- The steps of a live blend are written as drawn art: copies of key
objects with text wrap options no longer write those options again.
The keys keep theirs on the hidden lines and the blend keeps its own.
- The record holds Specified Distance as a 32-bit float, which the
reader reads back as its shortest decimal. The writer now compares the
blend with that distance, so a distance typed in another unit (10 mm
is 28.346456... pt) is written live when it lays out as many steps.
- blend_steps_settled has unit tests for each of its cases.
- blends_write_the_same_bytes_again checks that every blend is written
live both times.
- Comments name the blend plugin's XP line by its constant.
- docs/target-app-parity.md lists live blends in the .ai editing copy;
a line in docs/file-format-parity.md is wrapped like the rest.
Tests: a_live_blends_steps_carry_no_text_wrap_options,
a_blend_spaced_in_millimeters_is_written_live,
steps_settle_unless_rounding_can_change_their_count.
The editing copy of a PDF-compatible .ai wrote every blend as its steps.
Blends the .ai reader opens live are now written live:
- The blend's key objects and, when it has a spine of its own, its
spine are written as a group on hidden lines, each key's dictionary
naming it a key and its id and the spine's naming it the spine. Its
steps follow as a group, then the Path Blends record of its spacing
(Smooth Color, Specified Steps, Specified Distance with its distance),
orientation (Align to Page, Align to Path) and keys, then its
dictionary (name, text wrap options, variables) and its opacity and
blending mode as a group's after its end. A spine edited on the canvas
is written with each key's anchor on the key. A replaced spine is
written with an anchor where each key sits, so it opens with those
anchors and lays out the same steps.
- Each blend is checked with the reader's own reading before it is
written, and the blends together against the objects the reader lays
out in one file. Written as their steps with a warning: blends with
easing, a color shift or start points; with effects, an appearance or
an opacity mask of their own; of objects other than paths, compound
paths and groups, of clipping groups, of more than 62 key objects, of
hidden keys or keys holding a blend; of keys with geometry or
Pathfinder effects or a group's own fills and strokes, which the
editing copy writes as their result; of keys the editing copy would
change otherwise (empty paths or subpaths, paths and compound path
members of several subpaths, several fills or strokes, strokes a plain
line can't draw, dashes of more than 64 lengths, hidden fills or strokes, fills or strokes other than
a color, in a Lab color or with transparency or effects of their own,
effects, opacity masks); blends where one key has a fill or stroke of
no paint or a stroke of no width and another has one that draws;
blends whose spine has more than one part;
blends whose step count is close to where rounding the written
coordinates and colors changes it; blends the reader would open with
other settings or not as drawn; blends inside objects with geometry or
Pathfinder effects or a group's own fills and strokes; blends in
opacity masks, pattern tiles, symbols and art cut to a clipping object
or nested eight levels deep in art written in place of other objects;
blends whose art would pass the most objects the reader reads; and
every blend on a large canvas.
- The steps set their own transparency and lock and hidden state after
the hidden lines, for readers of the printed form.
Each construct is written in the form the .ai reader reads (blend.rs,
read/document.rs blend roles, read/containers.rs end_blend, read/ops.rs
XP and transparency), and every object written counts toward the
reader's object limit as the reader counts it. The record's orientation
word and a blend with no spine part are read as #8243 reads them.
Blend Options, key objects and spines:
https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blend-options-overview.htmlhttps://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260
Tests: the round trip of blends of each spacing and orientation, with
no spine of their own, an edited spine and replaced curved spines,
named, at half opacity, hidden and locked, with text wrap options, of
compound paths, of groups and of 62 keys, each laying out the same steps
as the document's blend; the record's words (Align to Path's angle
included) and the dictionaries; the steps' own state after the hidden
lines; the same bytes on a second write; each case written as its
steps, with as many steps as are drawn, where they are drawn (among
them Specified Distance 0.03 pt from where its count changes, on a
spine of 200 segments, which comes back live on a spine of two); blends in
pattern tiles, opacity masks, symbols, art cut to a clipping object and
eight levels down; the object limit; the reader's blend limit; a large
canvas; fuzz cases for damaged written blends.
Docs: docs/file-format-parity.md.
When the orientation the record names didn't lay the steps out turned
as drawn, the import took the orientation whose steps sit closest to
the drawn ones by their centers alone. A half turn leaves the centers
in place, so a blend drawn Align to Path whose record named Align to
Page came in as Align to Page, with each step turned from its drawing.
The import now takes the closest of the orientations that pass the
check, and the closest of them all only when neither passes.
Test: grouped red and blue squares drawn turned on a spine running
right to left come in as Align to Path with a record naming either
orientation.
The check that the record's orientation lays the steps out as drawn
compared a step's outline as one set of lines. A half turn of a group
of a red square beside a blue one keeps that outline and trades the
squares' places, so such a blend passed as Align to Path. Each subpath
is now compared with the other's subpaths of a matching fill; a compound
path's members take its fill, and gradient or pattern fills are compared
with each other by their outline.
The check also tries the laid steps nearest first when it compares
outlines. Before, every step in place was compared, so a hundred steps
crowded within the tolerance used up the outline comparisons on the
first one and the check failed.
Tests: grouped red and blue squares on a spine running right to left,
drawn unturned, keep Align to Page with a record naming either
orientation, and keep Align to Path when drawn turned; a group of a
gradient-filled triangle turned a half turn doesn't match; a hundred
crowded steps match their drawn copies; 998 crowded steps keep Align to
Page.
With more than 16 drawn steps, the check compared the outlines of the
first 16 it tried and took the rest by their sizes, so a last step drawn
turned the other way still matched. It now compares the outlines of 16
steps spread evenly from the first to the last. A step that would take
more than 64 outline comparisons matches none, so the record's
orientation is not taken on an outline that was not compared.
The check that keeps a record's orientation compared two outlines by
their anchors alone. A square with its top side bent inward has the same
corners as its half turn, so the two matched. The check now also
compares the points a quarter, half and three quarters along each
segment, in both directions.
Opening a .ai from its editing data alone checked whether the text
document makes all of its type, then built the document, and each step
decoded and parsed the text document and scanned the text objects'
frames again. A file with envelopes of type, which waits on its PDF
part, did this up to four times.
The check and the builds now share one read of the frames and of the
text document. It is kept with the decoded editing data for the build
with the PDF part and for the build without it that can follow, also
when the check failed. The build applies its own pattern paints to the
shared text document, as before.
The document and notes are unchanged: new tests compare them against
the same opens with every check and build reading the text afresh, and
count one read and one scan on each route.
The writer measured which way each patch turns only at its first corner,
along the straight lines to the next corners. A patch whose point is
dragged across it, or whose handles cross at a corner, passed as a
plain patch and was written as a mesh. Each corner of each patch is now
measured along the straight lines and along its handles, and a mesh
whose corners turn different ways is written as its drawn look with the
warning.
- Tests: a patch folded at a corner by a moved point and by crossed
handles; a reflected mesh read back draws the same points and opacity
across each patch; an envelope in a symbol's art with its grid and
contents in the symbol's own space opens as the art it draws, and one
in a file without a template box is left unread.
- The fuzz case for written meshes moves next to the other editing-data
cases in import_fuzz.rs.
- Docs: file-format-parity.md says a reflected mesh opens with each
row's points in reverse order, and how envelopes in symbols open;
target-app-parity.md links the help page on mesh point opacity.
The editing copy of a PDF-compatible .ai wrote every gradient mesh as
its drawn look. Meshes the .ai reader reads back as they are are now
written as meshes:
- Each mesh is a /Mesh record: 2 /Version, its type and grid size,
/Data, then each patch row by row with its place, the color space
where it changes (gray, RGB or CMYK) and its four corners: color,
opacity, point, and the handles towards the next corner and the one
before it. Its opacity, blending mode and knockout shape are set
before the record, and its name and opacity mask follow it.
- A reflected mesh, whose patches all turn the other way, is written
with its columns in reverse order, which draws the same mesh.
- In a symbol's art the corners are written about the canvas point of
the ruler origin, y up, as an image's matrix there is. An envelope's
grid in a symbol's art is now written in the same space, and the
envelope's contents in its dictionary in the canvas's space, y down.
- Each mesh is checked with the reader's own reading before it is
written. Written as their drawn look with a warning: meshes with a
point in a Lab color, with more than 128 rows or columns, folded
meshes (patches that turn different ways), meshes the reader would
read with other points, handles or colors, meshes in pattern tiles
and in art cut to a clipping object, and every mesh on a large
canvas. A mesh's drawn look is written at any depth of nested
symbols and live objects.
Each construct is written in the form the .ai reader at e142c5fcee
reads: /CS, /Type, /Size, /P, /N and /E in mesh.rs:180-234, corners
with or without an opacity by their count of values in read_corners
(mesh.rs:239), the patches joined into one mesh in one_mesh
(mesh.rs:298); /Mesh X!, X# and /End X! in read/ops.rs:219-232; the
transparency after the record in read/art.rs:281 (end_mesh) and
read/ops.rs:344. /Version and /Data are passed over by that reader
(mesh.rs:234). Corners in a symbol's art rest on a reader change in
this commit.
The reader changes how any .ai opens:
- Mesh records and envelope grids in a symbol's art are read in canvas
space (read/document.rs:947 image_space), and an envelope's contents
in its dictionary in the canvas's space, y down. In a file without a
template box such a mesh is left unread, its symbol is not read
whole, as with an image there (read/art.rs:634), and its instances
open as the page draws them. Envelopes in symbols in .ai files saved
by earlier VectorCraft builds open differently.
- A point of a patch whose corners differ in color model keeps its own
color when the patches are joined into one mesh.
Gradient meshes, mesh points and their opacity:
https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=200
Patch meshes (corners joined by cubic edges with control points):
https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.7old.pdf#page=321
Tests: the round trip of meshes with RGB, CMYK and gray points, a moved
point with handles of its own, part-transparent points, a name,
opacity, blending mode and knockout shape, hidden and locked, with an
inverted, unlinked opacity mask, in groups, opacity masks, symbols,
opacity masks in symbols, a document of two artboards and eight levels
down, compared point by point, handle by handle and channel by channel
at the 4 decimals written; reflected meshes, mirrored across and
along; the record's form, including corners in a symbol's art and an
envelope's grid and contents there; an envelope in a symbol read back
with its contents and their gradient in place; the same bytes on a
second write; each case written as its drawn look, with its paths read
back over the mesh's box; reading a mesh in a symbol's art with and
without a template box; /Version and /Data passed over; the color
model rule; fuzz cases for damaged written meshes, a symbol's
included.
Docs: docs/file-format-parity.md, docs/target-app-parity.md.
Two settings of a blend read from the editing data came from rounding
instead of from the file:
- The orientation was whichever of Align to Page and Align to Path laid
the steps out closer to where they are drawn. The check compares the
steps' centers, which turning the steps along the spine leaves in
place, so on a straight spine both fit and the rounding of the drawn
steps decided. The reader now reads the record's word 5 (0 is Align to
Page; a 32-bit float of 8 or more is Align to Path) and keeps that
orientation when it lays the steps out as drawn: in place, at their
drawn sizes and with each one's outline where it is drawn, which
turning a step moves. Otherwise it takes the closest, as before.
- A blend with no spine part opened with a straight spine and an anchor
at each key. When its record names the keys in their order, it now
opens with no spine of its own, which lays out the same straight
lines between the keys' centers. A record that names them in another
order still gets the straight spine in the record's order.
Blend Options, orientation and spines:
https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blend-options-overview.html
Tests: the record's word 5 (0, 8, 8 plus an angle, and values that name
no orientation); the record's orientation kept where both lay out alike,
and not taken where it would turn the drawn steps (rectangles on a
vertical spine, triangles on a spine running right to left); outlines
that match whatever anchor a path starts at, with another anchor on a
side, with contours in another order and with a lone anchor, and live
art compared by its size; a blend with no spine part in record order
and in the other order.
Writer::raster formatted every sample byte with write!("{:02X}") into a
separate String and then copied that String into the file body. The new
Writer::push_hex looks each nibble up in a 16-digit table and appends the
comment lines straight to the body, so a large image no longer holds a
second copy of its hex text. The written bytes are unchanged: upper-case
digits, 60 per `%` line, a newline after the last line and no line for
an empty image.
On the 36 MB of samples of a 12 MP RGB image, the hex step took a median
of 735.5 ms before and 90.8 ms after (7 runs each, both versions in one
release process). The gain matters on documents with large images.
Saving a legacy .ai file numbered a gradient definition whose name was
taken by searching every definition written so far for each number it
tried, so a document with many distinct gradients without a swatch name
spent time cubic in their count naming them. Spot color names were
numbered the same way.
Both now keep the names given in a set and, for each name, the number to
try next. Names are never given back, so every number below that counter
is still taken, and the file is the same as before: the first free
"Name 2", "Name 3" and so on, with equal gradients sharing a definition.
- New tests compare the counters with a search of the names given over
3,000 names, and the whole written file both ways for colliding
gradient and spot color names.
- An ignored timing test writes 1,504 gradient definitions: in release on
Linux, the median of 7 runs took 23 ms of thread CPU time against
1,163 ms for the search.
A series read from bands with unstroked markers, or bands alone, kept an
explicit no-stroke paint. With Draw Filled Lines turned off, the thin line
took that paint and was not drawn. Such a series now keeps no stroke, as a
graph drawn here does, and its thin line is drawn in the series color at
1 pt. A series whose markers carry a stroke keeps it.
readhexstring and readline called the one-byte file read for every input
character, copying each byte into a new vector. They now scan the bytes
left in the file in one slice and advance the file by the bytes they used.
The results are unchanged: the same bytes, the same boolean, the same next
unread byte, from the program's own file (after the whitespace that ends
the last token), a decoded buffer and a filter decoded when first read.
readhexstring stops on the digit that completes the last byte and drops a
lone digit at the end of the data; readline takes CR LF as one line ending,
leaves the byte after a lone CR unread, and leaves the line ending unread
when the line fills the string.
Tests run the new readers next to copies of the byte-at-a-time loops over
13 stream forms and several hundred inputs, comparing the result and
everything left to read; an image read through a readhexstring procedure
is compared with the same samples given as a hexadecimal string. The
import fuzz tests gain readline and a case for both operators.
data_op allows clippy::cognitive_complexity. Without the allow, clippy
rates it 54 against the limit of 30; with the old loops in place it
passes.
A line graph whose style record draws its lines as shapes now opens as a
live graph with Draw Filled Lines on, and its lineShapeWidth becomes the
Line Width (3 pt reads as the default). The flag is ignored when the
points are not connected, as the published file format specification
says (printed pp. 147-148). Saving writes both values in the Gy record.
- Widths from 0.01 to 100 pt are kept. A wider Line Width, a width under
0.01 pt with filled lines, and filled lines without connected points
are saved as the graph's art with the existing warning.
- In a filled-line series, a filled path with the thin black band
outline is read as a band and does not set the series stroke. A
filled path with another outline must be a square marker or legend
swatch; otherwise the graph keeps its art as plain objects.
- The reader in crates/eps/src/import/ai/read/graph.rs reads each value
the writer in crates/eps/src/ai_graph.rs writes; the save-then-open
tests cover the default, 8 pt and 150 pt widths in both .ai forms.
xtask pdf-deps still expected craft-pdf and the patched hayro/krilla
backends at main's 9be9a637 revision after this branch pinned them to
a499742a. Point REV at that pin (still on craft-libs main). Classify
test files in sonar-project.properties the way craft-libs does, so the
quality gate measures the product. Give the EPS operation-budget test
the same 300s cap as the other budget tests; under instrumented coverage
it overran the old 120s cap, while the Ubuntu gate finished in time.
A gradient definition in the .ai editing data holds each stop's color, opacity, midpoint and ramp point, and VectorCraft's reader opens it as a Classic gradient. A Perceptual gradient was written with its own stops, so the file opened with different colors between them.
The writer now treats a Perceptual gradient as it treats a gradient mixed around the hue wheel, in the art and in the Swatches panel: the colors on its curve become stops of their own in process colors, at most 256, with a warning that names Perceptual gradients. A stop linked to a global process color reports its lost link for both methods. Dither is reported as its own loss. A freeform gradient, or one with more than 256 stops, is still written as its average color whatever its method.
A stored texture longer than the codec's default 2^18-pixel side still
reads back, and a gray PNG is not expanded to RGBA just to get its
levels. The AI writer and the EPS scene refuse an oversized image from
its header, then decode within MAX_IMAGE_PIXELS, keeping the pixels at
their stored depth. Flatten's see-through check uses ImageBlob's
allowance, and links.unembed decodes within MAX_RASTER_ALLOC.
In a legacy .ai gradient definition, each color stop holds only its
color, midpoint and ramp point, and VectorCraft's reader opens such a
gradient as a Classic gradient. A Perceptual gradient was written with
its own stops, so the file opened with different colors between them
and no warning.
The writer now treats a Perceptual gradient as it treats a gradient
mixed around the hue wheel: the colors on its curve become stops of
their own in process colors, at most 256, in a definition of their own,
with a warning that names Perceptual gradients.
A clipping object written as art cut to it (a group, an image, a symbol
instance, a live object, type, or a path inside art already cut to
another clipping object) lost its name, opacity mask and variable
bindings in the editing data: no written object carried its dictionary,
and a painted one put its name on each of its fill and stroke objects.
The unpainted path that carried its text wrap options now carries its
whole dictionary, in the form the .ai reader reads (art_dictionary in
crates/eps/src/import/ai/read/document.rs). Its fills and strokes keep
only the opacity mask they are drawn through. The path is admitted by
the object count, so at the object limit its dictionary is never left
on the object before it, and a path whose dictionary comes out empty is
taken out again.
Remove Background and Color Mask check the image's size from its header
again before decoding ("an image of W × H pixels is too large to change"),
and Crop Image's trim and Remove Background read a file that can't hold
the pixels its header declares as unreadable, as on main. The test helper
reading Remove Background's output keeps 16-bit samples.
The HEIF and JPEG XL readers and their tests go back to main's (heic-rs and
jxl-oxide): the craft-heif and craft-jxl versions failed eight of their
tests (resolution axes after a quarter turn, the container's mirror and
crop, refusing a grid of cropped tiles, 16-bit samples, the decode
allowance). Moving them stays to do.