Font glyph streaming


Threaded async glyph streaming from disk to a texture atlas in memory. Let us define a list of characters to always have loaded, and then stream in the other characters as needed from a binary of available glyph textures - as in the texture atlas buffer is resized and updated to add extra glyphs as they are requested by text components.

What it could look like in engine is either let text not display unloaded glyphs until they are loaded, or let us request glyphs to be available based on a body of text so that when we choose to display new text we can make sure all glyphs for it are loaded first (we could show a spinning icon while waiting for load complete for example).

This could make supporting certain languages much more memory friendly.

Obviously this is a big feature and should not be treated as urgent but still important as the Chinese market becomes more important. It is how I thought Defold’s way of doing font glyph loading worked when I first read about it.


Hmm, isn’t this how it is working?


It’s my understanding that ALL glyphs are loaded into memory all of the time. So if you have a big font with thousands of characters you need huge textures since it’s not paged either?


@Sven and @jhonny.goransson can confirm how it works. But it is my understanding that the glyphs needed for rendering all text currently in labels and text nodes are the ones in the font texture. It would otherwise be impossible to use Asian languages since the number of available characters are far more than what can fit into memory.


Not really impossible, you would scan your text and only list the characters in the text to be included in the font. That doesn’t allow user text easily though, and can be a pain.


Maybe I’m misunderstanding you, but it sounds exactly like how Defold currently handles font glyph loading. :slight_smile:

A font resource in Defold will result in two things at runtime, a texture and the “font data blob”.

  • The font data blob is really just a big list of glyph entries, each containing some basic kerning info and the bitmap data for that glyph/character.
  • The texture is internally called the “glyph cache texture” and what will be used when rendering text for a specific font.

During runtime, when the engine needs to render text (GUI text, label components or debug text), it will first of all loop through the characters to be rendered to check which glyphs are available (or not) in the texture cache. For each char that don’t have the corresponding glyph in the texture cache will trigger a texture upload (or streaming if you want to call it that) from the “font data blob”.