Extension-fontgen

We’ve added a new extension extension-fontgen which allows for runtime generation of distance field fonts.

A big benefit of this is that you can use a single .ttf file to populate multiple fonts at runtime.
This improves:

  • Download size
  • Runtime memory usage

Known limitations

This is an MVP1, with some known limitations listed, but it’s already useful at this stage.

Workflow differences

It requires you to add a .ttf font as a custom resource, and also create an empty font file.

However, the main difference in workflow from regular fonts is that the developer has to populate the font with glyphs by calling a script function ahead of time of displaying the text.

The script api gives you a callback when the glyphs are generated (on a thread if available), so you know when you can display the new text.

Example

As usual, the extension is also useable as a test project, and this is what it currently looks like:

24 Likes

This is really great thank you!

1 Like