Repository navigation
Description
Problem
CmapTable.Parse reads formats 0, 4 and 6 only. Any other subtable format is skipped, and a font whose only
Unicode subtable is format 12 is refused. (origin/main 1c61fa6, src/VellumPdf.Kernel/Fonts/Sfnt/CmapTable.cs.)
65: else if (fmt == 0 || fmt == 6)
...
70: else
71: {
72: continue;
73: }
...
78: if (best < 0)
79: // Formats 0, 4, and 6 are supported. Format 12 (full Unicode) is not yet supported.
80: throw new NotSupportedException(
81: "font has no supported (format 0, 4, or 6) Unicode cmap subtable");Format 4 cannot hold a code point above U+FFFF. So even when a font has a format 12 subtable next to its format 4
one, the parser picks format 4 (priority 5 for platform 3 / encoding 1, :60-63) and every non-BMP character
maps to glyph 0 (:25-26), silently (#592).
Measured
Measured 2026-11-17 with fontTools 4.62.1 on tests/VellumPdf.Conformance.Tests/Assets/DejaVuSans.ttf
extracted from origin/main 1c61fa6: subtables (platform, encoding, format) = (0,3,4) (0,10,12) (1,0,6) (3,1,4)
(3,10,12); 548 code points above U+FFFF, all in the format 12 subtables; U+1F600 is among them and is absent
from the format 4 subtable. A planning session measured 14 non-BMP code points in SourceSans3-ExtraLight.otf
(CFF) in the same way; that figure was not re-measured here.
The handbook research on VellumPdf 2.3.3 (2026-11-16, not reproduced here) reached the same conclusion from the
code: no character outside the BMP can be drawn.
Scope
- Parse format 12 (sequential map groups) and prefer it when it is present: platform 3 / encoding 10 first,
then platform 0 with encoding 4 or 10. Keep the format 4 subtable for fonts that have no format 12. - Accept a font whose only Unicode subtable is format 12 (today it throws,
:80-81). - Bound the work. Format 12 groups can describe 2^32 code points, so the parser needs a code point budget like
Format4CodePointBudget(:18) and a group-count check against the subtable length. - The ToUnicode builder already writes a surrogate pair for a supplementary code point
(TrueTypeFontEmbedder.cs:551-558), andEmbeddedFontHandle.GetGlyphIdsalready walks runes (:41-44), so
no change is expected there. A test confirms it.
Acceptance
- DejaVuSans draws U+1F600 with its real glyph (not glyph 0) and the ToUnicode map has
<gid> <D83DDE00>. - The glyf path and the CFF path both pass (DejaVuSans and
SourceSans3-ExtraLight.otf, both already in the tree). - A font whose cmap has only a format 12 subtable loads. No such font is in the tree; the test builds one in-test
by rewriting DejaVuSans's cmap table bytes to drop the format 4 and 6 subtables. No new font file is added. - A hostile format 12 subtable (group count beyond the table, overlapping groups spanning billions of code
points) is refused withInvalidDataException, bounded by the code-point budget (a count, not a wall-clock time). - A BMP-only document produces the same bytes as today (golden test).
- The test fails on origin/main 1c61fa6, proven by mutation.
Activity