Skip to content

Kernel: Symbol and ZapfDingbats have no advance-width tables, so every string in them measures zero #470

Open

Description

@Tim81

Standard14Metrics holds advance-width tables for 12 of the 14 Standard 14 faces. Symbol and
ZapfDingbats are absent, so GetWidth returns 0 for every character in them and MeasureString
returns 0 for every string.

Mechanism

src/VellumPdf.Kernel/Fonts/Standard14Metrics.cs — _tables maps 12 faces; GetWidth opens with

if (!_tables.TryGetValue(font, out var table)) return 0;

Measured across all 14 faces: only Symbol and ZapfDingbats return 0 for "AB".

Why it matters rather than being a dead corner

These two are a supported configuration, and the library treats them as one deliberately:
PdfFontResource omits /Encoding for exactly these two faces so their built-in symbolic encoding
applies. Their glyphs therefore carry real advances in a viewer, while the library believes every
one of them is zero wide.

Everything downstream that positions by a measured width is wrong for them:

  • Running bands. Measured after the truncation fix in fix(layout): bound running-band text to the content box #469: a 500-glyph Symbol footer on a
    300pt page with 50pt margins, centre-aligned, emits all 500 glyphs, is placed at x = 150 from a
    measured width of 0, and reports no truncation. The defect fix(layout): bound running-band text to the content box #469 fixes therefore survives intact
    for these two faces, and the caller is not told.
  • Paragraph wrapping. A word of zero measured width never exceeds a line, so a Symbol
    paragraph collapses onto one line however long it is.
  • Table auto-width. A column whose content measures zero gets its minimum share.
  • Justified text. The gap arithmetic divides by a measured total.

What the fix is

Add the two width tables. Both faces have published Adobe Core-14 AFM metrics, the same source the
other twelve tables came from, so this is transcription against an existing provenance rather than
new derivation.

Scope note

Fixing it in the layout engine is not possible: FitToWidth and the wrap routines have no width to
work from. #469 documents the consequence at the call site and points here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions