Repository navigation
Subset font tags and escaped names (from #48), with CIDSet for PDF/A-1 - #50
Merged
Merged
Conversation
An embedded TrueType subset was named after the whole font: /BaseFont /Inter-Bold. ISO 32000-1 §9.6.4 requires a subset's name — both /BaseFont entries and the descriptor's /FontName — to start with six uppercase letters and a plus sign: /BaseFont /DCFUHW+Inter-Bold. Without the tag, two subsets of one font in a document share a name. A certificate set in Inter used it for bold and for bold italic, so it carried two different Inter-Bold subsets under one name; a processor that looks fonts up by name (Ghostscript, preflight, merging) can draw one subset's text from the other and lose glyphs. Tools also took the subset for the whole font: pdffonts listed it with sub "no". The tag is taken from a hash of the subset's bytes, so different subsets get different tags and the same subset always gets the same one — the output stays reproducible. Fonts embedded whole (subset: false) and CFF fonts, which are never subset, keep the plain name. The PostScript name was also written into the PDF name unescaped. The OpenType spec keeps delimiters, '#' and non-printable bytes out of it, but a font that broke the rule produced a broken font dictionary; those characters are written as #xx now (§7.3.5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the subset tag in /FontName, veraPDF treats the font as a subset and PDF/A-1 requires a CIDSet for it (ISO 19005-1 §6.3.5, rule 6.3.5-3), so pdfa-1b and pdfa-1a stopped validating. The subsetter keeps the glyph numbering and leaves unused glyphs empty, so every GID below numGlyphs is present in the font program, and the CIDSet sets all of them. PDF/A-2 and 3 accept a CIDSet only when it lists every glyph present (§6.2.11.4.2): one of only the used glyphs fails veraPDF there. It is written for every subset, whatever the conformance level: the font does not know it, and the stream is a few hundred bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This carries the commit of #48 by @serpentblade unchanged, authorship kept, and adds two follow-up commits from the review. Thank you — naming subsets as ISO 32000 asks, deterministically from their bytes, is the right fix, and the name escaping closes a gap we had in the CFF path as well.
The follow-up, and why it is needed:
/CIDSetfor TrueType subsets. Once subsets carry theABCDEF+tag, veraPDF recognises them as subsets and applies ISO 19005-1 §6.3.5: a CIDFont subset must have a/CIDSet. The library wrote none, sopdfa-1bandpdfa-1aof the conformance set started failing rule 6.3.5-3 (they pass on main only because the subsets were untagged). CI did not run on the fork's pull request, so this could not show up there.The set marks every glyph below
numGlyphs: our subsetter keeps glyph numbering and leaves unused glyphs empty, and veraPDF counts each of them as present. A narrower set (used glyphs, glyph 0, composite components) fails PDF/A-2 and 3 on rule 6.2.11.4.2-2, which requires the set to be complete. It is written for every TrueType subset —PdfFontdoes not know the conformance level, and PDF/A-2/3 accept a complete set; for Liberation Sans that is ~330 bytes before compression. Fonts embedded whole and CFF fonts get none.[Unreleased]→ Fixed: subset tags (with the visible name change/BaseFont /LiberationSans→/ABCDEF+LiberationSans), escaped names, CIDSet.Tests: the CIDSet stream exists, its length is
ceil(numGlyphs/8)and every bit matches, on a text with a composite glyph (é); no CIDSet for whole fonts and CFF. Full suite 2608 OK (14 skipped), PHPStan clean, veraPDF 1.30 passes all nine PDF/A documents of the conformance set, including 1b and 1a.Closes #48.
🤖 Generated with Claude Code