parse() refuses a template larger than the 64 MiB a document's packets may
hold (read_packets' limit), before any of it is parsed, so what parsing
keeps of it, item lists held by the field and its properties among them,
stays within a few times that whoever calls it (review).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
The vendored hayro-syntax ran PNG predictors through the bit-level
BitChunks/BitWriter machinery TIFF predictors need, although PNG filters are
defined on bytes (ISO 32000-2 §7.4.4.4, PNG specification §9). A 993 x 936
RGB image took about 63 ms to unfilter whatever its row filters; undone on
byte slices it takes about 3 ms (Up) to 16 ms (Paeth) in a release build.
It also fixes a row that ends part-way through a pixel (three 4-bit samples
at an odd width): the bit-level path dropped its last byte, each later row
started a byte early and the picture came out sheared.
TIFF predictor 2 keeps the old path. Vendored hayro-syntax patch 29.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
In a flowing (lr-tb/rl-tb) parent the members of a subformSet now go on
along the parent's line with its other children, rather than the set being
packed as one block that moves to the next line whole (XFA 3.3 p. 357: the
set is transparent to layout). The members keep the set in their SOM paths.
Adds a test that, in a table and in one of its rows, a set's members still
go one under another (review).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Includes #4325#1952#4180#2529#4320#4805, preserving their original histories.
Keep paragraph alignment and hard/soft wrap metadata together; retain CCITT/downsampling/RGB ownership guards with bounded JBIG2 export and exact-copy symbol encoding.
Combined interaction regressions added. Validation pending.
Use a named compact preset arrow beside the field, retain the row alignment/width assertions for the editable control, and open the current colour flyout in the saved-text regression. No accessibility or layout checks are disabled.
Preserve caption editing and current form/Prepare module boundaries. Carry export-only appearance preservation, validation and data round-trip tests to their current paths, and retain current attribution metadata. Hosted CI must validate this refreshed head.
Preserve main's continuous text selection, page tools and module split. Carry only this branch's sidebar-focus feature and regression onto main, without resurrecting old common files from criss-cross merge bases. Hosted CI remains required.
Use the unified Format Text panel and current page-input context instead of restoring old monolithic UI code. Preserve main's pointer routing, editor accessibility and preferences; retain colour, save and input regressions. Hosted CI must validate this refreshed head.
A larger range on the first line of a multi-line paragraph rises from the
first line's baseline, not from the old box's bottom, so the reach now
extends one pitch above the moved box's top. Name the 1.2 em line floor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
With only a range enlarged, row_step is the source leading, so the
styled rewrite's reach rose one source line above its old box while a
120-point range draws far higher, and an image there was missed. The
pitch is now at least 1.2 times the largest size.
The landing test gains a 120-point range on a 12-point OCR line under an
image above the old box; it fails without the floor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
Vendored hayro-interpret patch 61.
- A degenerate subpath (a single-point closed path, or points that all
coincide) is stroked as a dot of the line width with round caps and not
at all with butt or projecting square caps (8.5.3.2). The zero-length
`l` is no longer nudged a ten-thousandth of a point (which gave square
caps a direction to draw a square in), and `x y m h` keeps its `h`
(kurbo's `is_empty` counts only segments, so it was dropped and the
subpath painted nothing). Other subpaths and zero-length dashes are
untouched.
- A dash array that is all zero, or has a negative or non-finite entry,
is kept as `[]`, a solid line (8.4.3.6). `[0 0]` used to become
`[0.01 0.01]`, a faint half-covered line.
- A negative or non-finite line width from `w` or `/LW` is kept as 0,
the thinnest line (8.4.3.2), so no device sees a width below zero. The
renderer already drew it as a one-pixel line in the stroke colour.
Tests: crates/render/tests/it/stroke_geometry.rs (pixel checks and a
recording device).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
The inline-image check of patch (60) looked the /CS name up in the
ColorSpace resources even when it was a device space name or its inline
abbreviation (/RGB, /DeviceRGB, /G, /CMYK, ...). Those names never refer
to resources (ISO 32000-2 8.6.8), and ImageXObject::new takes the device
space first, so a malformed Indexed resource that happened to share the
name skipped an image that would draw correctly. Device names are now
excluded before the resource lookup.
Test: indexed_lookup::an_inline_device_space_name_ignores_a_resource_of_the_same_name
(fails with the filter removed: the image is skipped and drawn white).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
An image in [/Indexed /DeviceRGB 7 <FF0000 00FF00>] was drawn entirely
black, indices 0 and 1 included. The interpreter rejected the colour
space when the table ran out, and the image fell back to DeviceGray, so
its index values were painted as near-black grey levels.
ISO 32000-2 8.6.6.3 says hival "shall be an integer", no greater than
255, and the table "shall be m x (hival + 1) bytes long". An image whose
Indexed space breaks this (hival not an integer in 0..=255, or a lookup
missing or shorter than needed) is now not drawn, and the render reports
RenderWarning::MalformedIndexedImage once per page; pdfcraft-cli render
prints it. A longer table is still fine. Inline images, including one
naming such a space as a resource, are skipped the same way. Fill and
stroke colours in such a space go through a different path and are
unchanged.
Vendored hayro-interpret patch (60), recorded in vendor/README.md.
Tests: crates/render/tests/it/indexed_lookup.rs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
The styled path writes rows `line_spacing` (1.5 by default) times the
size apart when a size or spacing is set, but its Reach assumed 1.2, so
an image over only the lower rows of a larger rewrite was missed. The
pitch now comes from the row writer's own step (row_step, shared by
both), at the largest size among the paragraph's lines and ranges.
The landing test gains a six-row rewrite at twice the size over an image
covering only its last row; it fails with the 1.2 step.
A case with only line_spacing set covers the other branch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
The walk queued every entry of a Kids array before checking the node
limit, and resolving a direct node or array deep-copied it (two to four
times for a direct tree). It now recurses (depth stays capped at 32),
borrowing each node from its resolved owner, and stops at the limit as
it goes: only the branch being walked is held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
The stand-in fitting of hayro-interpret patch (67) also applies to Symbol
and ZapfDingbats (ISO 32000-2 9.6.2.2, Annex D.5 and D.6). Tests show
that their glyphs, and the check mark a check box draws for its /MK /CA
caption 4, keep the standard advance:
- symbol_dingbats_width (pdfcraft-render tests/it): Symbol alpha, beta,
pi, Sigma, Omega, Delta, infinity, bullet and plus, and ZapfDingbats
a20, a19, a23, a24, a71, a73, a77 and a28, drawn with no /Encoding:
each glyph's ink lies within its standard advance and fills most of
it, and the next glyph starts one standard advance on.
- dingbat_check_box (pdfcraft-engine tests/it): a check box with no /AP,
/DA (/ZaDb 60 Tf 0 g) and /MK /CA (4) draws its check centred in the
box, within its 846-unit advance and not squeezed.
The patch is renumbered (67), next after main's highest (66), and the
Tests column lists the new tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
A standard 14 font named without /Widths is drawn with a bundled CFF
stand-in. Its glyphs are fitted to the standard metrics only when the
stand-in's own advance is known, and for the CFF stand-ins it never was,
so each glyph was drawn at its own width. The stand-ins' Euro is 667 to
722 units wide against the metrics' 556 (Helvetica) and 500 (Times), and
it overlapped the glyph after it ("€5", "€€", "a€b"). The advances
themselves were right: both the renderer's metrics and the writer's
Std14 table already give the Euro 556/500/600.
hayro-interpret patch (67): CffFontBlob::advance_width reads a glyph's
advance from its charstring, and StandardFontBlob uses it, so a stand-in
glyph is fitted to the standard width as the OpenType stand-ins already
were (ISO 32000-2 §9.6.2.2; Annex D Table D.2).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
The on-top trigger compared later paint with the paragraph's old box. A
rewrite that is moved (BlockStyle::offset), rewrapped wider or grown to
more lines can land under an image the old box is clear of, and stayed
underneath it. Both rewrite paths now test a Reach: the old box (where
the cover goes) plus the moved box grown to the wrap width either way
and down to the drawn line count (the widest measured line when wider), and
up by one line pitch for a larger size; turned text grows by the lines'
diagonal; any non-finite number makes it unbounded. Over-reaching is
harmless: the cover still fills only the old box. The parity notes say
so.
Tests: an_ocr_rewrite_goes_on_top_of_paint_over_where_it_lands (move,
width and line growth, both paths) and a_rewrites_reach_covers_its_move_
width_and_lines. Seen failing with each path reverted to the old box and
with growth zeroed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
`degenerate_fill_area` took a side under 1/256 unit as zero, so a thin
rectangle with area that the CTM scales up to whole pixels (100 x 1/1024
under a 4096x vertical scale covers four device rows) was clipped and
filled as a one-pixel band along its bounding-box diagonal. The fill
fallback had the same threshold and stroked it as a hairline. Both now
treat only an exactly zero side as degenerate; a box with area is
filled and clipped as the shape it is.
A slanted zero-height line less than a pixel high was snapped to its
whole bounding box, marking both rows along its full length when it
crossed a row boundary. Whole-pixel snapping is now used only when the
line stays within one device row or column (a line under 1/256 pixel
across is taken at its middle); otherwise it is the one-pixel band, so
each row is marked only where the line runs through it (ISO 32000-2
§10.7.4, half-open pixel squares the shape intersects).
Tests: crates/render/tests/it/zero_area_fill_clip.rs
a_thin_rectangle_scaled_up_to_whole_pixels_keeps_its_area and
a_slanted_zero_height_line_crossing_a_row_marks_each_row_only_where_it_runs
each fail with their part of the fix reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
A rectangle with no height or no width encloses no area, so the
rasteriser marked nothing for it. As a clip (`10 10 100 0 re W n`) it
hid everything painted after it; as a fill it fell back to a
thinnest-line stroke that half-covered two rows when the line lay on a
pixel boundary.
ISO 32000-2 §10.7.4 paints every pixel whose half-open square the shape
intersects, "no matter how small the intersection is" ("A zero-width or
zero-height rectangle paints a line 1 pixel wide"), and a clipping
region is "the set of pixels that would be included by a fill
operation".
hayro-interpret patch (65), `degenerate_fill_area`: a fill or clip whose
path has no width or no height (but not both) gets the device pixels the
line touches - whole pixels when it runs along a device axis, a band one
device pixel wide when a rotated CTM turns it. Points, and paths with
area however thin, paint as before.
Tests: crates/render/tests/it/zero_area_fill_clip.rs (5 of 8 fail with
the patch reverted; 9 mutants of the patch each fail a test).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
main raised the redaction pass's form depth limit from 12 to 50 (#3645),
so the 16-deep chain was walked and the test's form was no longer removed
unread. The chain is now built from MAX_DEPTH, one level past it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
Review on #2539: a removed glyph with no known text (no /ToUnicode, a
glyph name outside the list) went in as an empty string and nothing marked
the collection as incomplete, so when every removed glyph was like that
the terms were empty and /Info and XMP were left untouched. It now counts
as text the check couldn't keep, and every /Info string and XMP stream goes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review by Losminek on #2539:
- The work cap was checked per value, so very many small /Info or XMP
values could add up without bound. One budget now covers the whole
scrub; past it every further entry or packet counts as matching
(fail-closed). Identical removed runs are searched once.
- unescape looked for ';' through the rest of the text before checking
the 12-byte entity limit, so a packet of bare '&'s was quadratic. It
now looks only at the next 13 characters (200,000 '&': 943 ms -> 5 ms).
- A form XObject removed whole past the depth limit, or when its stream
doesn't decode, never had its text read; both paths now set
removed_cut so the metadata check clears everything instead of
searching incomplete text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up on #2539:
- only a processing instruction whose target is exactly `xpacket` is
skipped, so `<?xpacketAudit …?>` is searched like any other;
- an attribute name is kept across whitespace before `=`, so
`xmlns:x = "adobe:ns:meta/"` is still a declaration, not a value;
- the XMP stream is decoded with decoded_within(MAX_XMP_BYTES), so a small
stream that inflates hugely stops at the cap instead of after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up on #2539:
- the glyph end includes character and word spacing, so letter-spaced
redacted text is one word and still matches /Title (Bluefin);
- an XMP value wholly part of a removed run goes, as an /Info value does
(J. Li), compared as whole words (True stays with "untrue");
- when the removed text was cut short (too many runs, a run too long, too
many terms) every /Info string and XMP stream goes instead of searching
what was kept;
- XMP that is not valid UTF-8 or UTF-16 (also UTF-16 without a leading
mark) is not searched lossily but removed;
- namespace declarations and the xpacket wrapper are not searched;
comments and other processing instructions are;
- the raw-byte assertion saves without object streams so it can see /Info.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A value shorter than the redacted sentence ("James Bond" from "JAMES BOND
IS A SPY") in a custom schema's element or attribute takes its packet
with it, as it goes from /Info, while a clean packet and an unrelated
entry stay. The regression #2598 suggested keeping whichever fix lands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An /Info value whose words are too short to be terms ("J. Li") survived
when the sentence holding it was redacted. A value that is wholly part
of a removed run, with three letters or digits at least, now goes as
well (the reverse check #2598 proposed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applying redactions removed the glyphs under the marks but left the same
words in the document information dictionary and the XMP metadata.
The redaction interpreter now collects the removed glyphs' text in runs by
position. After verification, /Info entries containing a run (or one of its
longer words) are removed, and the catalog's and pages' XMP streams whose
text mentions one are removed whole; unreadable or oversized XMP fails
closed. Report::metadata counts what went.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UPDATE_APP (native builds; craft-update is a native-only dependency) carries our 128 px icon and accent (#b70228, its red, from the icon (#5245)). The updater, the self-update
helper and craft-update's startup prompt all get them through crate::UPDATE_APP; the
prompt draws the icon, the accent and "by ArtCraft" (craft-update's default developer).
craft-update is pinned to storytold/craft-libs main at 1065653e7 (#434).
Clippy fixes for Rust 1.99 in untouched code (same logic):
- crates/edit/src/images.rs
- crates/forms/src/appearance.rs
On a page with a word divided by a line-end hyphen, Find searches three
readings and merged their hits by dropping any hit that overlapped the
one kept before it. That also dropped hits of one reading that share a
glyph, such as "f" twice in an "ffi" ligature glyph, so the match count
depended on unrelated text elsewhere on the page. A hit is now left out
only where it overlaps one kept from another reading. The test oracle
follows the same rule, and a fixed case covers it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
Find, text_find and Search & Redact's word search read the Latin
compatibility ligatures U+FB00-U+FB06 as their letters, in the page and in
the query, so "office" finds a page drawn with an fi ligature glyph
(ISO 32000-2 9.10.3 maps ligature glyphs to their letters). Each letter
stays owned by its glyph, so the highlight covers the ligature.
Where a line ends in a hyphen (U+002D, U+00AD, U+2010) between two
letters, the page is also searched with the hyphen and the break dropped
("example" finds "exam-" + "ple") and with the hyphen kept but the break
dropped ("exam-ple"). The hits are merged in page order; a match covers
both lines and is highlighted on each. Pages without such a hyphen are
searched once, as before.
Accent-insensitive search is left to the open pull request for #3460.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
An unrelated image later on the page no longer moves the paragraph and
its cover on top, where the cover could hide visible content inside the
paragraph's box. An XObject now counts only when it is drawn at or after
the paragraph and its visible box overlaps the paragraph's
(`images::painted_over`, from `page_images`). An inline image or a
shading after the paragraph still counts anywhere, and so does any XObject
when the page's images cannot be listed.
The trigger table now covers an image elsewhere, an image drawn first,
visible text, a filled path, a shading and an inline image. It fails with
the old any-`Do` trigger.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
A picture read from the file is kept for the next place that links it.
Those kept bytes now count against MAX_TOTAL as well: past it, a name
not read yet is neither read nor kept, so a tree with many names holds
no more than the total however many names it has.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
A table test for `revealed_under_paint`: only invisible text with an
XObject, inline image or shading after its place moves; a filled path,
visible text or nothing after it does not. Seen to fail with the check
reduced to `invisible`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
A flowed subform in a row cell is drawn at its column's width; its
content height is now measured at that width (less the cell's margins)
rather than at the width the cell gives itself, so content that wraps
in a narrower column no longer runs under the next row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
An OCR paragraph that may go on top of the page is checked (`check_on_top`)
before either rewrite path changes the document, so a page whose marked
content nests too deep is refused with nothing changed. `lift_on_top` no
longer checks.
Tests: undo restores the hidden layer and the scan, redo, save and reopen,
and a second edit of the moved text all show the edit; a phrase split from
visible text in the same text object shows its edit; a refused rewrite on a
too-deep page leaves the saved bytes unchanged. Each new test was seen to
fail with its part of the fix reverted.
Parity: the note says when the edit is drawn on top and lists what is
still missing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9