0 votes

I'm looking for a way to change the default font of a theme by code. This would be used to implement font scaling depending on the window size.

I've found how to change the custom font of a label already:

get_node("MyLabel").set("custom_fonts/font", my_font_data)
asked May 30, 2016 in Engine by Calinou (6,560 points)

1 Answer

+1 vote

You can do something like this:

var theme = get_theme()
var newfont = load('assets/fonts/different-font.fnt')

I haven't confirmed whether this works on controls that just inherit a theme; if it doesn't, just call get_theme() on the themed parent control instead.

(Also, if all you're changing is the size, you can probably refine this to use DynamicFont and DynamicFontData.)

answered May 31, 2016 by jackmakesthings (314 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.