+1 vote

I have a number (on a Label) that, depending on how many columns and rows my board has, I want to be able to set as a larger or smaller font size.

I know that we can use Dynamic Fonts now, so we don't need to import a font for each font size we want- but how do I modify the font size of a Label from code, so I can set the font size when the board is created?

asked Nov 28, 2016 in Engine by JymWythawhy (30 points)

1 Answer

+4 votes
Best answer
get_node("path_your_label_node").get("custom_fonts/font").set_size(100)

...where 100 is your new font size

-j

answered Nov 28, 2016 by jospic (1,451 points)
selected Nov 29, 2016 by JymWythawhy

and for godot 3.0 how can I change a button font size please?

you could use a theme, follow this video on how to do:
https://www.youtube.com/watch?v=g3p3rtdqCDk&t=608s
-j

thank you jospic, I would have loved to do it the "getnode("pathyourlabelnode").get("customfonts/font").setsize(100)" way but that's ok. Thank you for your reply. Have fun!

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.