Texts::read copied the stories, the default styles, the paragraph
defaults and the frames out of the parsed text document and then
dropped the document. It now looks every required path up first,
reads the styles, Kinsoku sets and fonts from the whole document, and
then moves those four parts out. Every document that read before reads
to equal values, and every one that did not still does not.
Reading a synthetic editing copy with 2,000 point-type stories
(1.8 MB) takes a median of 60 ms of CPU time instead of 109 ms (7
alternating runs each, one process). The gain matters on documents
with a lot of type.
A Scatter or Art brush's art is read turned over, and the tiles of its
pattern fills now turn over with it, so they keep their place on the
art. The version 7 pattern test reads a Scatter brush's tile moves in
the file's own space (y up), as the art now is.
Scatter brush art is read turned over, as Art brush art is. The turn now
goes through the same helper as Art brushes, so the art of opacity masks
that don't move with their objects is turned over too and stays lined up
with the art. Fixes the "Unlinked spray" case of
scatter_and_art_brush_mask_art_round_trips.
The .ai writer kept only the image it read last, so a document that
placed two images in turn decoded each again at every placement. The
writer now keeps every image it reads during a save, by the address of
its data and its MIME type, up to 256 MiB of samples and 256 images,
with the image read last kept beside them when they are full. The file
written is unchanged; the tests compare the whole output and warnings
with the old one-image policy.
Two 2048 x 2048 images placed in turn 25 times each, release build,
thread CPU time, median of 7 alternating runs: 3774 ms with 50 decodes
before, 748 ms with 2 decodes after.
- 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.
First Baseline gains Em Box Height (`text.areaOptions {firstBaseline:
"emBoxHeight"}`, and the Area Type Options dropdown). The top of the
first line's ideographic em box, the largest on a line of several sizes,
touches the top of the type area inside the inset, in each row/column
cell and in vertical type. It is the em box that Top-to-Top leading
uses. Min is the least distance, as with the other kinds.
Native files save it as `emBoxHeight`. The .ai reader reads editing-data
kind 5 as Em Box Height and the writer writes it back; Legacy (6) and
unknown kinds keep today's fallback.
The dropdown's Ascent and x Height labels, and Fixed in Gujarati, get
the catalog rows nine languages were missing, beside the new label in
every catalog.
Help page: https://helpx.adobe.com/illustrator/desktop/design-with-text/add-manage-text/add-margins-to-text-and-adjust-the-first-baseline.html
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.