Is it possible or not possible to change font size without loading custom font?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Charlie

This is either trivially easy or not possible, and I can’t tell which after tracking down about a dozen Q&A posts here, GitHub issues, or other random google sources. (Sorry for the tone of exasperation…)

If it matters, I’m working on a Button. One answer I saw was to change rect_scale. This DOES change the font size in the editor, but does NOT change font size in my running game. I can tell by print(my_button.rect_scale) that my change “sticks”. Other threads offer other solutions but these all seem to involve custom fonts even when the question was “without loading custom fonts”.

I realize I may want a custom font someday. But I’m just prototyping ideas now.

If the answer really is “not possible”, I would greatly appreciate a tip on where to find one without entering the malware storm that threatens when I google “free font”.

:bust_in_silhouette: Reply From: SleepyTom

In answer to the second part of your question, I use Google Fonts - free and no malware

:bust_in_silhouette: Reply From: Calinou

It is not currently possible to change the size of a font without importing a custom font. However, it is easy to import custom fonts by creating one or several DynamicFont resources which can load TTF or OTF font files into them – the only prerequisite is to drop a font file into the project folder.

Many websites distribute open source fonts that can be freely used in personal and commercial projects, such as Google Fonts or Font Library (which offers hundreds of fonts that are not provided by Google Fonts).

For information, the default fonts used in Godot are:

  • in Godot 3.0: Noto Sans in the editor, Droid Sans in projects, Hack in the script editor,
  • in Godot 2.1: Droid Sans in the editor and projects, Source Code Pro in the script editor.

Thanks! I have my answer now!

Charlie | 2018-04-20 00:19

:bust_in_silhouette: Reply From: zen3001

I know, 3 years late but still for a quick (kind of hacky solution) for anyone in the future looking up this thread. if you only need this for buttons you might just use images instead.

:bust_in_silhouette: Reply From: SteveSmith

You can attach the button to a Node2D, and then change the scale. This will scale the button and its font accordingly. And look a bit crap though.