Changing fallback font in default system font resource

Godot Version

4.2.2

Question

Hi Everyone,

I have a system_fonts.tres resource setup in the project options as a custom font to be used as the default font for any control.

This font resource has a number of fallback fonts in case one is not available on the users system. They are all standard mono spaced fonts so that really shouldn’t be a problem.

My question is, is it possible in code to change which font from this resource file is being used. It would be nice, to be able to cycle through these fonts should the user desire.

Kind Regards

Ryn

I’m guessing then that this mustn’t be possible. I’ll usually pretty good at finding a solution to most problems, but this has me completely stumped.

Ryn

using this:
gui/theme/custom_font

if you noticed, it needs to be a theme. but this setting should change the entire game font
but you will need to have the theme ready and load the font by theme with path

Thanks for that. I’m still not sure what I’m doing wrong.

I’m using the following but fonts don’t seem to update.

"0":
	ProjectSettings.set_setting("gui/theme/custom_font", "res://Resources/system_fonts_courier.tres")
	get_tree().reload_current_scene()
"1":
	ProjectSettings.set_setting("gui/theme/custom_font", "res://Resources/system_fonts_monaco.tres")
	get_tree().reload_current_scene()

Even using theme resources doesn’t seem to change anything so not sure what I’m doing wrong

"0":
	ProjectSettings.set_setting("gui/theme/custom", "res://Resources/courier_theme.tres")
						
"1":
	ProjectSettings.set_setting("gui/theme/custom", "res://Resources/monaco_theme.tres")

have a read on this

so the idea is to not use the project settings’s custom font
but instead, have your main node of your game or typically any main GUI node to change theme according to the user. this should guarantee your font changing without needing to restart the whole game

1 Like

Thanks so much I’ve now got it working, though it’s a pain that you can’t just use a project theme.

Ryn

1 Like