-
-
Notifications
You must be signed in to change notification settings - Fork 342
Description
Issue description
warning: I'm sorry, I want to report this, but since I haven't tested the examples in C but in Python, I can't be sure that the problem wasn't introduced by the bindings. However, I tried to create a very minimalist code that I think it's simple to replicate in C. I apologize for my lack of knowledge. I think that if I continue to use raylib in the future, I might as well try to switch to C since there is more material available.
the problem: Specifying a font with LoadFontEx and then GuiSetFont results in a font of GuiTextBox with a different size than using the same font directly with DrawTextEx at the same size.
Previously I ran some tests using a square monospace font and verified that DrawTextEx draws the font in the expected size (just configure a window with dimensions that are a multiple of the font size and check that the margins match).
So I think there may be a problem in raygui.
I did another test specifying the same size and overlapping the two text boxes, and I noticed that GuiTextBox seems to have more spacing between characters (even though the font size seems right, in previous tests I had noticed a discrepancy there too, I also wrote about it on Reddit, but I couldn't recreate this problem).
It's not a big problem, but this way I can't predict how much text will fit into a GUI element, so I have to make rough estimates (and it's a bit inconvenient when you want to create a parametrically scalable interface)
Environment
Archlinux derivative, the package from the repository works but being compiled for opengl 3.3 was not useful for me.
$ glxinfo | grep "OpenGL version"
OpenGL version string: 2.1 Mesa 24.1.1-arch1.1
I am not able to figure out what gpu i have, it is an intel integrated in a thinkpad x201t driver i915
Issue Screenshot
Here is the output of the example snippet. You can see that the text in the GuiTextBox (in gray in the background) expands more than that of DrawTextEx (in red in the foreground), even though they are the same size.
Code Example
import pyray as rl
mult = 1
swdt = 800*mult
shgt = 100*mult
tdim = int(swdt/10)
rl.init_window(swdt, shgt, "win")
font = rl.load_font_ex("square.ttf", 100, None, 0)
rl.gui_set_font(font)
rl.gui_set_style(rl.DEFAULT, rl.TEXT_SIZE, tdim)
text = "|||||||||"
while not rl.window_should_close():
rl.begin_drawing()
rl.clear_background(rl.BLACK)
rl.gui_text_box(rl.Rectangle(0,0,swdt,shgt), text, 2, False)
rl.draw_text_ex(font, text, [5, int(shgt*0.1)], tdim, 0, rl.RED)
rl.end_drawing()
rl.close_window()