|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Calinou |
|
Old Version |
Published before Godot 3 was released. |
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)
|
|
|
|
Reply From: |
jackmakesthings |
You can do something like this:
var theme = get_theme()
var newfont = load('assets/fonts/different-font.fnt')
theme.set_default_font(newfont)
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.)