Commit Graph
6530 Commits
Author SHA1 Message Date
FredApps a49949388b fix(test): allow the unused mut on Windows in the private test folders (#7595)
#5923 made the pptx LibreOffice test and the staging tests build their
folders with a DirBuilder that only Unix sets a mode on. On Windows the
binding is never changed, so -D warnings stops the build with unused_mut
and main's Windows gate is red.
2026-11-17 05:52:32 +01:00
Dylan M. Taylor 9892160ed6 fix(platform): confine staging names; private temp dirs for tests and macOS signing (#5923) 2026-11-16 21:59:18 -05:00
Dylan M. Taylor f8197e29ca fix(fonts): a CMap's codespace ranges are at most four bytes and listed once (#6075) 2026-11-16 21:59:15 -05:00
Dylan M. Taylor 0bb5fcca94 fix(fonts): the licence policy reads name-table records one at a time within a total allowance (#7044) 2026-11-16 21:59:11 -05:00
Dylan M. Taylor b3f6d485ba docs: prefer shared craft-libs implementations (#7527) 2026-11-16 21:59:06 -05:00
Dylan M. Taylor 35a1d33857 sign: use shared CMS SignedData signing writer (#7584) 2026-11-16 21:59:03 -05:00
FredApps efd265563e Merge pull request #7330 from MMexicann/patch-8
docs(prc-render): name the current craft-prc parser dependency
2026-11-16 17:20:43 +01:00
FredApps 412e6963b5 Merge pull request #7529 from storytold/onee/778-pdf-content-facade
refactor(content): re-export craft_pdf::cos::content
2026-11-16 14:54:16 +01:00
FredApps 3d43364928 fix(crypt): write RC4 fixtures through the legacy entry points
Pinning craft-pdf to the #1852 merge SHA also picked up d74e60b2, which
makes create() and set_encryption() refuse RC4-40 and RC4-128. Tests,
helpers and the protect example that still write those schemes now use
create_legacy and set_encryption_legacy. Edit::Protect does the same
when the chosen algorithm is legacy, so a file that must stay readable
by a reader without AES can still be written.
2026-11-16 14:11:36 +01:00
FredApps 99ef606491 refactor(content): point the facade at craft-pdf #1852
Pin craft-pdf to 8e03cd016d42032b867fef6bad86bc69bf2c1920 and re-export
craft_pdf::cos::content. Other craft-libs pins stay on e2dc681a3.
2026-11-16 13:42:15 +01:00
FredApps f9aca964b1 refactor(content): re-export craft_pdf::cos::content
The parser, serializer and matrices now live in craft-pdf (craft-libs#1852,
pin 8e03cd016d42032b867fef6bad86bc69bf2c1920). pdfcraft-content becomes a
facade, like pdfcraft-cos. The unit tests moved with the implementation;
hayro_sign_tokens stays here. Other craft-libs pins are unchanged.
2026-11-16 13:42:01 +01:00
FredApps 207a50ef13 Merge pull request #7344 from MMexicann/patch-20
test(create): fail explicitly for invalid one-bit RGB fixtures
2026-11-16 12:33:12 +01:00
FredApps 9d061a7668 Merge pull request #3762 from AdrianTM/feat/comments-panel-shortcut
Ctrl+M opens the Comments panel (#3741)
2026-11-16 11:51:05 +01:00
Adrian f8d8aef6e4 M5: preserve macOS Minimize alongside Ctrl+M Comments (#3741) 2026-11-16 04:28:05 -05:00
Adrian 2ace804522 M5: test Ctrl+M as Windows and Linux send it (#3741)
Real Ctrl events carry both ctrl and command, so a Cmd+Ctrl+M binding,
which the registry tries first, would also match them. The test now
sends that shape on Windows instead of the command modifier alone.
2026-11-16 04:27:47 -05:00
Adrian fdf9350045 Ctrl+M opens the Comments panel (#3741)
Bind comment.list to Ctrl+M (Cmd+M on macOS). The command opens the
panel rather than toggling it, so pressing it with the panel already
open keeps it open. The binding comes from the command registry, so the
View menu, the palette and Help > Keyboard shortcuts show it.
2026-11-16 04:27:47 -05:00
FredApps 75a6ce50c3 Merge pull request #7377 from gmrmad1/docs/roadmap-2026-11-15
docs: bring ROADMAP.md and parity assessment current through 2026-11-15
2026-11-16 10:23:45 +01:00
Francesco UrbaniandFredApps 90d847ce17 Select the current query when refocusing search fields (#4533)
* Search field receives a focus request

* Find keeps an IME composition when the find field already has the keyboard

Selecting the query on Find made the next IME update replace the whole
query when the field was composing: egui replaces the selected range,
and only egui can end a composition from inside the field. The query is
now selected only when the field takes the keyboard from elsewhere, in
one helper for the find bar and the Search panel.

* Test that the Search panel keeps an IME composition when asked for the keyboard again

* A repeated Find selects the query while the field has the keyboard

`owns_ime_events` is only `has_focus` on the pinned egui, so a second Find
while the find field (or the Search panel field) still had the keyboard
kept the caret and typing appended to the old query. Follow the IME
composition from the field's own events and cursor instead: a non-empty
pre-edit starts it, a commit or empty pre-edit ends it, and any other edit,
click or loss of focus ends it too. Only a live composition keeps the
selection; every other Find selects all of the query.

Tests: a repeated Find with the keyboard still in the field, for both
fields, and a Find after a committed composition.

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-16 10:00:37 +01:00
NineandClaude Opus 5.5 799fdd14b9 bs: Bosnian language support (#5445)
* Add Bosnian (bs) to the interface languages

bs.tsv: Bosnian (Latin script, Ijekavian) catalog covering every key of
PdfCraft's other catalogs, its wording shared with storytold/craft-i18n
locales/bs/ and the strings craft-i18n lacks translated new. Every bs-*
locale selects it; counts use one/few/other. Locale and plural tests,
localization docs and an attribution entry (AI-assisted, not yet
reviewed by a native speaker).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tayw8nmxoLLmKv13jK93z

* Bosnian: date-format language, English picker name, word-count ellipsis

Preferences > Date format offers exactly the interface languages, so
Bosnian gets its month and day names there; the picker falls back to
"Bosnian" when no face can draw the native name; Word Count keeps the
command label's trailing ellipsis.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tayw8nmxoLLmKv13jK93z

* bs: wording from the craft-i18n catalog review

The Bosnian catalog review (storytold/craft-i18n#72) asked for one word
per concept; this catalog follows: pan is "pomjeranje" (not
"pomicanje"), a spreadsheet is "proračunska tabela", Greek & Cyrillic
reads "Grčko pismo i ćirilica". Placeholders and ellipses are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tayw8nmxoLLmKv13jK93z

* bs: take the catalog from craft-i18n, keep only PdfCraft's code

PdfCraft now reads its translations from storytold/craft-i18n (#6055),
and this PR's Bosnian rows are there (storytold/craft-i18n#141, in the
pinned commit), so crates/ui-egui/src/i18n/bs.tsv goes. What stays is
PdfCraft's part, redone against the new registry: the bs row in
LANGUAGES, "Bosnian" as its English picker name, Bosnian date names,
locale, persistence and one/few/other plural tests (Bosnian follows the
Russian rule in the legacy rule table), and the docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tayw8nmxoLLmKv13jK93z

* docs: Bosnian revision row in the revision history; language totals

The 2026-11-04 Bosnian row had landed in the key-languages table instead
of the revision history; it is now the history's first row. The summary
counts 21 other languages, 35 catalogs plus English, 36 in Preferences,
as LANGUAGES lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tayw8nmxoLLmKv13jK93z

* Docs: list bs as a ui.set / ui.state language value

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-16 08:59:35 +01:00
FredApps 923dd9f593 Merge pull request #7449 from storytold/extract/shared-export-base64
export: replace local Base64 encoder with existing craft-mime
2026-11-16 07:42:08 +01:00
FredApps a0bc1b3477 Revert "xfa: avoid rescanning prototype-only child lists"
This reverts commit 5410dc1c. The XFA prototype-walk optimization is
unrelated to the #778 Base64 cutover; keep it for its own PR with a
measured benchmark (craft-libs#778 consumer PRs stay single-purpose).
2026-11-16 06:53:25 +01:00
FredApps 1c7b507a24 Merge pull request #7475 from storytold/extract/shared-signature-verification
sign: replace local signature verification with existing craft-pkcs7
2026-11-16 06:42:14 +01:00
TheSuperStew e191b0ea69 M3: select text across pages (view.text-select)
Allow a text selection to run across pages, keeping main's same-page table-row selection (head_x) and the JavaScript link click dispatch from #2081.
2026-11-15 22:55:35 +01:00
42c0ba8679 M2: a JPX image on a rotated page draws instead of crashing (#3884) (#5438)
* M2: a JPX image on a rotated page draws instead of crashing (#3884)

The decode-size hint `image_draw_size` hands hayro-jpeg2000 mapped the
image's corners (w, 0) and (0, h) as points, so it took in the
translation. On a /Rotate 90 page (Acrobat Paper Capture scans) one
corner lands on the device origin, the hint gets a side of 0, and
hayro-jpeg2000 0.3.5 divides the image size by it: "renderer crashed on
page N: attempt to divide by zero" on every rotated JPX page.

The hint now comes from the transform's linear part (the axis lengths
the preview tiny-image check already used, now computed once), and each
side is at least 1. As a side effect, translated JPX images no longer get
an overestimated hint, so they can decode at a reduced resolution level
when drawn small, which is what the hint is for.

Regression test: a 1x1 JPX image filling a 40x40 page at /Rotate 0, 90,
180 and 270, rendered at 0.5x, 1x and 1.5x. It fails before the fix
(/Rotate 90 at 0.5x: attempt to divide by zero) and passes after.

Supersedes the guard in #1883 and does not depend on the hayro-jpeg2000
bump in #2309; both are open and conflicting with main.

Fixes #3884

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C19EMwwBCMSkqew7KepPV2

* M2: decode an offset JPX image area at full size (#3884 review)

hayro-jpeg2000 0.3.5 places a reduced resolution's samples using the
image area's reference-grid offset (XOsiz, YOsiz) unscaled. When a size
hint skips a level, an offset image either loses rows (offset 7, 7: no
reduced row is copied) or is sliced past a reduced row and panics
(offset 7, 0: "range start index 3 out of range for slice of length 2"
at decode.rs:486). The accurate hint from the previous commit makes
reduced decoding more common, so this matters more now.

filter::jpx::decode now passes the hint only when both offsets are 0,
read from the SIZ segment of a raw codestream or a JP2 jp2c box;
codestreams without an offset keep reduced decoding.

Tests: jpx_size_hint_is_dropped_only_for_an_offset_image_area fails
before the fix (the panic above, and 2x2 instead of 4x4 for the other
offsets) and passes after; the (0, 0) case pins that reduced decoding
is kept. image_area_offset_reads_raw_codestreams_and_jp2_files covers
raw, JP2 and truncated inputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C19EMwwBCMSkqew7KepPV2

* M2: pin invalid /Rotate values in the rotated JPX test (#3884 review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C19EMwwBCMSkqew7KepPV2

* M2: restore the /UserUnit test's rotations (#3884 review)

7928399 widened the rotation list in the rotated-JPX test with a sed that
also matched the identical loop in user_unit_scales_the_page_and_everything_on_it,
which then failed on /Rotate 45. Only the JPX test was meant to change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C19EMwwBCMSkqew7KepPV2

* M2: decode a colour-keyed JPX image at full size (#3884 review)

A colour-key /Mask (ISO 32000-2 8.9.6.4) is matched against the decoded
samples in resolve_alpha. A JPX image decoded at a reduced resolution for
the size hint has wavelet low-pass averages instead of its samples, so
keyed pixels next to unkeyed ones turned opaque, and unkeyed averages
could fall in the key range. The accurate hint from the first commit
makes reduced decodes more common.

ImageXObject::decoded_raster now drops the hint when a colour key is the
image's mask (no /SMask stream and no /SMaskInData 1, the precedence
resolve_alpha uses), so it is decoded at full size and resampled with its
mask like an image under any other filter. A /SMask keeps the reduced
decode. The decode cache key follows, since it is built from the same
hint.

Test: jpx_with_a_colour_key_mask_is_decoded_at_full_size decodes a 4x4
one-level JPX image with a 2x2 hint: without a mask, with /Mask [0 0],
and with /Mask [0 0] plus /SMask. The /Mask case gave 2x2 before the fix
and gives 4x4 after; the other two stay 2x2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C19EMwwBCMSkqew7KepPV2

* M2: pin a colour-keyed JPX image's transparency as drawn (#3884 review)

The colour-key test checked the size the image was decoded at. This one
checks the page: a 4x2 JPX checkerboard of samples 0 and 1 with
/Mask [0 0], drawn over red at 2x1 pixels, where the size hint skips a
resolution level. Half of each pixel's samples are keyed, so both pixels
come out half red (128, 1, 1).

With the fix in decoded_raster reverted, the reduced decode's averaged
samples no longer match the key and the image covers the red: both
pixels are (1, 1, 1) and the test fails.

The codestream is the one inside the 4x2 JP2 fixture in hayro-syntax's
filter::jpx tests.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-15 22:14:10 +01:00
Dylan M. Taylor 5410dc1cfc xfa: avoid rescanning prototype-only child lists 2026-11-15 14:11:27 -05:00
Dylan M. Taylor a11ea7ad85 Merge pull request #7450 from storytold/refactor/shared-srgb-v2
preflight: use shared ICC v2 sRGB output-intent bytes
2026-11-15 14:02:29 -05:00
Dylan M. Taylor 073644e09c sign: delegate public-key verification to existing craft-pkcs7 2026-11-15 13:03:34 -05:00
Dylan M. Taylor e14ed45a4d Pin ICC v2 generator to merged shared revision 2026-11-15 17:24:08 +00:00
Dylan M. Taylor 17fc47b692 Merge pull request #7447 from storytold/dot/pdf-shared-der
sign: replace local BER/DER codec with existing craft-pkcs7
2026-11-15 12:18:03 -05:00
Michael Higgins 1b86ace58d fix(render): cap a JPEG 2000 codestream's SIZ size at 2^28 pixels (#5086)
## What this changes

A JPEG 2000 image is now refused when its codestream's SIZ marker declares more than 2^28 pixels, the same cap `image_size_ok` applies to `/Width` x `/Height`. The check runs in `vendor/hayro-syntax/src/filter/jpx.rs` on the header read at full resolution, before `Image::decode` (which makes the infallible allocation), and fails the same way as other undecodable images. It uses the full-resolution size because a `target_resolution` shrinks the reported `width()`/`height()` but each tile's coefficient buffers are still allocated at full size (review on this PR); the header is then re-read at the target resolution only when one is set. Logged as hayro-syntax patch (36) in `vendor/README.md` (main has since taken 29-35).

Fixes #5078

## How you verified it

`cargo fmt --check` and `cargo clippy --all-targets -- -D warnings` are clean on `pdfcraft-render` (which compiles the vendored hayro-syntax). Regression tests in `jpx.rs`'s `tests` module, adopted from the reviewers' patches:

- `a_codestream_over_the_pixel_cap_is_refused` (croquete1): a `/Width 1 /Height 1` image whose single-tile codestream declares 65536 x 65536 (2^32 pixels) returns `None` from `jpx::decode`, with and without a 1x1 target resolution (the target case has four decomposition levels, so the target really shrinks the reported size to 4096 x 4096, under the cap); the same builder at 1x1 decodes, so the `None` is the cap, not a parse error.
- `jpx_size_guard_uses_full_resolution_before_target_resolution` (Harrison-Booth): `decode` delegates to `decode_with_pixel_limit`, so a 1024-pixel limit can show that a 64x64 image with four decomposition levels, which a 1x1 target decodes under 1024 pixels, is still refused at that target. The first version used `PALETTE_JP2`, which a target can't shrink (its JP2 palette makes hayro-jpeg2000 drop the target, and it has no decomposition levels), so it passed with the check measuring the target size; the current one was seen failing at that assertion with the header read at the target resolution before the check, and passing with the fix.

The vendored crates are excluded from the workspace, so CI's `cargo test --workspace` doesn't run these unit tests. They were run on a copy of `vendor/hayro-syntax` (with the vendored `hayro-jbig2` patched in): `cargo test --lib filter::jpx`, 12 passed.

- [x] `cargo fmt --check`
- [x] clippy with `-D warnings` on the crates I changed
- [x] tests pass on the crates I changed

## Anything a reviewer should look at first

- `Image::new` only parses the header (croquete1 measured the 65536 x 65536 single-tile case at about 0 ms), so the cap runs before any coefficient buffer is allocated.
- `u64::from(width) * u64::from(height)` can't overflow (two u32 values). Component and tile counts aren't bounded here; that's a separate allocation path, outside #5078.
- `MAX_PIXELS` is a local constant. The shared `MAX_IMAGE_PIXELS` lives in `hayro`, which hayro-syntax can't depend on.
- rustfmt wasn't run over `jpx.rs` (the vendored crate is outside the workspace, and the workspace config would reformat older blocks). The new lines are formatted by hand.
2026-11-15 17:29:08 +01:00
Michael Higgins 10727c520b fix(web): open document links with noopener and send COOP same-origin (#5091)
## What this changes

On the web build, `PdfCraftApp::open_url` now opens links with `window.open(url, "_blank", "noopener,noreferrer")` via `web-sys`, instead of `egui::OpenUrl::new_tab`. eframe opens new tabs without features, which gave the opened page a `window.opener` handle it could use to navigate the PdfCraft tab. Every app-level open goes through `open_url`: document links, button URI actions, `app.launchURL`, help links and the releases page. Desktop builds are unchanged.

The web packaging now sends `Cross-Origin-Opener-Policy: same-origin`: `_headers`, `.htaccess`, and the nginx example in `packaging/web/README.md` (`HOSTING.md`), whose old "doesn't need COOP" note is rewritten.

Fixes #5084

## How you verified it

`cargo fmt --check` and `cargo clippy --all-targets -- -D warnings` are clean on `pdfcraft-ui-egui`, including the review fixes. Tests not run yet; CI runs them. `cargo check -p pdfcraft-ui-egui --target wasm32-unknown-unknown` passes too, with no warnings in `links.rs`.

- [x] `cargo fmt --check`
- [x] clippy with `-D warnings` on the crates I changed
- [ ] tests pass on the crates I changed

## Anything a reviewer should look at first

- COOP `same-origin` has no effect inside an iframe, so the `postMessage` embedding bridge is unaffected. A page on another origin that opens PdfCraft with `window.open` does lose its window handle. Nothing in the repo does that.
- Not covered: `dialogs/credits.rs` uses `ui.hyperlink_to` for fixed GitHub URLs, which on the web may open in the PdfCraft tab itself.
2026-11-15 17:27:37 +01:00
Dylan M. Taylor 5a6ab66a4f deps: declare shared PKCS7 version for dependency policy 2026-11-15 10:12:51 -05:00
Dylan M. Taylor 08d24b3ad8 preflight: constrain shared CMS package version 2026-11-15 10:10:12 -05:00
Dylan M. Taylor 0ca899e830 preflight: follow shared ICC helper lint fix 2026-11-15 09:43:56 -05:00
Dylan M. Taylor acb6408244 preflight: use shared byte-compatible ICC v2 sRGB profile 2026-11-15 09:42:07 -05:00
Brandon Thomas 40b9b1f412 test(preflight): freeze original ICC v2 writer as parity oracle
Original PDFCraft source at e098c5c85, introduced by 4d60af8b1 and renamed in d3db99818. This copy will only be compiled for tests.
2026-11-15 09:41:09 -05:00
Dylan M. Taylor d80d64fb97 Use shared MIME Base64 codec for document exports 2026-11-15 09:38:36 -05:00
Dylan M. Taylor bb158c0ab8 sign: delegate BER and DER encoding to existing craft-pkcs7 2026-11-15 09:35:45 -05:00
Dylan M. Taylor e098c5c85e Merge pull request #7374 from keithcsqueensu/rtf-export-craft-rtf-793
Export: write RTF through craft-rtf (storytold/craft-libs#793)
2026-11-15 09:24:10 -05:00
Dylan M. Taylor fa8c473d23 Clarify scope of RTF mapping complexity test 2026-11-15 13:25:23 +00:00
Dylan M. Taylor 93309e6b1c Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	crates/ui-egui/src/platform/pickers.rs
2026-11-15 12:54:24 +00:00
Dylan M. Taylor fc77f5a749 Merge pull request #7422 from storytold/codex/picker-optimize-completion
Handle fast optimization completion in picker test
2026-11-15 07:53:43 -05:00
Dylan M. Taylor 3f20c6848b Test fast optimize completion after picker 2026-11-15 12:29:26 +00:00
Dylan M. Taylor b7256c81bc test(pickers): avoid racing completed optimization 2026-11-15 07:23:35 -05:00
FredApps 070432ca44 i18n: move the craft-i18n pin to 866aff71 (#7417)
Pick up craft-i18n main, including French menu paths that use ">"
instead of "▸" (#296) and Portuguese (Brazil) byte-unit rows in the
shared catalog (#205).
2026-11-15 12:23:39 +01:00
Dylan M. Taylor e94fa524ca Export: pin merged RTF writer and preserve empty-page breaks
Use the merged craft-libs #1467 commit for craft-rtf and its codepage dependency, leaving other shared pins unchanged. Flush pending breaks before a second break and at end of input so blank and omitted-image pages retain every boundary. Add semantic readback coverage for those cases.
2026-11-15 06:11:34 -05:00
Hector Villarreal aef22858a9 Select a table by rows when a drag crosses its columns (#3669)
## What this changes

Fixes #3850.

Partly addresses #3682: drags within one column of its two-column page now select that column's text (the tester's harness measured 3/9 → 7/9 on `cols.pdf`). Drags from one column into the next still follow reading order, as on `main`; they need column-correct reading order (#3676).

Selecting text in a table selected the wrong things. A table reads column by column, so a plain drag along one row, or down and across a few rows, took the rest of the first column and the top of the next ones between its ends. On some rows the highlight jumped to the column headers and half the table. Copy gave the cells out of order. Preview selects these by rows, and this makes PdfCraft do the same.

Rebased on `main` after the module split (#4889): the row selection is in `crates/render/src/text.rs`, the padded-cell join and barcode rows in `text/order.rs` and `text/layout.rs`, the drag's pointer end in `crates/ui-egui/src/canvas/selection.rs` and `canvas.rs`.

- **Visual rows** (`PageText::visual_between`, used by `Selection::rects` and `Selection::text`). The drag selects by rows when reading order between its ends would not follow them: the rest of the first row, the rows between, and the start of the last. Copy gives the cells tab-separated, as Column select does. Rows are used when either of these holds:
  - Reading order strays above or below the rows dragged over.
  - The drag ends in another column. That means across a gutter that no text of those rows crosses (checked a few lines above and below as well, so a justified line's wide word gap does not count), or with the pointer past the end of both lines.
- **Limits on the rows.** Rows never take lines left of everywhere the drag has been, and they stay in the column when the drag does. A drag in the right column of side-by-side text that ends on a hanging list marker does not pull in the left column. Running text keeps reading order whenever it covers the same glyphs, and so does a column of running text beside a sidebar. A drag down one article or table column keeps reading order too. A line's extent for these limits is its ink: spaces padding it out don't count.
- **Pointer position.** `Span::Run` records where the drag's pointer ended (`head_x`). It can lie well past the nearest glyph, as in the empty end of a table row. Select all, a clicked word, line or page, and four-click page selection keep reading order.
- **Hit testing.** `PageText::nearest` still takes the glyph whose em box holds the point first (#3693). Failing that, it prefers the row level with the pointer, so past the end of a short row a longer row just below no longer captures the drag. Between rows, the old distance rule still applies.
- **Padded cells.** Report generators pad each cell of a row with trailing spaces. When a cell's padding stops short of the next cell (more than the 3-height continuation gap), the next cell on its baseline now joins the row, within 8 line heights (`PADDED_FIELD`, `PADDED_REACH`). Without this, the row's last cells were read after the whole table, in selection, copy and `text_extract` alike.
- **Barcodes drawn with a font** (new since the last review). Mexican CFDI invoices and receipts print their QR or Aztec code with a barcode font: rows of glyphs stacked flush, 5 pt from the seal's text and on nearly the same baselines. Each code row joined the seal line beside it, so the seal read interleaved with the code, some seal lines came after the whole code, and a drag down the seal jumped through it. Rows of at least 8 glyphs, 4 or more stacked flush with one glyph count and the same edges (`barcode_rows`), now join no other text and read after the page's text. A point beside the code is not taken by the code row level with it.

## How you verified it

- [x] `cargo fmt --all --check`
- [x] `cargo clippy --workspace --all-targets --locked -- -D warnings`
- [x] tests pass on the crates I changed, and on the crates that use text extraction:

  | Crate or suite | Passed |
  |---|---|
  | `pdfcraft-render` (lib + integration) | 476 + 64 |
  | `pdfcraft-ui-egui --lib` | 696 |
  | `pdfcraft-ui-egui --test it` (`column_select`, `text_select`, `drag_selects`, `selection_works`) | 33 |
  | `pdfcraft-automation` | 359 |
  | `pdfcraft-engine` | 442 |
  | `pdfcraft-export` | 43 |

- [x] `cargo xtask layers`, `cargo xtask assets`, `cargo check -p pdfcraft-render --target wasm32-unknown-unknown`, `cargo xtask parity`

**Tests.** I reverted each fix and watched these fail:

- `column_select.rs::a_plain_drag_along_one_table_row_selects_only_that_row` (UI, select tool and highlighter). Before the fix it got `"Apple\nPear\nQty\n12"` instead of `"Apple\t12"`.
- `column_select.rs::a_drag_ending_between_the_columns_selects_the_rows` (UI). Without `head_x` it got `"Name\nApple\nPear"`.
- `column_select.rs::a_drag_down_text_beside_a_barcode_selects_only_the_text` (UI). Without the barcode rows it got `"ABCDEFGHIJKL one two three\nFGHIJKLMNOPQ\n…"`.
- `text/tests.rs::a_barcode_drawn_with_a_font_reads_apart_from_the_text_beside_it`
- `text/tests.rs::a_point_beside_a_barcode_takes_the_text_not_the_code_row`
- `text/tests.rs::a_point_level_with_a_row_takes_that_rows_nearest_glyph`
- `text/tests.rs::a_drag_in_the_right_column_takes_nothing_from_the_left`

Also new in `text/tests.rs`: `a_drag_along_one_table_row_selects_that_row`, `a_drag_over_table_rows_selects_those_rows`, `a_drag_that_reading_order_already_covers_keeps_it`, `a_pointer_ending_beside_the_column_takes_the_rows`, `a_cell_padded_with_spaces_joins_the_next_cell_of_its_row`, `a_justified_gap_is_not_a_gutter`, and the running-text, sidebar, heading and vertical-text cases from earlier review rounds. In `column_select.rs`: double-click drags, select all and four-click page selection on uneven columns.

All fixtures are synthetic.

**Corpus.** Before the rebase, text extraction of the pinned pdf.js corpus was byte-identical with and without this PR. The barcode change leaves it identical too: the plain text of the first 60 pages of each of its 989 PDFs (1,525 pages) is the same with and without it.

**Real-world files** (private, not attached):

- **Text extraction:** on a personal folder of PDFs (bank and hotel reports, payslips, policies, contracts, slide decks), the only files that differed from `main` before the rebase were bank statements whose padded rows now keep their amounts. The barcode change alters one page across 105 files: a statement's CFDI page, whose seal now reads in order.
- **Simulated drags:** about 53,700 random drags across those files. Selection takes at most about 145 µs per frame.
- **Two-column contract:** on a bilingual two-column contract, 2,649 drags kept inside one column leak into the other column less often than before (1,224 vs 1,591). In no file does the new code leak a two-column drag where the old one did not, except across table rows, where rows running across the page is intended.

## Never-crash

- [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests
- [x] No indexing with input-derived positions in the new code (`get`). Allocations are bounded by the page's glyphs, and `side_by_side` compares at most `SIDE_BY_SIDE_LINES` lines. Barcode rows are found with one hash map over the page's rows. NaN boxes rank last in `nearest` (`total_cmp`) and are never barcode rows. No recursion.
- [x] No `unsafe`
- [ ] Any crash this fixes has a small synthetic regression test (n/a, no crash)

## Provenance

- [x] No asset from an Adobe product, and no Adobe icon recreated, traced or imitated
- [x] No font files committed here
- [x] No GPL/AGPL code copied in
- [x] Behaviour comes from black-box observation (Preview's selection on the same files), not from reading another implementation's source
- [x] No new assets

## Security

- [x] `--root` confinement untouched
- [x] MCP and the UI control channel untouched
- [x] No new outbound network access

## Parity and reach

- [x] `parity/acrobat-features.toml`: `view.text-select` gains the new evidence and a note. Selection across pages is still missing, as before.
- [x] Reachable headlessly: the padded-cell join and barcode rows change `text_extract` too. Visual-row selection is a pointer interaction, like the rest of plain drag selection.
- [x] `ROADMAP.md` progress log line

## Anything a reviewer should look at first

1. **A deliberate behaviour change.** `alt_drag_selects_only_the_text_inside_the_rectangle` asserted that a plain drag from "Name" to "12" selects in reading order: `"Name\nApple\nPear\nQty\n12"`. It now selects the two rows dragged over, `"Name\tQty\nApple\t12"`, and I changed the assertion. Reading order itself is unchanged (`a_column_selection_takes_one_table_column` still asserts it), and so is a drag down one column.
2. **The gutter test is a heuristic.** "Another column" means a vertical strip at least one line height wide that no text in the dragged rows, or 4 line heights around them, crosses. That catches table columns and side-by-side text, and ignores justified word gaps in practice. Thin columns with ragged edges may still fool it.
3. **The padded-cell join changes reading order.** It applies only to a segment whose box runs on at least 2 line heights of trailing spaces past its last visible glyph, and only towards a cell on the same baseline within 8 line heights.
4. **Barcode rows change reading order.** A stack of 4+ flush rows of 8+ glyphs, each with the same glyph count, height and edges, reads after the page's text. Text set solid still has lines of different lengths and counts; a hex dump set solid in a monospaced font would also match, and would then read last.
5. **Overlap with #2431** (narrow article gutters, #2387). The two PRs touch different code paths and should rebase cleanly.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **New Features**
  * Text drags across table-like layouts now select cells by visual row, with copied cells separated by tabs. Multi-click and Shift-click selections can also follow visual rows where applicable; select-all and other non-row selections retain reading order.
  * Text selection and pointer placement work more accurately around columns, gutters, and barcode-like text, reducing unintended selection of nearby content. Barcode text is kept separate from adjacent text.
* **Documentation**
  * Updated feature coverage and progress notes to reflect text-selection behavior and regression testing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-15 12:11:23 +01:00
Dylan M. Taylor 27287c297d Merge pull request #7378 from storytold/dot/pcx-shared-cutover
Create: decode PCX through craft-image-codecs
2026-11-15 03:53:06 -05:00
Dylan M. Taylor 0a11922520 fix(create): preserve version-four PCX compatibility 2026-11-14 23:59:16 -05:00
Dylan M. Taylor e9f7aeaeee refactor(create): decode PCX through shared image codecs 2026-11-14 23:56:51 -05:00