Skip to content

Wrong bbox in location for vertical font#735

Merged
MaximPlusov merged 2 commits into
integrationfrom
vertical-font-support
Jul 21, 2026
Merged

Wrong bbox in location for vertical font#735
MaximPlusov merged 2 commits into
integrationfrom
vertical-font-support

Conversation

@Vladimir-Burshnev

@Vladimir-Burshnev Vladimir-Burshnev commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Closes: https://trello.com/c/SCBNY4Sg
pdf.js PR: veraPDF/pdf.js#30
veraPDF-parser PR: veraPDF/veraPDF-parser#708

Summary by CodeRabbit

  • Bug Fixes
    • Improved text extraction and positioning for vertically oriented fonts, including correct glyph advance calculations.
    • Enhanced handling of Unicode mappings, missing glyph widths, and text spacing behavior for both horizontal and vertical writing modes.
    • Corrected text bounding-box calculations with orientation-aware geometry for improved layout accuracy.
    • Improved text chunk layout/rotation so extracted color and positioning better match the original document rendering.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

ChunkParser now handles horizontal and vertical text with orientation-aware glyph advances, cursor tracking, and bounding-box calculations. TextPieces and TextChunksHelper were refactored to support separate coordinate ordering and geometry paths.

Changes

Vertical text flow

Layer / File(s) Summary
Orientation-aware text pieces
wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java
TextPieces now tracks orientation-specific coordinates, comparators, cursor state, spacing, and symbol boundaries.
Font-aware text parsing
wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java
Text-show arguments and glyph strings now apply horizontal or PDCIDFont vertical metrics while updating TextPieces.
Orientation-specific chunk geometry
wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextChunksHelper.java, wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java
Bounding-box calculation is split into horizontal and vertical methods, and createTextChunk selects the matching path.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: maximplusov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing bounding boxes for vertical fonts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vertical-font-support

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java`:
- Around line 31-53: Update TextPieceComparatorH and TextPieceComparatorV to add
a monotonic insertion-order tiebreaker after the existing center/end
comparisons, and assign that ordinal before textPieces.add in TextPieces.add.
Ensure distinct TextPiece instances with identical geometry compare nonzero so
every added piece is retained and indexing remains consistent.
- Around line 88-117: Update TextPieces.addSpaces to calculate the gap
direction-aware, handling descending coordinates produced by
TextPieceComparatorV so spaces are inserted when the absolute or appropriately
oriented distance between adjacent pieces exceeds threshold. Preserve the
existing ascending-order behavior and add gaps only when the directional
distance is positive and above the threshold.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 17412848-901d-41c1-828a-cfc8ab1f0b43

📥 Commits

Reviewing files that changed from the base of the PR and between c952d56 and c229226.

📒 Files selected for processing (3)
  • wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java
  • wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextChunksHelper.java
  • wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java

@MaximPlusov
MaximPlusov force-pushed the vertical-font-support branch 2 times, most recently from 8c4262b to 5e05608 Compare July 20, 2026 19:57
@MaximPlusov
MaximPlusov force-pushed the vertical-font-support branch from 5e05608 to 8a6c31c Compare July 20, 2026 21:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java (1)

871-876: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Unconditional SEVERE logging inside a per-glyph loop.

Every glyph with a missing width logs at SEVERE unconditionally, unlike the analogous "no Unicode mapping" branch which is gated behind StaticContainers.isDataLoader(). For a font that's missing many width entries, this can flood logs at the highest severity for every glyph of every string-show operator across a document.

♻️ Suggested fix
 			} else {
-				LOGGER.log(Level.SEVERE, "Missing width of glyph with code " + code + " in font " + font.getName());
+				if (StaticContainers.isDataLoader()) {
+					LOGGER.log(Level.WARNING, "Missing width of glyph with code " + code + " in font " + font.getName());
+				}
 				width = 0.0;
 			}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java`
around lines 871 - 876, Update the missing-width branch in the per-glyph parsing
logic of ChunkParser so its SEVERE log is emitted only when
StaticContainers.isDataLoader() is true, matching the analogous missing-Unicode
handling. Preserve assigning width = 0.0 for all missing-width glyphs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java`:
- Around line 928-946: Guard the descriptor obtained in the TextChunk
construction flow before calling descriptor.getItalicAngle() or
descriptor.getFontFamily(). Use the established default italic-angle behavior
when the descriptor is absent, and only perform the fontNameToFontFamilyMap
update when descriptor is available; retain font-name extraction as the fallback
for empty family values.

---

Nitpick comments:
In
`@wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java`:
- Around line 871-876: Update the missing-width branch in the per-glyph parsing
logic of ChunkParser so its SEVERE log is emitted only when
StaticContainers.isDataLoader() is true, matching the analogous missing-Unicode
handling. Preserve assigning width = 0.0 for all missing-width glyphs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 96bcec96-eb48-4034-b895-07dc5c8aea99

📥 Commits

Reviewing files that changed from the base of the PR and between c229226 and 8a6c31c.

📒 Files selected for processing (3)
  • wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java
  • wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextChunksHelper.java
  • wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java

@MaximPlusov
MaximPlusov merged commit 7cadb12 into integration Jul 21, 2026
8 checks passed
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.

2 participants