3.6 KiB
ADR 0012: Text
- Status: accepted (2026-11-07)
- Relates to: roadmap M5 (text engine), ADR 0001 (persistent document), ADR 0002 (render pipeline), ADR 0005 (typography and fonts)
Context
Titles, captions, speech bubbles and credits are some of the most common things animators put on
the stage, and Animate documents are full of text. Text depends on fonts, and fonts differ
between computers: a document made on one machine may be opened on another that lacks its
typeface. The renderer is the oracle (AGENTS.md rule 4) and evaluate must stay pure (rule 3),
so neither may depend on which fonts happen to be installed.
Decision
- A text element keeps its source and its outlines.
ElementKind::Text(Arc<TextBlock>)stores the text and its style (font family, size, bold, italic, colour, alignment, letter and line spacing, and an optional width that wraps lines), plus the glyph outlines the engine computed for them (outline: Arc<Path>, local coordinates, top-left at the origin) and the layout box. The outlines are saved with the document. - Rendering uses the outlines only.
evaluateturns a text element into one filled display item, so the stage, every export (PNG, GIF, SVG, Lottie, sprite sheet, video) and hit testing treat it like a shape. A document looks the same on every computer, with or without its fonts. Exactness comes from the font data and the shaper, not from the platform's text rendering. - The engine lays text out when it changes. Creating or editing a text element (a command, so undoable) shapes it with the fonts on this computer and stores the new outlines. Opening a document never re-shapes it. If the stored family isn't installed, editing falls back to the default family; the element records the family actually used and the command says so.
- A text crate (
anicraft-text, layer 1) owns fonts and layout. It finds fonts withfontdb(system folders,CRAFT_FONTS_DIR, and faces the app registers, such as its embedded Inter), shapes withharfrust(a HarfBuzz port), reads outlines and metrics withskrifa, and breaks lines (paragraphs at line breaks; with a width, greedily at spaces). These crates are already in the dependency tree through egui, so no new licences. Bold and italic pick the matching face of the family; there is no synthetic styling. - Break Apart turns a text element into a shape with the same outlines, as Animate's second Break Apart does.
Consequences
- Files with text are bigger than the characters alone (the outlines are a vector path per block, stored like any shape's path).
- Changing a font on a computer that lacks it changes the look of that block only when it is edited, and the user is told.
- Text in Animate documents imports onto this model (ADR 0014).
- Not yet: per-character styles in one block, vertical text, text along a path, font embedding for export, glyph fallback across fonts for missing characters (missing glyphs draw as the font's "notdef" box).
Note (2026-11-11): text fields
Dynamic and input text fields are built on this model (ADR 0066): a block with field settings, whose box is the field's and whose stored outline is its authored text laid out inside the box, so rendering still uses only the outlines. Text a script sets or a viewer types is laid out by the player's host with the fonts on the computer that plays it.
Note (2026-11-12): text on a path
Static text can follow a path (ADR 0070): the block keeps a copy of the path, glyphs are set along it by arc length and stored as outlines as before, so rendering still needs no fonts.