- #1
Darkmisc
- 220
- 31
- TL;DR Summary
- I'd like my text to always fit on one line within a label. Is there a way to do this automatically?
Hi everyone
So far as I can tell, there is no function to automatically shrink text to fit on one line within a label in Godot 4. Instead, I'm going to get the length of each string with
len(string)
and use
Label.set("theme_override_font_sizes/font_size", size)
to adjust the size according to the length of the string. However, I think this will lead to the font size sometimes being smaller than it needs to be. Is there a better way of doing it?
I wanted to measure the width in pixels for a given string (at a given font size), but I'm not sure that function exists either.
Thanks
So far as I can tell, there is no function to automatically shrink text to fit on one line within a label in Godot 4. Instead, I'm going to get the length of each string with
len(string)
and use
Label.set("theme_override_font_sizes/font_size", size)
to adjust the size according to the length of the string. However, I think this will lead to the font size sometimes being smaller than it needs to be. Is there a better way of doing it?
I wanted to measure the width in pixels for a given string (at a given font size), but I'm not sure that function exists either.
Thanks