The test only checked that no warning mentioned limitcheck, so a
rangecheck or typecheck at the size limit would still pass. It now
checks that the import reports no error at all.
Adds tests for interpreter paths that no test reached:
- LZWDecode: the PDF 32000 example (a code that is the entry it adds),
12 KB of data whose table grows through 9- to 12-bit codes and is
cleared, and a code past the end of the table as an ioerror.
- An image too large to hold whose data is LZW or run-length: the data
is measured and skipped, and the art after it is read.
- clipsave and gsave keep up to 1,000 saved states; the next one is a
limit error.
- A sampled function may hold 4096 x 4096 samples and no more
(limitcheck on Size).
- currenthsbcolor when green or blue is the largest channel, and gray.
- cvs text of reals, booleans, names, operators and other objects, and
cvrs radix text with uppercase digits, negative numbers as 32-bit
two's complement, and a radix outside 2 to 36 refused.
No test failed when these writer paths broke:
- EPS export of an inside or outside stroke: the clip to the path (or,
even-odd, to everything outside it) before the stroke drawn at twice
its width.
- EPS export of a pattern stroke, written as its outline filled with the
tiles instead of as a stroke.
- The legacy .ai writer's live-object arm: a distorted image on a layer
is written as its pieces with the live-art warning.
- The .ai writer's top-object grid: the points inside the grid blended
from the four sides, checked on a 2 x 2 and a 3 x 2 outline so a
swapped row and column weight fails too.
Each test fails with the code it covers broken and passes with it
restored.
- The text engine reader reads dictionaries and lists nested 65 levels
deep and stops at a 66th, both balanced, so only the depth limit can
end the parse.
- A row of 256 mesh patches is stitched into one mesh, and a row of 257
is not.
- A variable library whose variableSets node writes its attributes and
children before its name is still read when reading stops before the
library: one variable and one data set with its text value.
Opening a PDF, EPS or .ai file with images re-encodes each image, and
each image's opacity mask, as a PNG. Since the switch to the shared
image codec these PNGs were written with the codec's default
compression (deflate level 6) instead of fast compression. A PDF and
an .ai file each holding one image opened about 50 ms and 105 ms
slower than in 0.24.1.
PDF import and the EPS and .ai readers now each encode through one
helper that asks for PngCompression::Fast, the setting the SVG filter
raster already uses. The pixels are unchanged.
Tests check the zlib header of every PNG an import stores (RFC 1950
FLEVEL): PDF RGB, gray and image-mask images and a CMYK image's soft
mask; a PostScript RGB image and a masked CMYK image's mask; and .ai
RGB and Separation images with their masks, at full size and reduced.
Assertions that ran all() over a list that could be empty now check the
list's length first: mesh points, image inks, glyph origins, imported
text, the PDF mesh and arrowhead paths, and the resampled CMYK pixels.
An image that takes a Warp from its art style is checked to keep none of
the look's fills and strokes, instead of checking each of none.
The convolve-matrix tests check that the filtered rectangle is imported,
not only that the import returned Ok. The fan-out clip path test moves
to a unit test that counts the clip paths read. The self-nesting symbol
test checks that the other symbol comes back. The EPS level and preview
id test checks the param values and the trimming and case rules instead
of looping over every value. The ignored PDF text-heavy timing run says
why it is ignored.
A gradient that repeats or reflects with no stops now paints as one
that pads. Before, PDF export wrote it as two 160 by 160 images and EPS
wrote three runs of a conic where one that pads writes one;
`Gradient::is_spread` is false without stops. `paint.setFill`'s params
still report the spread.
#9228 let a file with many text objects whose type is made be weighed by
where its pieces of type lie, up to four times the comparisons word
matching may make. The page's type lying where made type draws was still
searched word by word in every made text object there, and in the lines
of hidden made type, so those searches could run to the larger limit.
They are now counted on their own, up to MAX_PAIRS. Past it, type where
made type that shows draws is taken as that type, type over hidden made
type only stays on the page, and the page's type is noted as unchecked.
The letters of hidden made type's lines are worked out once.
Since #9228 hidden styled type whose look has its own transparency comes
in as a group of the look and the type, and the group holds the hidden
and locked state. A visibility variable bound to the type's XML id still
bound the type, so showing it left the type hidden. The reader now
records the text slot each such group wraps, and a visibility binding on
that slot binds the group; text bindings stay on the type.
A PDF part without layers comes in on one layer named for its page. When
the editing data is set aside (a stale copy of another page size, say),
pairing that layer with the editing data's one layer locked art nothing
ties to it. Layers now take locks only by a name unique on both sides.
The composite import test now checks the H's top and bottom as well as its
width and height, so a shift of the drawn glyph fails it. The mesh export test
samples each patch's center, so swapped column fills fail it.
The PDF, EPS, SVG mesh, metafile hatch and distorted-image tests now
assert the values the input gives: the Letter page a page without area
falls back to, the H glyph's box from its font metrics, the middle gray
of each mesh piece, the 8 of 64 hatch pixels, and the bounds of the
placement taken at the image's center.
A dynamic symbol instance keeps its appearance changes in the editing
data under each changed part's child index. The copy leaves out paths
and compound paths without anchors, so a change could reopen on a
different part or on none, and changes over 1 MiB were dropped with no
warning.
Such an instance is now written as its art, with the symbol-art
warning, when its changes take more than 1 MiB, when a left-out child
comes at or before a changed part's index in its group, or when the
symbol's root group is left with one kept child. Other instances stay
live with their changes.
Where the text document makes the type of every text object that shows,
each piece of the page's type is matched with the made type that holds
it, and a word of the piece is that type's when its spelling contains
the word. The page can draw two text objects as one word: a word and a
letter set apart from it (a swash "h" after "Spirit") come out of the
page as one piece, "Spirith". Both text objects hold the piece, but
neither spells the word, so it was counted as type with no text object,
with the note "some of the page's type has no text object in the
layers, so it is left out" (a loss, so `convert` wouldn't write over the
file), though both text objects come in and draw it.
A word still left is now the type of the text objects holding the piece
when it is the last word of one of them joined to the first word of
another that draws after it along the first one's lines. Each part is a
whole word of its text object, so bits of words don't make up a piece,
and the two the other way round don't make the word.
In our garment files (used locally, never committed) this takes the
note off one file of 424 and changes nothing else.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict in crates/eps/src/import/native/layers.rs: main reads the layers through read(), which adds the PDF part's font widths; the lazy lock snapshot of this branch is kept on top of it.
The reported file has 2106 text objects; its text document makes the type
of all but 5. The import still counted every text object against each of
the page's 2049 text objects (4.3 million pairs, past MAX_PAIRS), so it
fell back to the PDF part, which has no groups or names to carry locks.
Only the text objects whose type isn't made are matched with the page's
words. The made ones are weighed only by where they lie, a box against a
box, so they get their own limit, MAX_PLACE_PAIRS (4 x MAX_PAIRS). The
reported file now opens through its layers with its 20 locked objects
locked.
The fallback's lock snapshot is now read only when the PDF part is used,
and only when the layers could be read.
The regression builds its own editing data and PDF part with the reported
file's structure; nothing of the reported file is committed.
Main now reads the editing copy decoded as its streams are read
(#9922: ai_alone_decoded, ai_layers_alone_decoded, AiLayers::decoded)
and renamed the text document's patterns to paints (#9782:
text_patterns, Texts::with_paints). The decoded entry points take the
PDF part's widths as the ones they wrap did, AiLayers::decode goes
through AiLayers::decoded, and the text document still takes the widths
when it is first read, before its paints. The docs keep both sides'
entries.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A scatter brush takes a Brightness Jitter amount from 0 to 100 percent (0
by default). Each copy moves the brightness of its solid fills and
strokes, type included, by its own amount up to that many points either
way, after the colorization and the hue and saturation jitter. The
amounts come from the stroke's path and the brush name, drawn apart from
the hue and saturation jitter's, so a stroke draws the same colors on
every redraw, after Save and Open, and in export, and turning it on does
not change their amounts.
A color keeps its hue and saturation and moves in its own model: RGB in
the HSB of its values, Gray by its ink, Lab by its lightness with a and b
kept, and CMYK by its K over the brightness its C, M and Y leave. A CMYK
color that goes brighter than its C, M and Y show with no K loses its K
and takes less C, M and Y. The brightness stops at black and at full.
White, black and grays move too. A brush at 0 saves no brightness_jitter
key; a brush without the key reads as 0.
- brush.options takes brightness_jitter, and brush.get shows it for every
scatter brush. Brush Options shows a Brightness Jitter field
(ui.brushOptions field brightnessJitter).
- Options of Selected Object sets a path's own brightness_jitter
(brush.objectOptions).
- The brightness goes through the per-copy recolor step hue and
saturation jitter use, with its own salt.
- The .ai editing data writer does not write the amount, so such a brush
is left out of the Brushes panel there and reported.
Docs: docs/mcp.md, docs/target-app-parity.md.
The private data streams of a .ai file, or of a PDF saved with its
editing data, were joined into one buffer of at most 256 MiB before
they were decoded, while the decoded editing data may take up to an
eighth of installed memory (512 MiB to 2 GiB). A file whose streams
passed 256 MiB opened as its PDF part without a note, and a file whose
PDF part can't be read failed with "it is larger than 256 MB".
The streams are now read one after the other and decoded as they are
read, so they are never joined. The decoded data keeps its limit, and
no more of the streams is read than that limit and a sixteenth more.
The data is decompressed after the first compression marker in it.
A scatter brush takes a Saturation Jitter amount from 0 to 100 percent (0
by default). Each copy moves the saturation of its solid fills and
strokes, type included, by its own amount up to that many points either
way, after the colorization and the hue jitter. The amounts come from the
stroke's path and the brush name, drawn apart from the hue jitter's, so a
stroke draws the same colors on every redraw, after Save and Open, and in
export, and turning it on does not change the hue jitter's amounts.
A color keeps its hue and brightness and moves in its own model: RGB in
the HSB of its values, CMYK over C, M and Y with K kept, Lab by moving its
chroma with its lightness and hue angle kept (a and b stay within 127).
The saturation stops at none and at full. White, black and grays stay as
they are. A brush at 0 saves no saturation_jitter key; a brush without
the key reads as 0.
- brush.options takes saturation_jitter, and brush.get shows it for every
scatter brush. Brush Options shows a Saturation Jitter field
(ui.brushOptions field saturationJitter).
- Hue and saturation jitter share one per-copy recolor step, which takes
a salt and a color adjustment.
- Options of Selected Object showed Hue Jitter but dropped a change to it
on OK, since a path could not set it for itself. A path now sets its own
hue_jitter and saturation_jitter (brush.objectOptions).
- The .ai editing data writer does not write the amount, so such a brush
is left out of the Brushes panel there and reported.
Docs: docs/mcp.md, docs/target-app-parity.md.
Four EPS import tests asserted elapsed time (5 s, 20 s, a 20 s receive
timeout, and 1,000 copies against 5 times one copy). A busy test runner
could fail them, and a slower run that was still bounded could pass them.
Each now reads a test-only counter on its own thread:
- `]` without its `[`: the operand stack slots that `[` and `]` look at.
200,000 brackets look at no more than 4 slots each.
- The outline check: the point-to-segment distances it works out. A look
drawn 5,000 times works out no more than `MAX_OUTLINE_PAIRS`.
- Objects on a path: the paths and objects the records measure. A
thousand copies of a record measure as many as one copy.
- File fonts: the glyphs `fits` compares. A string of 250,000 of one
character makes fewer comparisons than it has glyphs.
Outside tests the counters do nothing.
Live envelopes, warped type and warped images were held to one shared
difference budget measured only on the first artboard. A file whose PDF
part shows a later artboard, a page cropped to the art, or more than one
artboard could then take more difference on that page than the page
check allows, and open from its PDF part instead of its layers.
Each page the art may be compared with (every artboard, and the art's
bounding box when it is not one of them) now has its own half share of
the page check's allowance. An envelope on a later artboard that draws
away from its drawn art over that artboard's page keeps its drawn art,
where before it opened live. Art on no such page is not held to a page.
Repeated pages are held once, the page list is worked out once per
change of artboards, and an import makes at most 1,024 comparisons with
pages; art that needs more keeps its drawn art.
A .ai file's editing data can include a placed EPS file's bytes between
%%BeginDocument: and %%EndDocument. The reader did not read those bytes:
in the %AI5_BeginPlace form the placed file showed only the preview the
data keeps of it, or an unread placeholder box without one, and in the
version 7 form the art the file draws came in as editable paths with a
note that placed files weren't read.
- The reader keeps those bytes (up to 256 MB) and makes the placed file a
placed document of them, in the file's bounding box where the
matrix puts it. It draws its art whether or not its file is found, and
a native save keeps the bytes. The version 7 form's placed EPS art is
no longer editable on open.
- A placed file stays as before when its bytes are a DCS file (File >
Place makes those linked images), have no bounding box of their own,
carry a VectorCraft document (as VectorCraft's EPS export writes),
don't read as an EPS file, or belong to a file named .ai or .ait.
What reading the bytes warns of is in the open result.
- One with a preview that an image variable binds stays the linked image
showing its preview, as a placed PDF page does.
- The link takes the size and hash of the bytes, so a file found unchanged
is neither missing nor modified.
- Drawing and the open check each read at most 8 placed EPS files inside
one another, so a file whose included files include others opens.
The open check draws the placed documents inside the bytes from their
previews, and it reads each included file once at each depth. A file
nested 12 levels deep opens with at most 8 drawing reads and 72
checks.
- File > Package with Copy Fonts reads the type of a placed EPS file, as
it reads a placed PDF page's, and of the EPS files it includes in turn,
pattern art included.
- On %_ lines the %_ that starts each line is taken off. Then one line
end is taken off the end of the bytes when another line end comes
before it: the one the %%BeginDocument: line ends with when the bytes
end with it, otherwise the last one. An LF after a CR is kept with it
when the file's first line ends with CRLF.
Docs: docs/target-app-parity.md.
A geometry effect is given the object's box as its reference, for
example the center a Transform effect scales and rotates about. Drawing,
the preview bounds, Expand Appearance's first step, shape art, the
outline check of the .ai reader and a stroke's effects before a Transform
that makes the stroke a path of its own measured that box with kurbo's
bounding_box, which counts only segments. A lone anchor was left out, and
a path of one anchor measured a box at the origin, so it scaled about
(0, 0). PathData::bounds, which the selection's box, Align, Transform
Each and every later effect in the stack use, holds lone anchors.
- geom: anchored_curve_bounds measures a BezPath as PathData::bounds
measures the path it stands for.
- render, effects and the .ai reader give geometry effects that box.
Gradient reference boxes and clip regions are unchanged.
The test shards' feature check (`cargo xtask ci shard`) stopped every
shard before any test ran: "vectorcraft-eps: features [] in shard 4,
[work-count] with the whole workspace". Only vectorcraft-engine's
dev-dependencies turned the feature on, and shard 4 tests
vectorcraft-eps without vectorcraft-engine. vectorcraft-eps now turns
it on in its own dev-dependencies, as vectorcraft-pdf does for
read-count, so it builds with the same features in its shard as in the
whole workspace.
Measuring the data of an image too large to hold charged one operation
per 256 decoded bytes. A program that measures the same 300 MiB of
compressed zeros in a loop decoded about 22.8 GB, about 72 passes,
before its budget ran out, and the reading took about 55 s.
measuring_data_too_large_to_hold_in_a_loop_runs_out_of_the_budget took
58 s alone and failed its 300 s guard in a loaded full test run.
Measuring now charges one operation per 16 decoded bytes, and stops at
what the budget still pays for at that rate. A program's budget grows by
64 operations per byte, so one image compressed up to 1024 to 1 is still
measured within what its own bytes add. The loop now runs out of the
budget in its fifth pass, and the test takes 3.6 s.
The test also checks how much was measured: more than one pass and at
most five. With the old rate it fails with 22781165568 bytes measured.
PathData::bounds now counts a subpath of one anchor, so three places
that measure what a path paints measured a point nothing paints:
- .ai import: the box arrowheads are placed against measured a visible
fill by the path's geometric box. A filled path with a head and one
stray anchor no longer fit the drawn look, so its style was not read.
The fill now measures PathData::drawn_bounds(false).
- Type copies a Transform effect moves: the ink box of the glyph
outlines now counts a contour of one anchor only where a round or
projecting character stroke cap draws it as a dot.
- .ai envelopes: a piece of type outlines made only of contours of zero
length kept them and counted their point. It now counts nothing, as
the rule for such contours says.
Tests: a filled line with a head and a stray anchor still fits a look
of the line and its head; a dot-only piece beside a stroked square adds
nothing to the square's box. Both fail without the change.
Six engine tests guarded against quadratic or unbounded work by timing
it (under 2, 10, 30 or 60 seconds) or by printing how long it took. A
slow or loaded machine could fail them, and a regression that stayed
under the bound passed. Each now counts the work the guarded code does
and compares it with a smaller input or with the code's own limit:
- An unknown command id or parameter key of 200,000 characters compares
no more characters than one of 20 (edit-distance cells).
- A Word .doc with 20,000 hidden paragraphs reads at most one more Prl
per paragraph than one with a single paragraph, and each style's
properties are read once.
- One function-based shading filling 5,000 paths takes no more function
evaluations than filling one, and twenty stay within the import's
evaluation budget.
- A form decoding to 64 MiB drawn 1,000 times is walked no further than
the page's form-content limit and one more form.
- A blend of 998 steps measures no more laid steps per object than a
blend of 3, and one of 1,500 steps is not laid out.
- Retype of a tracked line of 450 glyphs lays out at most 20 times the
glyphs a line of 45 does.
The counters are test-only: thread-local cells in the engine under
cfg(test), and in vectorcraft-pdf (read-count feature) and
vectorcraft-eps (new work-count feature), which the engine enables in
its dev-dependencies only. Retype's layout calls go through one helper
that counts them.
The previous commit made PathData::bounds hold the point of a subpath of
one anchor. Node::visual_bounds measures a path from that box, so a lone
anchor that draws nothing (an open one, or a closed one under a butt cap
or with no stroke) widened the visual box by the stroke's reach. The
renderer draws a lone anchor only as the dot of a round or projecting
cap on a closed subpath (point_dots in crates/effects/src/stroke.rs).
- PathData::drawn_bounds measures the segments, and the lone anchors of
closed subpaths when a cap draws dots. Node::visual_bounds measures
paths and compound paths from it, falling back to the geometric box
when nothing is drawn. Geometric bounds still hold every lone anchor.
- The .ai envelope import's box of what type's outlines paint relied on
PathData::bounds leaving lone anchors out. It now removes contours of
zero length from the baked pieces before measuring them, so
a_contour_of_zero_length_paints_nothing passes unchanged.
An envelope whose file saves the size of its contents with their
strokes maps from that box, with margins stored as shares of the
contents' height and width. A straight line along an axis has no
height (or no width), so it got no margins and mapped from its
zero-height geometric box instead.
Margins along a side with no length are now shares of the other
side's length (envelope_margin_lengths). The reader, the envelope's
map, leaving Edit Contents and the .ai writer all measure through it,
so a stroked line opens mapping from its stroked box and saves that
box's size again.
Docs: object.envelope.info params text, docs/mcp.md,
docs/target-app-parity.md.
The styles that link type's colors to their swatches were made before
the writer knew whether the type's story would be written. Type written
as its outlines after all (a thread the text document can't hold) left
its style behind, named by nothing. Such a style is now written only
when a story names it.
Since the previous commit they are written on a large canvas too,
where no other art style is: they hold no lengths to scale. The large
canvas warning now says "no art styles of objects", the comment beside
it says why, and the large canvas test (renamed) checks that spot type
there reads back linked with no warning.
A note on the previous commit's message: "the saved file opened with
the type in a plain process color" is only true when the saved file is
read from its editing data (another app, or VectorCraft once the
VectorCraft document it carries no longer matches its pages). A plain
reopen in VectorCraft restores that document and already kept the ink.
Co-Authored-By: Claude Opus 5.5 <[email protected]>