Log inGet started

.font asset type

Updated December 4, 2026

A font is a general CPU resource usable by any text surface. The onRegister hook declares the face (font.declare) by the names that select it, and its data.zfnt is read the first time a text needs it: a label, a text.* object or SVG text naming the face, its group or one of its aliases in its font family, a character its coverage file lists that no installed face draws, or font.glyph / font.textMesh / font.load naming it. Reading it calls the engine font.register(name, bytes) primitive, which installs the parsed face into both the 2D/3D text system (text.*) and the egui UI text system, under the family name the font file itself reports. A family name reads the one face of the group whose role the text's weight and slant ask for, so bold text in Cousine reads CousineBold alone. Text drawn before the face lands is drawn in a fallback face and laid out again once it does. A registration is what puts the face in the database; whether fontFamily = "<name>" selects it is the separate question of whether the shaper matches that name, and font.reconcile() answers it per family:

for _, f in ipairs(font.reconcile()) do
    if not f.selectable then
        print(f.family .. " is registered but shapes as " .. f.shapedWith)
    end
end

text.face(handle) gives the same answer for one label. A family the shaper's database holds is selectable under its own weights and for the glyphs its faces cover: a row that reads familyCoveredNoGlyph names a family the shaper picks whose faces have no glyph for the text asked of it. topics/text covers reading a label that came out in the wrong face.

Fonts are CPU resources (not GPU), so the primitive lives in the font.* namespace, the CPU analogue of renderer.texture.create.

Layout

<name>.font/
  data.zfnt         the baked payload `asset.create("font", ...)` writes
  face.json         optional: family group, role, aliases, coverage, boot, on-demand entries
  *.coverage        optional: the coverage file `face.json` names

face.json fields:

  • group, role, aliases: the family group the face stands in, its slot (regular, bold, italic, bolditalic) and the other names that select the group. Each of them, and the asset's own name, reads the face.
  • coverage: a coverage file in the folder (the text font.coverage(bytes) writes). A text surface meeting a character it lists that no installed face draws reads the face, which then draws it on every surface: the built-in DejaVuSans and NotoSansSymbols2 are the per-glyph fallbacks this way.
  • boot: true registers the face when the asset registers rather than when text first needs it.

Editing a font's files

A write to a file the registration reads (face.json, data.zfnt, the coverage file, or a raw font file in the folder) declares the font again from what the folder now holds, and registers it again when it is installed. The names the new face.json gives it (its group and each alias) select it on every text surface from then on, and a name the earlier descriptor gave it and the new one does not stops selecting it; a changed group moves the face to that group. Text laid out under a name the edit decides is laid out again, and a Text3D label draws it again on the next frame. For an on-demand face the same holds for the font and coverage files its entries name: the entries are declared again from their coverage files, and an entry already installed is registered again from its font file with the names the descriptor now gives.

On-demand faces

A face whose file is large and whose script most sessions never draw is declared by the codepoints it covers instead of being read at boot. Its face.json lists the font files of the folder under onDemand, each beside a coverage file:

NotoSansCJK.font/
  face.json           { group, role, aliases, license, onDemand = [ { name, file, coverage }, ... ] }
  kana.otf            a font file (TTF / OTF)
  kana.coverage       the codepoints it maps: "3000-30ff,ff01-ff5e,..."
  ...
  OFL.txt             the license the files are distributed under

onRegister reads the coverage files and calls font.declare(name, coverage, { file, family, role, aliases }) for each entry; no font file is read. The first time a label or a text.* object meets a character an entry covers and no installed face draws, the engine requests that entry: its file is read without blocking the frame and registered with font.register, and from then on every text surface draws the character from it. font.onDemand() reports each entry as declared, requested, installed or failed, and font.prefetch(text) requests the entries a text needs before it is drawn.

font.coverage(bytes) writes a coverage file from a font file's character map. Splitting one large face into several entries (by script, and by how common a character is) means a session reads only the part its text reaches: the built-in NotoSansCJK.font is cut that way, and a page of Japanese reads its kana and common-ideograph entries alone.

Every installed face is a per-glyph fallback for every family the UI holds: a character the selected family has no glyph for is drawn from the first face that has one. A face declared with coverage is read for the characters it covers that no installed face draws.

A family the engine lacks

A text naming a family no installed face, no declared face and no host-OS face answers to brings it from ZeroMind: the engine reads the .font assets the font source worlds publish (the Optional Fonts world), finds the family by its group, a face's own name or an alias its face.json gives, declares every face of the family for the session with font.declare, its bytes read from ZeroMind's content store when a text first draws in it, and draws the text in it once the face arrives. Nothing is written to the world, in an editing session and a player's alike, so a family a text names never appears among the world's changes; a session brings the family again each time it opens the world, until the world holds the faces itself. To keep a face in the world, install it like any asset (world.installAsset({ guid, at = "/source/fonts" }), the call each family's detail names). font.load(name) brings a family the same way. font.missingFamilies() reports each such family as asked, fetching, fetched or absent, with the texts that named it and the faces declared or why none was.

When the fonts ZeroMind holds cannot be read for a reason ZeroMind can answer differently later (a server error, a refusal to take more requests now, a network failure, no answer in time), the families wait as fetching and the fonts are read again, sooner at first and then every few minutes, until a read answers; the text then draws in the family. A refusal that stands marks the family absent at once.

In the Inspector

Selecting a font opens its Font section: the family the face registers under, its role and aliases from face.json, whether the text system has the family registered and, when it holds it, how many faces and which weights. Below the facts, a sample line is drawn in the family at 14, 20 and 32 px.

  • asset-type
  • reference