Repository navigation
fix(render): emit clip-only text (7 Tr) to devices for text extraction (#3109) - #3116
jonathanwxh-cell wants to merge 5 commits into
Conversation
|
Heads-up: #3191 fixes the same issue (#3109) with the same |
FredApps
left a comment
There was a problem hiding this comment.
The code reads correctly on this head: the Clip arm now reports the glyph with a new GlyphDrawMode::Clip (vendor/hayro-interpret/src/interpret/text.rs:129-138), and the renderer paints neither Invisible nor Clip (vendor/hayro/src/renderer.rs:1689). CI is green. Two things need settling before I can approve:
- Same fix as #3191. It reports the same glyph from the same place with the same
GlyphDrawMode::Clip, and it already has seven reviews. Only one of the two should land. Please agree with that author which one is kept, and carry over any test the other one has that this one lacks. - The PR description is stale. It says the fix calls
draw_glyphwithGlyphDrawMode::Invisible, "matching3 Tr". The diff adds a newClipvariant instead, becauseInvisiblewould drop clip-only titles underTextFilter { images: true }. Please update the text to describe what the code does, since that reason is the point of the change.
|
Thanks @FredApps!
All 309 render tests, clippy, fmt, layers, and assets are green. |
Text drawn in clipping mode (
7 Tr,TextRenderingMode::Clip) shapes the clipping path for visual rendering, but was previously omitted from device calls and thus dropped from text extraction, Search, and Redaction. This fix emits glyphs drawn under7 Trto text devices with a dedicatedGlyphDrawMode::Clipvariant (distinct fromGlyphDrawMode::Invisible), ensuring clipping-only text (such as gradient- or image-filled titles) is extracted and searchable while still allowing filtered extraction (TextFilter { images: true }) to preserve clipping-mode titles without retaining invisible OCR layers.Fixes #3109
What this changes
GlyphDrawMode::Clipinhayro-interpret::types.hayro-interpret::interpret::text::show_glyph, callsdevice.draw_glyph(..., &GlyphDrawMode::Clip)underTextRenderingMode::Clipafterclip_glyph.hayro::renderer, ignoresGlyphDrawMode::ClipalongsideGlyphDrawMode::Invisibleso visual rendering does not paint clip-only text directly.crates/render/src/text.rsfor7 Trtext extraction across search andTextFilterfiltering, plus visual raster clipping assertions incrates/render/src/raster.rs.How you verified it
cargo fmt --all -- --checkcargo clippy -p pdfcraft-render -j 2 --all-targets -- -D warningscargo test -p pdfcraft-render -j 2(309 passed)cargo xtask layerscargo xtask assetsNever-crash
unwrap/expect/panic!/unreachable!/todo!outside testsunsafecrates/renderSummary by CodeRabbit