Repository navigation
fix(font): name subset fonts with a tag, escape font names - #48
Closed
serpentblade wants to merge 1 commit into
Closed
serpentblade wants to merge 1 commit into
serpentblade wants to merge 1 commit into
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>
dskripchenko
added a commit
that referenced
this pull request
Oct 27, 2026
Subset font tags and escaped names (from #48), with CIDSet for PDF/A-1
Owner
|
Thank you, @serpentblade — subset tags as ISO 32000 asks, deterministic from the subset's bytes, plus proper name escaping: exactly right. Your commit is merged unchanged, with your authorship, through #50. We meant to push the follow-up straight into this branch, but GitHub refused it for a fork owned by an organisation, so we carried it over to a branch here. What we added, and why:
A small request for next time: please open pull requests from a fork under your personal account with "Allow edits by maintainers" ticked. GitHub honours that setting for personal forks, and we can then push small fixes straight into your branch. Thanks again! |
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.
Embedded TrueType subsets were named after the whole font (
/BaseFont /Inter-Bold). ISO 32000-1 §9.6.4 requires a subset's/BaseFontand/FontNameto start with a six-letter tag, e.g.DCFUHW+Inter-Bold. Without it, two subsets of one font in a document share a name, and tools that look fonts up by name (Ghostscript, preflight, merging) can mix them up.Tests added; full suite and phpstan pass. Checked with
pdffontsandqpdf --check.🤖 Generated with Claude Code