Error: Font Not Found (SOLVED)

In Platformer Creation Kit, I tried what happens if I change the font size from 32 to 64, and now the Main Menu is broken:

Error: font ‘main_menu_font’ not found.

Suggestions?

Double-check that it’s still added to the gui with the correct name:

Close the project and open it again if it doesn’t work. Try building and checking the console for any clues.

Reopening the project worked.

By the way, did I do it correctly - I mean changing the font size? You just change it in frameworks, fonts and that’s it? You don’t use scaling in Gui, Nodes, text, Properties?

If I want to use many sizes of the same font, do I copy-paste the same font or what is the best way of having many sizes of the same font?

You have two options:

  1. Make copies of your font and change the size on the different copies
  2. Change font type from Bitmap to Distance Field. Distance Field fonts can be scaled in gui nodes or labels without losing quality. Read more here: https://www.defold.com/manuals/font/#_distance_field_fonts

If we are talking about optimizing CPU and/or memory, which kind of font is better?

If you need various sizes distance field font takes less memory but consumes more GPU.

I made a new font with size 64 by copy-pasteing, restarted the Defold editor, but the new font doesn’t show up. Do I need to “register” fonts or something like that?

1 Like

Have you added the font to the GUI scene, as described in the official manual?

Do I right-click … / framework / fonts, New, Font File? That does not seem logical as the file has been already been created by copy-pasteing.

OMG. I misunderstood.

1 Like

As described in the linked page;

The fonts that you wish to use in GUI text nodes must be added to the GUI component. Either right-click the Fonts folder, use the GUI top menu or press the corresponding keyboard shortcut.

You need to add the font resource to your GUI scene, by right clicking on the Fonts folder under the Gui node in the Outline panel to your right.

The reason you need to explicitly add the font resource to your GUI is so that the engine knows what resources it needs when displaying the GUI, optimizing memory usage! :slight_smile:

2 Likes

I was a few seconds faster than you, sven. Seems like I need more explicit images to get it. :relaxed:

2 Likes

Haha, hey you solved it, that’s the important part!

2 Likes