You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improved font handling in PDFs with custom character mappings, helping preserve the correct appearance of text when fonts are embedded.
Improved recognition of a wider range of glyph names, including accented characters, Greek letters, and symbols.
When specific font directories are provided, font lookup now respects those directories instead of including bundled font resources.
The change adds Adobe glyph-name lookup and parses PDF ToUnicode mappings. CID font embedding uses those mappings to check supplied glyph order and build CID-to-GID mappings for eligible TrueType fonts. Explicit-directory font indexes exclude bundled-resource faces.
A generated Adobe glyph-name table supports glyphForName alongside single-character and validated hexadecimal name forms.
ToUnicode parsing and glyph-order checks native/bridge/src/jpdfium_qpdf.cpp
New helpers decode valid UTF-16 surrogate pairs, parse bfchar and bfrange mappings, and check whether mapped Unicode characters have glyph IDs matching their CIDs.
CID font validation and remapping native/bridge/src/jpdfium_qpdf.cpp, jpdfium/src/test/java/stirling/software/jpdfium/doc/PdfFontEmbedderTest.java
For eligible CID fonts without an embedded program, processing uses parsed mappings to check glyph order. TrueType fonts can be remapped and receive a CID-to-GID map stream. Related CID replacement tests were removed.
Explicit-directory font selection
Layer / File(s)
Summary
Filter bundled faces from explicit-directory lookups jpdfium/src/main/java/stirling/software/jpdfium/doc/PdfFontEmbedder.java
Both in-memory and file-backed font resolution use an index that excludes bundled-resource faces when directories are explicit.
Change: Feature
Merge Risk: Moderate · previous review 7a104
Font substitution can install a program with wrong or missing glyph mappings for some CID fonts (non-Identity encodings, partial glyph coverage, inherited CMaps), and explicit embedding no longer generates ToUnicode mappings for unembedded Identity TrueType fonts. Glyph-name resolution is also incomplete for legacy and suffixed names. These are bounded to specific font shapes, but they should be fixed or accepted before merge, and the removed CID tests should be restored.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: adding Adobe Glyph List resolution helpers. The changeset adds an AGL lookup table and glyph-name lookup helpers in jpdfium_qpdf.cpp, so the title matches the primary …
Description check
The description follows the template's main sections: a 'Description of Changes' section explains the purpose and lists the changes, and the checklist is included. It explains what changed and why. Ga…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: adding Adobe Glyph List resolution helpers. The changeset adds an AGL lookup table and glyph-name lookup helpers in jpdfium_qpdf.cpp, so the title matches the primary change. It is short and specific.
Full details: Description check
Explanation
The description follows the template's main sections: a 'Description of Changes' section explains the purpose and lists the changes, and the checklist is included. It explains what changed and why. Gaps: the template's HTML comment asks for an issue reference ('Closes #(issue number)'), and none is given. Several checklist items are unchecked and the testing item is unclear. The author checks 'Ran ./gradlew :jpdfium:integrationTest' but the raw summary shows PdfFontEmbedderTest tests were removed and no tests were added, so the 'Added or updated tests' item stays unchecked. The changelog item is also unchecked. The description says the integration test passes, but the test-removal diff is not explained. The description does not mention the removed tests or the behaviour change in PdfFontEmbedder.
Resolution
Consider the following improvements. Add the issue reference (for example, 'Closes #256' if applicable). Explain why the tests in PdfFontEmbedderTest were removed and whether equivalent coverage exists. Describe the behaviour change to explicit font directory filtering in PdfFontEmbedder. Complete or explain unchecked items, including the CHANGELOG.md entry and the Javadoc status for public types.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between b0bc328 and 346ab96.
Files ignored due to path filters: 1
jpdfium/src/main/resources/fonts/NotoSansSC-Regular.otf.xz is excluded by !**/*.xz
Files selected for processing: 2
native/bridge/src/adobe_glyph_names.inc
native/bridge/src/jpdfium_qpdf.cpp
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Review details
Context from checks skipped due to timeout: 46
GitHub Check: Version bump script regression tests
GitHub Check: Markdown lint
GitHub Check: Gradle wrapper validation
GitHub Check: Shellcheck (scripts + native/*.sh)
GitHub Check: Javadoc builds cleanly
GitHub Check: prep-windows-icu
GitHub Check: Native jar checker regression tests
GitHub Check: Corpus (generate + native)
GitHub Check: Samples E2E (88 features via RunAllSamples)
GitHub Check: FFM layout vs pinned PDFium headers
GitHub Check: Public API compatibility (japicmp vs last release)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Review details
Context from checks skipped due to timeout: 32
GitHub Check: CodeRabbit
GitHub Check: Corpus (generate + native)
GitHub Check: Samples E2E Suite (All 88 Feature Samples)
The filter is an intentional behavior change, not a defect. The commit title, the removeIf line, and the empty-directory test all describe explicit directories as isolated from bundled fallback. The inspected PDF/X documentation names only system font directories. The review comment asks whether losing the fallback is acceptable. That is a design question for maintainers, and it does not establish a concrete failure or a violated repository requirement. The comment's conditional premise that PDF/X must keep the fallback is unsubstantiated by the inspected sources. No change instruction should follow from this comment.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Reject or resolve inherited ToUnicode mappings before remapping.
A ToUnicode CMap can inherit mappings through UseCMap. This parser reads only the local stream. (opensource.adobe.com)
For example, let the inherited mapping contain CID 2 → B and the local mapping contain CID 1 → A. If A resolves to GID 36, cidRemap becomes true. The generated /CIDToGIDMap contains only CID 1, so CID 2 loses its glyph selection.
Resolve the inherited mappings with cycle detection, or reject substitution when inheritance is present. Add a regression that checks both glyphs after reopening.
For 1 beginbfchar\n% mapping\n<0001> <0041>\nendbfchar, this scanner stops at %. hexAt then fails, and embedMissing leaves the font unresolved. Removing the comment makes the same mapping succeed.
Skip comments during tokenization and section discovery. Add regressions for comments in bfchar and bfrange blocks.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Preserve ToUnicode generation for explicit embedding.
PdfFontEmbedder.embed passes onlyMissing=false. Consequently, cidUnicode remains empty, and this loop never populates codes. (raw.githubusercontent.com)
For an unembedded Identity-H TrueType font without /ToUnicode, the immediate-base implementation generated mappings from unicodeByGlyph. This change installs the program without generating those mappings. Text using CID 36 for A therefore loses the generated CID-to-Unicode association. (raw.githubusercontent.com)
Keep the inverse-glyph mapping path for explicit embedding when /ToUnicode is absent. Add a regression that embeds the original program and checks extraction after reopening.
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
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.
Description of Changes
Adds Adobe Glyph List (AGL) glyph-name resolution helpers to map single-scalar,
uniXXXX, uppercase-onlyuXXXX,.suffixvariants, and underscore-separated ligature names to Unicode. Reliable glyph-name decoding prevents broken text extraction and invalid/ToUnicodemappings when installing substitute fonts or repairing simple encodings.Changed:
native/bridge/src/adobe_glyph_names.incand wire lookup helpers injpdfium_qpdf.cpp.uniXXXX, uppercase-onlyuXXXX,f_icomponent splitting, and.altsuffix stripping while rejecting ambiguous lowercase names such asuface.Checklist
General
## [Unreleased]inCHANGELOG.mdLibrary changes
.github/workflows/compatibility.ymlexcludes the break with a reasondocs/installation.md, and the POMsNative or FFM changes
bash native/build-real.sh)./gradlew :jpdfium:integrationTestnative/bridge/include/jpdfium.hand the ABI notes for any ABI changeTesting
./gradlew :jpdfium:integrationTestpasses