fix diameter symbol missing [PDFBOX-5960] - #523
Closed
valerybokov wants to merge 1 commit into
Closed
Conversation
Contributor
|
Thank you, this looks good. I'll do that change in two steps, first refactoring that big code chunk into the new |
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Sep 5, 2026
…ding dictionary has a recognized /BaseEncoding, resolve by glyph name first, falling back to the existing code-based cmap logic only if that yields GID 0, by Valery Bokov; closes #523 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/3.0@1937909 13f79535-47bb-0310-9956-ffa450edef68
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Sep 5, 2026
…ding dictionary has a recognized /BaseEncoding, resolve by glyph name first, falling back to the existing code-based cmap logic only if that yields GID 0, by Valery Bokov; closes #523 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/2.0@1937910 13f79535-47bb-0310-9956-ffa450edef68
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.
The bug: PDFBOX-5960 (https://issues.apache.org/jira/browse/PDFBOX-5960) is a regression (2.0.33+/3.0.4, worked in 1.8.16) where a diameter symbol fails to render. The attached font (ASCON HPDFAA+Symbol_A, from a "KOMPAS" export) has a malformed FontDescriptor where both the Symbolic (4) and NonSymbolic (32) flag bits are set — contradictory. It also has an /Encoding dictionary with /BaseEncoding /StandardEncoding and a /Differences array mapping code 71 > /Ccedilla.
PDTrueTypeFont.isSymbolic() trusted the raw Symbolic bit and took the "symbolic" code path, looking up glyph 71 directly through the font's (3,0) cmap — landing on GID 34 (post name "G", visually wrong). The correct glyph (the diameter symbol) is GID 90, reachable only by resolving the /Differences name "Ccedilla" through the post table, the way a non-symbolic font would.
The fix (pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java): in codeToGID(), when the descriptor has contradictory flags and the Encoding dictionary has a recognized /BaseEncoding, resolve by glyph name first, falling back to the existing code-based cmap logic only if that yields GID 0. Ordinary symbolic fonts (the common case) are untouched.
Test: #522
Per https://www.apache.org/legal/generative-tooling.html: portions of this PR were
produced with assistance from Claude Code (Anthropic), based on a bug was described in Apache PDFBOX Issue Tracker.
I've reviewed the generated code and confirm to the best of my knowledge that the output does not include any
third-party copyrighted material and is compatible with the Apache License 2.0.