chrisdill / raylib-cs

C# bindings for raylib, a simple and easy-to-use library to learn videogames programming

Home Page:http://www.raylib.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MeasureText always returns 0

Berkant03 opened this issue · comments

Before submitting a new issue, please verify and check:

  • The issue is specific to Raylib-cs and not raylib
  • I checked there is no similar issue already reported
  • My code has no errors or misuse of Raylib-cs

Issue description

When using the Raylib.MeasureText method it always return 0.
Tried it out in c++ and the Method returned not 0 and therefore worked there.
After writing my own Method (Copy past of the C code) i encountered that the GetFontDefault() function always returns a 0 Font
Object, where everything is default Initialized.
After Looking closer at the C-Code i saw that it checks if the DefaultFont was Loaded and if not return 0. In this case the Default Font
is not loaded, but looking at the Console-Output generated by Raylib, it say that it loaded:
INFO: FONT: Default font loaded successfully (224 glyphs).

Environment

Windows 10 22H2 Build 19045.3448, OpenGL 3.3.0 GLSL 4.60, RX 6700xt, Raylib-cs-4.5.0.4., Visual Studio 2022 .Net 7

Found the issue while creating a TextBox and trying to center the Text inside it.

After you added some tags, i tried it again. At first it still returned the 0, but after using a minimal example i found out that if i use it directly after the Window initialization that it worked.
Turn out i did not create the Raylib Context fast enough before using the the MeasureText method.
Sorry for the inconvenience caused, because i could not see underneath the underneath.