The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hey guys!

I'm trying to adjust a label.rect_size.x (I'm making a dialog box) relative to the size of the a text inside a it. More precisely, I want the rect_size.x to be the minimum needed size to display the text. I'm using this code :

label.rect_size.x = label.get_font("mono_font").get_string_size(label.text).x 

But the get_string_size() returns a pretty small number and the text does not if in the label (letters are missing). Is the size returned in pixel? Maybe I'm not actually getting the good font? (I have a custom mono_font on my RichTextLabel, I did not find any other way to get the font from my label).


in Engine by (25 points)

1 Answer

+1 vote
Best answer

Ok, seems like I used the wrong font ;) With "normal_font" it is working as intended.

by (25 points)

I was also making a dialogue box and your code helped me out. Thank you so much!

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 Frequently asked questions and 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 [email protected] with your username.