Why do custom fonts not show up on html5 export but work when testing with the built in webserver?

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

As the title says. Its like the ttf file is not part of the resources when exported. Running the html project from the editor shows the fonts in the browser.

:bust_in_silhouette: Reply From: Croze

Bump, having a similar issue and can not find a solution. My only idea is to maybe host the .ttf on my website’s file manager, and set the font at runtime. Although I’d much rather it just export with the other resources before I dive into whether this is feasible.

Ok so I got it working through export after digging through a few helpful forums:
https://forum.godotengine.org/59637/cannot-traverse-asset-directory-in-android?show=59637#q59637
https://forum.godotengine.org/158/how-to-create-a-font-on-runtime-to-use-on-a-label

Here’s my step-by-step on how I got it working:
Ensure all .ttf (or similar font files) are located in the res:// Resource Folder (or a subdirectory)
Create a dynamic font (.tres), Right click ‘Font Data’ → Load → Select whichever .ttf you put in your Resource Folder
Add the following code in _ready() [NormalFont and BoldFont are the DynamicFonts you created before]:
richtxtboxvariable.add_font_override(“normal_font”, ResourceLoader.load(“res://NormalFont.tres”))
richtxtboxvariable.add_font_override(“bold_font”, ResourceLoader.load(“res://BoldFont.tres”))
…etc for Italics/BoldItalics
Go into Project → Export → HTML5 Resources tab and enter *.ttf in the ‘Filters to export non resources’ text entry
Export

There may be other ways to do it, this is just how I got it to work.

:bust_in_silhouette: Reply From: andy_

I also found a solution in the end. Make sure you save your scenes before you export!