Repository navigation
Look up symbolic TrueType codes in code-keyed cmap subtables - #559
Merged
Merged
Conversation
A simple-font code without a /Differences entry was resolved only by Unicode, and the Unicode charmap ignores the (3,0) Symbol and (1,0) Macintosh Roman subtables. A symbolic TrueType subset whose only cmap is one of those resolved no glyphs, so its text was drawn with a fallback face instead of the embedded program. Add FontFace::glyph_for_code, which TrueType faces answer from the (3,0) subtable, directly and at 0xF000 + code, and then from the (1,0) subtable. Without an explicit selector, symbolic faces try the code before Unicode and other faces after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
A simple-font code without a
/Differencesentry was resolved only by Unicode, through skrifa's charmap, which selects Unicode subtables only and ignores the (3,0) Symbol and (1,0) Macintosh Roman subtables. A symbolic TrueType subset (descriptor flag 3, no/Encoding) whose only cmap is (1,0) therefore resolved no glyphs, and every character was drawn with a fallback face instead of the embedded program.PDF 32000 §9.6.6.4 maps a symbolic TrueType font's codes through its (3,0) or (1,0) subtable directly. This change:
FontFace::glyph_for_code(u8)(defaultNone, so Type 1, CFF, Type 3 and Type 0 faces are unaffected);0xF000 | code, then (1,0) with the code; glyph 0 counts as a miss;select_glyph, without an explicit selector, tries the code before Unicode for symbolic faces and after Unicode for other faces. Explicit glyph IDs, names and CIDs are unchanged.Test plan
mainand on this branch: identical document and page statuses, and no change in any page's mismatch metriccargo fmt --check,cargo clippy --all --workspacecargo test -p pdf-font -p pdf-text-engine -p pdf-canvas -p pdf-renderer🤖 Generated with Claude Code