Repository navigation
Description
Problem
A text style names one font. On an embedded font a character that font lacks is drawn as glyph 0 (#592); on a standard-14 font ShowText
writes ? (PdfCanvas.cs:614-650). Either way the caller has no way to
say "use font B for what font A does not cover". (origin/main 1c61fa6.)
src/VellumPdf.Layout/Core/TextStyle.cs:59:public FontReference FontRef { get; init; } = Standard14.Helvetica;,
one font per style.src/VellumPdf.Kernel/Fonts/EmbeddedFontHandle.cs:38-47:GetGlyphIdsmaps every rune through one embedder.ParagraphRenderer.cs:598tokens carry oneTextStyleeach, and a word is one token (:593-598).
Why it matters
A product that mixes a text font with a symbol font has to split every run by coverage by hand. That only works
once #590 is fixed (today a run boundary inside a word draws a space).
Measured 2026-11-17 with fontTools 4.62.1 on in-tree files: LiberationSans-Regular.ttf has no U+2609 and no
U+263D, and DejaVuSans.ttf has both (and 96 private-use code points at U+E000 to U+F8FF, with U+EF00 and U+F6C5
present). A planning-session measurement (2026-11-17, not re-run here) found no planet or zodiac sign in Inter,
IBM Plex Mono or Bodoni Moda, and 13 of 13 planets and 12 of 12 zodiac signs in DejaVuSansAstro.ttf. Those
three fonts and that file are verification inputs only; they are not bundled and are not committed.
Scope
- An ordered fallback list on the style (
TextStyle.FallbackFonts, or onDocument; the design review decides)
of embedded or standard-14 fonts. The first font whose cmap covers a character draws it. - A word that mixes fonts is one unbreakable unit and wraps as one (Layout: adjacent text runs are joined with a space that is not in the text #590's tokeniser). Measurement uses the
glyph advance of the font that draws each character. - A character that no font in the chain covers is reported (Kernel: a character missing from an embedded font is written as glyph 0 (.notdef) and the save reports nothing #592) naming every font tried.
- Each font actually used is embedded as a subset with its own ToUnicode map. ISO 19005-2 6.2.11.5 (widths in the
font dictionary and in the program agree within 1/1000 unit) holds per font. - Text extraction returns the original characters in order, whichever font drew them.
- A style with no fallback list behaves and writes exactly as today.
- The standard-14 path is not part of the chain's coverage logic beyond WinAnsi: a standard-14 font can only
cover what WinAnsi covers (PdfCanvas.ShowText,PdfCanvas.cs:614-650); the brief states what the chain does
with it.
Acceptance
- A paragraph in LiberationSans with fallback DejaVuSans and the characters U+2609 and U+263D (both in-tree
fonts) draws them from DejaVuSans: the glyph ids come from the DejaVuSans subset, both fonts appear in the
resource dictionary,pdftotextreturns the original characters. - A character in neither font is reported once with both font names, and still saves in default mode.
- A word of
a+ U+2609 +bwraps as one word. - Widths in each embedded font dictionary match the program within 1/1000 (assert on the font dictionaries).
- A style without fallbacks produces the bytes it produces today (golden test).
- Tests use the in-tree fonts only.
- The test fails on origin/main 1c61fa6 (no such member), proven by mutation.
Relates to
- Layout: adjacent text runs are joined with a space that is not in the text #590 (cross-run tokenisation), Kernel: a character missing from an embedded font is written as glyph 0 (.notdef) and the save reports nothing #592 (reporting), Kernel: cmap format 12 is ignored, so no character outside the BMP can be drawn from an embedded font #595 (non-BMP coverage), Layout: ActualText on a TextRun, so private-use characters and special glyphs extract as the intended text #602 (private-use characters
need/ActualTextat level A), Layout: named styles with inheritance #292 (named styles).
Activity
fix(layout): read a zoned band's runs and every drawn list level for …
style(layout): format the walk's constructor initialiser (#601)
fix(layout): read deep list levels only for lists that draw them, per…
fix(layout): read every list level for a chain, whether or not the li…
docs(layout): say on DrawNestedListLevels that a fallback chain is re…
fix(layout): read the children of a null-text list item for a chain (#…
docs(layout): state what a twin refuses and what the chain read covers (
docs(layout): state which list items the chain read covers, once (#601)
Merge origin/main into feat/font-fallback, and read range bands for a…
docs(layout): finish the one rule for list items and pin what it leav…
Merge origin/main into feat/font-fallback (#790 run anchors)