Repository navigation
fix(render): clip extracted text to the page CropBox (#2670) - #2838
Open
jonathanwxh-cell wants to merge 2 commits into
Open
jonathanwxh-cell wants to merge 2 commits into
jonathanwxh-cell wants to merge 2 commits into
Conversation
The open worker can still be reading after the harness's four startup frames. Removing the synthetic file then asserted zero tabs before opening completed. A fixture-specific 300 ms delay reproduced the exact ui.rs:843 failure on 644f7ab; waiting by state passes under the same delay. Keep the file until its tab opens, retaining the one-tab, filename and OS-quit assertions. The diagnostic delay is removed. CropBox production code is unchanged. Narrowly adapted from Guillem Hermida's OS-event test repair in upstream storytold#2812 at 47e5398 (MIT OR Apache-2.0). No other changes from that PR are included. Validation: controlled red/green; final UI suite 52 passed, zero ignored; CropBox render regression passed with its fully qualified exact test name; strict UI Clippy all targets, formatting, layers, assets and wasm (31 crates). The CLI CropBox acceptance test will also be verified in automatic exact-head CI. Co-authored-by: Guillem Hermida <guillemhr2@gmail.com>
This branch has not been deployed
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.
What this changes
Part of #2670 (item 5: Text outside the CropBox).
When a page's
CropBoxis smaller than itsMediaBox,hayro::render_intoclips visual rendering topage.intersected_crop_box()transformed bypage.initial_transform(true), butTextDevicerecorded every glyph drawn anywhere on the page without checking whether its view-space bounding box intersected the visible crop region. As a result,pdfcraft-cli text,text_extract,text_search, and the UI text layer extracted and matched hidden text outside theCropBox.initial.transform_rect_bbox(intersected_crop_box)) onTextDeviceinextract_page_filtered.TextDevice::draw_glyph, skip glyphs whose view-space bounding box has no positive overlap withself.page(b.x0.max(self.page.x0) >= b.x1.min(self.page.x1) || b.y0.max(self.page.y0) >= b.y1.min(self.page.y1)), while keeping glyphs that lie inside or straddle theCropBoxboundary.How you verified it
cargo fmt --all -- --checkcargo clippy -p pdfcraft-render -p pdfcraft-cli --all-targets -- -D warningscargo test -p pdfcraft-render --lib text::cargo test -p pdfcraft-cli --test textcargo xtask layerscargo xtask assetstext::tests::text_outside_the_crop_box_is_clippedincrates/render/src/text.rscovering text and/ActualTextinside vs outside all fourCropBoxedges, glyphs straddling theCropBoxedge, rotations (0,90,180,270),/UserUnit(1,2), and zero-area/disjointCropBoxes.page_argument_tests::text_clips_glyphs_outside_the_crop_boxinapps/pdfcraft-cli/tests/text.rs.Never-crash
unwrap()/expect()/panic!()/todo!()/unimplemented!()/unreachable!()added in library code.Provenance
CropBoxclipping in ISO 32000-2 §7.7.3.3 / §14.11.2) and synthetic test fixtures.