mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-19 02:26:48 +00:00
## What this changes XFA templates often draw a vertical divider as a `<line>` with `h` but no `w`, and a horizontal one with `w` but no `h`, while still declaring `slope="/"`. A width-less draw was measured as wide as its row and every line was drawn corner to corner along its slope, so these dividers came out as diagonals running across the form to the page edge. DAF Form 988 shows it on all 3 pages: its 66 vertical separators are all width-less lines. - `layout/measure.rs`: a line draw without a width is as wide as its stroke (clamped to 0.1 to 20pt, as it is drawn) plus its margin, capped at the available width, so a separator sits at its own x. - `layout/draw.rs`: a line without a width is vertical and one without a height is horizontal, whatever its slope says. A line whose box is no wider or no taller than twice its drawn stroke runs along the box's longer side, so a zero-height line is horizontal. Only a box with room for its stroke both ways follows `slope`. - `tests.rs`: `xfa_line_without_width_is_vertical_and_without_height_is_horizontal` covers six shapes: no width, no height, 1pt high, 1pt wide, a 48x72pt box with a 25pt stroke (drawn 20pt, so it still follows its slope) and 2pt by 0pt. It also pins the width-less line's x. ## How you verified it - `cargo test -p pdfcraft-xfa`: 314 passed. The new test fails with either half of the fix reverted. - `cargo test -p pdfcraft-engine xfa`: 86 passed. - `cargo fmt --all -- --check` and `cargo clippy -p pdfcraft-xfa --all-targets -- -D warnings`: clean. - DAF Form 988 laid out with `render_into`: 66 diagonal lines on `main`, none with this change (66 vertical, 68 horizontal). - [x] `cargo fmt --check` - [x] clippy with `-D warnings` on the crates I changed - [x] tests pass on the crates I changed - [ ] `cargo xtask layers` and `cargo xtask assets` (if you touched crate boundaries or any asset) ## Never-crash - [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests, unless it is provably infallible with a comment saying why - [x] No indexing or slicing with input-derived positions (`get`, and strings only at char boundaries); checked or saturating arithmetic; allocations sized by input are capped; recursion is bounded - [x] No `unsafe` - [x] Any crash this fixes has a small synthetic regression test ## Provenance - [x] No asset from an Adobe product, and no Adobe icon recreated, traced or imitated - [x] No font files committed here (they live in [storytold/craft-fonts](https://github.com/storytold/craft-fonts)) - [x] No GPL/AGPL code copied in — MuPDF, Ghostscript, Poppler, veraPDF and DSS may only be run as external oracle processes - [x] Behaviour comes from the specification or black-box observation, **not** from reading another implementation's source - [x] Every new asset has an `ATTRIBUTION.toml` entry and `cargo xtask assets` passes ## Security - [x] `--root` confinement still holds on every path, including ones reached by nested tool dispatch - [x] MCP and the UI control channel stay opt-in, loopback-only and token-authenticated - [x] No new outbound network access (that decision is the owner's) ## Parity and reach - [ ] `parity/acrobat-features.toml` updated in this PR, with `notes` saying what is *still* missing — `shipped` means "exists and tested", not "as good as Acrobat" - [ ] Reachable headlessly through an `automation` tool where that applies (`AGENTS.md` §3), so agents can drive it and not just the UI - [x] Docs updated if this changes a documented behaviour (`docs/`, crate README) ## Anything a reviewer should look at first The thin-box rule in `draw_draw`: it compares the box with twice the drawn (clamped) stroke and picks the longer side, so hairline borders never come out diagonal and a degenerate box never yields a zero-length segment.