Skip to content

Kernel: a character missing from an embedded font is written as glyph 0 (.notdef) and the save reports nothing #592

Closed

Description

@Tim81

Problem

On the embedded-font path an unmapped code point becomes glyph 0 without any report, and the ToUnicode map
then carries glyph 0. (Paths and lines are origin/main 1c61fa6.)

src/VellumPdf.Kernel/Fonts/Sfnt/CmapTable.cs:

25:     public ushort GetGlyphId(int codePoint) =>
26:         _map.TryGetValue(codePoint, out var gid) ? gid : (ushort)0;

TrueTypeFontEmbedder.GetGlyphId caches that result and registers glyph 0 as used
(src/VellumPdf.Kernel/Fonts/TrueTypeFontEmbedder.cs:61-68):

64:         var gid = _cmap.GetGlyphId(codePoint);
65:         _unicodeToGid[codePoint] = gid;
66:         _usedGids.Add(gid);

EmbeddedFontHandle.GetGlyphIds passes it on (src/VellumPdf.Kernel/Fonts/EmbeddedFontHandle.cs:44). The
ToUnicode builder writes every _unicodeToGid entry (TrueTypeFontEmbedder.cs:529-559), so each missing code
point adds a <0000> <...> line.

TextEncodingWarnings is filled only on the standard-14 path: PdfCanvas.ShowText
(src/VellumPdf.Kernel/Canvas/PdfCanvas.cs:614-650) adds one when WinAnsi cannot encode a character. The
embedded path adds none. (PdfPreflight does report the result afterwards, id ISO19005-2:6.2.11.8-notdef:
src/VellumPdf.Conformance/Rules/Fonts/GlyphPresenceRule.cs:551 and :724; the save itself says nothing.)
Document.TextEncodingWarnings (src/VellumPdf.Layout/Document.cs:57) is a copy of
the canvas list (:1016-1017). TextEncodingWarning carries only a Rune
(src/VellumPdf.Kernel/Canvas/TextEncodingWarning.cs), so it cannot name a font.

Measured

Measured in the 2026-11-16 handbook research on VellumPdf 2.3.3 (not reproduced for this issue): U+1F31F in
DejaVuSans was drawn as glyph 0, the ToUnicode map carried <0000> <D83CDF1F>, TextEncodingWarnings was
empty, and veraPDF ua1 and 2a both failed (ISO 14289-1 7.21.8, ISO 19005-2 6.2.11.8).

Measured 2026-11-17 with fontTools 4.62.1 on the in-tree fonts: DejaVuSans.ttf
(tests/VellumPdf.Conformance.Tests/Assets/) has no U+26B9 and no U+1F31F; LiberationMono-Regular.ttf
(src/VellumPdf.Fonts.Standard14/Fonts/) has no U+202F. These are the fixtures for the tests below.

A planning-session measurement (2026-11-17, fontTools, not re-run here) found no planet or zodiac sign in
Inter, IBM Plex Mono or Bodoni Moda.

Why it matters

ISO 19005-2 6.2.11.8 forbids any reference to .notdef from a text-showing operator, in any rendering mode
(read via NEN Connect on 2026-11-17). A PDF/A-2 file with one missing symbol fails it, and the save succeeds.

Scope (v2.4: report; refused only in strict mode, which is opt-in)

Acceptance

  • Text with U+1F31F in DejaVuSans yields one report naming U+1F31F and the font; U+26B9 likewise.
  • LiberationMono-Regular with U+202F yields no report: on origin/main 0a3be08 it is drawn as glyph 98, not glyph 0.
  • The saved ToUnicode CMap maps glyph 0 once, as <0000> <FFFD>, and names no missing character there (value-level assertion on the stream bytes).
  • A document without missing characters saves byte-identical to today (golden test).
  • Strict mode throws InvalidOperationException naming the code point and the font; default mode saves.
  • The XML documentation of the new members and of TextEncodingWarnings states which path fills each list.
  • The test fails on origin/main 1c61fa6, proven by mutation.

Relates to

Edited 2026-11-21: two acceptance lines corrected. U+202F in LiberationMono-Regular is drawn as glyph 98 on 0a3be08, so it is not a glyph-0 case; and glyph 0 keeps one ToUnicode entry mapped to U+FFFD instead of none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/fontsarea/layoutbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions