Skip to content

PDFBOX-6251 usecmap cidrange precedence - #515

Open
pcorless wants to merge 3 commits into
apache:trunkfrom
pcorless:PDFBOX-6251-usecmap-cidrange-precedence
Open

PDFBOX-6251 usecmap cidrange precedence#515
pcorless wants to merge 3 commits into
apache:trunkfrom
pcorless:PDFBOX-6251-usecmap-cidrange-precedence

Conversation

@pcorless

@pcorless pcorless commented Sep 1, 2026

Copy link
Copy Markdown

PDFBOX-6251: a CMap's own cid mappings lose to the ones it inherits via usecmap

Setup cmap to preserve inherited cmap values.

@pcorless pcorless changed the title Pdfbox 6251 usecmap cidrange precedence PDFBOX-6251 usecmap cidrange precedence Sep 1, 2026
pcorless and others added 3 commits September 4, 2026 21:33
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
pcorless force-pushed the PDFBOX-6251-usecmap-cidrange-precedence branch from f9ead3a to cd53a45 Compare September 5, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant