in godot 3.5.3 in Label class instance how to get string for every line? wordwrap enabled
- User
in godot 3.5.3 in Label class instance how to get string for every line? wordwrap enabled
- Assistant
In Godot 3.5.3, if you have a
Labelinstance with word wrapping enabled and you want to retrieve the text for each individual line, you can do this by using theget_visible_line_count()method in conjunction with theget_line_string()method.Here's a step-by-step guide on how to achieve this:
-
: Make sure that the node has the property enabled. This is necessary for the label to wrap text as intended.
-
- User
in godot 3.5.3 class Label has no method "get_line_string". What maybe alternatives to get single line separated with \n?
- Assistant
In Godot 3.5.3, the
Labelclass does not have aget_line_string()method. Instead, you will need to manually split the label text into lines based on the\nnewline character. While this method doesn't consider word wrapping or how the text is visually displayed in the label, it will separate the text into lines based on newlines in the source string.Here's how you can achieve this:
- User
This also doesn't fit. Because I can't get "\n" characters from just Label instance's text property for advance - it has no these delimiters.
- Assistant
- User
I'd glad to use RichTextLabel, but it also has no method "get_line_text"
- Assistant
- User
ok. Godot 3.5.3 has Font class. Specifically I use BitmapFont class inherited from that. And this BitmapFont instance loads from external atlas file .fnt. How can i get width of every bitmap character from this font?
- Assistant