Topic was automatically imported from the old Question2Answer platform.
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.
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.
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.