0 votes


I'm trying to make a dynamical resizing height dialog (the width will always be fixed). My control (dialog) has 1 background texture, a title (fixed maximum width), a text (fixed maximum width) and some buttons (OK, Cancel, Yes, No, etc).

Title type: Label
Text type: RichTextLabel

What I want to do:
1) Resize the background texture (the height) every time I set the title, the text and set the buttons:
var title_height = get_node("Title").get_line_height() var text_height = ? (I need this information) var total_height = top_margin + bottom_margin + dist_between_title_ and_text + dist_between_text_and_buttons + title_height + text_height var texture_height = total_height.

2) Rearrange the buttons' positions by the size of the total height:
var buttons_pos_y = top_margin + dist_between_title_ and_text + dist_between_text_and_buttons + title_height + text_height

Please see in the above code what I need to find out (there's a question mark).
I looked in RichTextLabel class and I couldn't find nothing like get_text_size() or get_text_width() & get_text_height()

P.S. Both (title and text) controls have Dynamic Font (.ttf) set.


in Engine by (104 points)


I know this is like a necrobump, but did you ever solve the problem?

I'm looking for a way to get_text_width() too but so far haven't found a solution.

1 Answer

0 votes

I'm dealing with a similar issue in my own project! You can use get_size().y on the RichTextLabel to get its height - you may need to set the Vertical size flags to "Expand, Fill", that's generally what I'm doing. I'll see if I can put together a demo version from what I've done, but start with that.

by (332 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.