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
{{ message }}
Repository navigation
Address the remaining font-stack review findings - #262
Addresses cross-cutting review findings across the font audit, embedding, normalization, and compression stack. Hardens producer encoding preservation, fail-closed auditing, TTC bounds checking, and strict round-trip assertions so text and layout never silently degrade.
Changed:
Preserve producer encodings/flags, harden TTC directory bounds checking, and fail closed on unopenable pages in PdfFontAuditor, PdfFontEmbedder, and FontNormalizer.
Synchronize native font/PDF-X guards in jpdfium_advanced.cpp, jpdfium_pdfx.cpp, and jpdfium_qpdf.cpp.
Strengthen strict render, width, and text assertions in PdfCompressorTest, PdfFontEmbedderRoundTripTest, PdfFontEmbedderTest, and FontNormalizerTest.
Improved font embedding and subsetting reliability, including clearer reporting when a font cannot be safely embedded.
Improved font-width repair while preserving valid existing widths, and strengthened handling of malformed PDF content and pattern settings.
Improved font inventory for unmodified documents when source-file information is available.
Documentation
Clarified font-subsetting and font-width repair behavior.
Tests
Expanded coverage for font subsetting, embedding, text preservation, and width repair.
The change updates PDF font inventory, substitution, embedding, subsetting, and width-normalization paths. It tightens content-stream and font-map handling, adds integration tests for text and rendering preservation, and adjusts tiling-pattern step repair.
Changes: PDF Font Processing
Layer / File(s)
Summary
Inventory and embedding eligibility jpdfium/src/main/java/stirling/software/jpdfium/doc/PdfFontAuditor.java, jpdfium/src/main/java/stirling/software/jpdfium/doc/PdfFontEmbedder.java, native/bridge/src/jpdfium_qpdf.cpp, jpdfium/src/test/java/stirling/software/jpdfium/doc/PdfFontEmbedder*Test.java
Inventory can use the source file for eligible unmodified documents. Embedding records specific substitution blockers, caches font programs per operation, and adds checks for encodings and font coverage. Tests cover scan limits, Type 1 fonts, malformed collections, symbolic fonts, and text round trips.
Font subsetting and retained glyphs native/bridge/src/jpdfium_qpdf.cpp, native/bridge/src/jpdfium_advanced.cpp, jpdfium/src/main/java/stirling/software/jpdfium/doc/CompressOptions.java, jpdfium/src/test/java/stirling/software/jpdfium/doc/PdfCompressorTest.java, jpdfium/src/test/java/stirling/software/jpdfium/fonts/FontNormalizerTest.java
Subsetting verifies glyph mappings and advances, and derives CIDSet entries from retained glyphs. CFF conversion is restricted to eligible simple fonts. Tests cover compression subsetting and CIDSet output.
Content scanning and width repair native/bridge/src/jpdfium_advanced.cpp, native/bridge/src/jpdfium_qpdf.cpp, jpdfium/src/main/java/stirling/software/jpdfium/fonts/FontNormalizer.java, jpdfium/src/test/java/stirling/software/jpdfium/fonts/FontNormalizerTest.java
The native lexer uses PDF-defined whitespace and validates inline-image boundaries. Width repair applies scan-completeness and preservation rules. Tests cover producer widths, multiple pages, and unresolved-width fixtures.
Stirling-Tools/JPDFium#243: Adds the font inventory and missing-font input path that this change updates.
Change: Bug fix
Merge Risk: Moderate · previous review 1d4c0
The new tiling-pattern step clamp does not run for stream-based patterns, so invalid step values can survive PDF/X repair. Negative widths on zero-advance glyphs can also remain after width repair. The round-trip tests can skip silently on a classpath fault, which weakens confidence in the font changes. Fix the pattern clamp and the width condition before merging.
Pre-merge checks: 3 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Description check
The description supplies a summary of changes and checks the template boxes. It omits the template's Closes #(issue) reference, the CHANGELOG entry (left unchecked), and the ABI/header note (left unch…
Add a 'Closes #' reference or state that no issue applies. Either add the CHANGELOG.md entry under '## [Unreleased]' or explain why it is not needed. Confirm that no ABI change exists, and note that 'native/bridge/include/jpdfium.h' was not…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title "Address the remaining font-stack review findings" is specific to the font-handling changes in this PR, which cover font embedding, width repair, CIDSet, and encoding handling. It does not n…
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 "Address the remaining font-stack review findings" is specific to the font-handling changes in this PR, which cover font embedding, width repair, CIDSet, and encoding handling. It does not name the single most important change, and "review findings" is somewhat generic, but it refers to the real scope of the changeset.
Full details: Description check
Explanation
The description supplies a summary of changes and checks the template boxes. It omits the template's Closes #(issue) reference, the CHANGELOG entry (left unchecked), and the ABI/header note (left unchecked, though the change set does not appear to alter exported declarations). The Testing item was changed from './gradlew test' to ':jpdfium:integrationTest' without a stated reason.
Resolution
Add a 'Closes #' reference or state that no issue applies. Either add the CHANGELOG.md entry under '## [Unreleased]' or explain why it is not needed. Confirm that no ABI change exists, and note that 'native/bridge/include/jpdfium.h' was not updated for that reason. State whether './gradlew test' was run, or explain why only the integration test applies.
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.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Major · Clamp the stream dictionary. · jpdfium_pdfx.cpp:248
native/bridge/src/jpdfium_pdfx.cpp:248 Major · Stability & Availability · Quick win
Clamp the stream dictionary.
Tiling patterns are stream objects. QPDF reports streams and dictionaries as distinct types, so this guard returns before the new clamp runs. (raw.githubusercontent.com) An invalid /XStep or /YStep therefore remains in the output.
Use pattern.getDict() for streams. Add a regression that reopens a PDF/X output and checks both step values.
As per coding guidelines, “Every defect fix needs a focused regression with an observable expected result.”
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
Additional context used
Code guidelines: 1
.github/CODERABBIT_REVIEW.md — configured
Path-based instructions: 4
Apply the native ownership, C ABI, C++23, engine integration, memory, and SIMD rules from .github/CODERABBIT_REVIEW.md.
Learnt from: CR
Repo: Stirling-Tools/JPDFium PR: 0
File: .github/CODERABBIT_REVIEW.md:0-0
Timestamp: 2026-10-20T15:53:18.441Z
Learning: Source excerpt:
# JPDFium review standards
## Tests, profiling, and delivery
- Every defect fix needs a focused regression with an observable expected result. No `assertTrue(true)`, swallowed failures, or tests that silently pass when fixtures/tools/source roots are missing.
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
Addresses cross-cutting review findings across the font audit, embedding, normalization, and compression stack. Hardens producer encoding preservation, fail-closed auditing, TTC bounds checking, and strict round-trip assertions so text and layout never silently degrade.
Changed:
PdfFontAuditor,PdfFontEmbedder, andFontNormalizer.jpdfium_advanced.cpp,jpdfium_pdfx.cpp, andjpdfium_qpdf.cpp.PdfCompressorTest,PdfFontEmbedderRoundTripTest,PdfFontEmbedderTest, andFontNormalizerTest.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