Fonts
The WASM compiler embeds the default font set. Additional fonts need to be loaded.
- Eager - hand the engine the font up front using
addFont/addFonts. - Lazy - register stubs so font names appear in autocomplete
and let the engine pull the bytes on demand through your
fontask handler.
Eager
addFont accepts a single TTF/OTF file (which may contain multiple faces);
addFonts takes several at once.
After this the family is usable in the document.
Lazy
A FontStub describes a face without its bytes:
Register a font loader when constructing the engine. It receives the key
from the stub the compiler decided it needs, and returns the bytes:
The bytes for inter-bold are only fetched the first time a document actually
uses Inter at weight 700. The key is opaque to the engine - encode whatever
your loader needs (a URL, a catalog id, a cache key).
Notes
addFontStubs can be called any time on a running engine - for example after
the user uploads fonts manually.
The compiler wants raw SFNT bytes (TTF/OTF). If your source is woff2, decode
it to SFNT before handing it over. The engine does not unpack web fonts itself.