Repository navigation
Description
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)
- Kernel: when a code point maps to glyph 0 on the embedded path, record it (code point and font) in a list the
canvas and document expose. Additive API:TextEncodingWarningkeeps its shape, and the font name comes
through a new type or member (design review). - Write no ToUnicode entry for glyph 0. The glyph is still drawn, so a document without missing characters
keeps its bytes. - Layout surfaces the list on
Documentthrough the diagnostics channel (Layout: one general diagnostics channel and an opt-in strict mode (the additive half of #496 and the channel of #304) #607). - Refusal is strict mode only. Default refusal is 3.0 (Refuse the input 2.3.x only reports: the contract changes a patch cannot make #484). A document that saves today still saves by
default. - Fallback fonts that cover the missing characters are Layout: a per-character font fallback chain on TextStyle #601.
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
InvalidOperationExceptionnaming the code point and the font; default mode saves. - The XML documentation of the new members and of
TextEncodingWarningsstates which path fills each list. - The test fails on origin/main 1c61fa6, proven by mutation.
Relates to
- Conformance: a PDF/A or PDF/UA claim is stamped on a document the library's own preflight rejects #474, Layout: NormaliseWhitespace turns U+202F NARROW NO-BREAK SPACE and U+2007 FIGURE SPACE into break points #562, Refuse the input 2.3.x only reports: the contract changes a patch cannot make #484, Layout: one diagnostics channel, before a third one-off warning type is invented #496 (one diagnostics channel).
- Layout: a per-character font fallback chain on TextStyle #601 (fallback chain), Layout: one general diagnostics channel and an opt-in strict mode (the additive half of #496 and the channel of #304) #607 (diagnostics channel), Kernel: cmap format 12 is ignored, so no character outside the BMP can be drawn from an embedded font #595 (non-BMP characters are glyph 0 today because
cmap format 12 is not read).
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.
Activity
fix(kernel,layout): settle review findings on the glyph-0 and unembed…
fix(kernel,layout): report glyph 0 and unembedded fonts (#657)