Create something like get_wordwrap_string_size for RichTextLabel controls. #4858
HauntedBees
started this conversation in
Scripting
Replies: 1 comment 1 reply
-
RichTextLabel was rewritten in 4.0.alpha, and this feature may already be available there. The rewrite won't be backported to 3.x as it's backwards-incompatible. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now, if I have text in a
Label
orRichTextLabel
that cannot fit in the control, the overflow will either be cropped off or, ifscroll_active
is true, a scrollbar will be added to view the remainder.As a third option, I am writing some code that will split the text apart into separate chunks, where each chunk would be as big as possible for the control. So if a 100-character message were placed in a control that roughly fits 40 characters, this code would return two 40-character chunks and one 20-character chunk, and accompanying code would allow navigation between them.
To determine when some text is too big for its control, I am using
DynamicFont.get_wordwrap_string_size(the_string, rect_size.x)
. Aside from needing to add some padding to the rect_size, this works forLabel
andRichTextLabel
controls without BBCode.However, BBCode allows multiple fonts with the
[b]
,[i]
,[code]
, and[font]
tags. As theget_wordwrap_string_size
method is on the font, not the control itself, there's no apparent way to determine how much space text likethis text is [b]bold in some places[/b] and [i]italic in others[/i]
would take up in a given control.The use case I'm intending is to allow players to adjust their in-game font size and not have to worry about dialog with NPCs being cut off (and not having to use scrollbars to see overflow text).
Is this currently possible in Godot (3.4), are there already plans for something like this to be possible, and would this be of benefit to others for use cases aside from the one I've described here?
Beta Was this translation helpful? Give feedback.
All reactions