PDFBOX-6251 usecmap cidrange precedence - #515
Open
pcorless wants to merge 3 commits into
Open
Conversation
A CMap that starts with usecmap may redefine any code it inherits, but useCmap merged the used CMap's cidchar/cidrange mappings into the same collections as the importing CMap's own. usecmap is read from the header, so the used CMap's mappings landed there first, and since toCID scans the range list first-match, an inherited range beat the mapping the CMap declared for the same code. ETenms-B5-H exists only to do such an override: it uses ETen-B5-H and remaps 0x20-0x7E to the proportional latin CIDs 1-95, yet toCID(0x41, 1) answered 13681, the fullwidth form, instead of 34. 31 of the 92 bundled predefined CMaps declare mappings on top of a usecmap and all 31 were affected; 29 of them are the -V variants, whose own mappings select the vertical glyph forms. Keep the used CMap as a reference instead of copying its cid mappings, and ask it only for codes this CMap does not map itself. Precedence then follows the usecmap chain nearest-first at every level, so it also holds for nesting deeper than two levels and for a CMap carrying more than one usecmap. hasCIDMappings has to take the used CMaps into account, Identity-V declaring no cid mappings of its own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014khhepY6XDZVnwu9by9rMo
pcorless
force-pushed
the
PDFBOX-6251-usecmap-cidrange-precedence
branch
from
September 5, 2026 04:34
f9ead3a to
cd53a45
Compare
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.
PDFBOX-6251: a CMap's own cid mappings lose to the ones it inherits via usecmap
Setup cmap to preserve inherited cmap values.