A damaged .ai can give a gradient mesh whose outline is enormous but finite.
draw_mesh_raster flattened that whole outline in device pixels (grown_outline),
and kurbo's flatten then asked for more segments than memory holds: a
"capacity overflow" panic (seen in import_fuzz's ai_written_meshes_never_panic).
An outline wider or taller than 2^24 device pixels now goes to the per-quad
drawing path the function already falls back to.
A VP8 key frame stores its first partition's size in 19 bits (RFC 6386
section 9.1). The encoder writes 524,287 for a larger partition too, and
a decoder then reads the token partition from the wrong offset. A lossy
WebP whose size field is at that limit now fails with an error that
suggests a lower resolution or Lossless, instead of writing a file that
does not decode.
On a path or compound path, a Transform effect with copies listed after
the object's own Rasterize effect now places the one image Rasterize
makes of the art before it on the original and on each copy: copy k
through the effect's map applied k times, with its pixel grid and its
room around the art, the last copy lowest and the original on top.
Before, the Transform effect copied the art and Rasterize made one image
of all the copies on a grid square to the page.
The image is made once for every placement, also when a shadow or glow
is listed between the Rasterize and Transform effects. The canvas, the
object's bounds, Expand Appearance and PDF export use the same
placements; Expand Appearance and PDF export make a group of images that
share the one image's pixels. Copies stop where the copied art stops,
and a copy scaled to nothing is left out.
WebP Options has a Compression menu (Lossless, Lossy) and a Quality
slider from 0 to 100 that is enabled for Lossy. document.export,
document.serialize and Export for Screens take lossless: false with
quality (default 90) and write a VP8 file, with an ALPH chunk that keeps
the alpha exactly when some pixels are not opaque. Lossless stays the
default. A WebP quality above 100, or one that is not a whole number,
is refused with an error.
The encoder is the one craft-image-codecs already provides; no
dependency changes. The note that lossy WebP isn't available, its
catalog rows and the format text that described it are removed.
The export walks for type and fonts and the artboard crop shared one
SymbolBoxes for every object. A SymbolBoxes also holds measuring budgets
(effect reaches, 9-slice placements), so in a large document objects late
in a walk could be measured by estimates where main measured them exactly.
SymbolBoxes::unmeasured makes new boxes that share the name index, and each
object is measured in boxes of its own again.
- The live-object walk (render/src/live.rs) finds symbols through the
frame's SymbolBoxes.
- SVG export's filter regions measure each object in unmeasured boxes, and
the region boxes share the writer's index.
- SVG import keeps each imported symbol's index, so a symbol whose art
holds instances no longer scans or indexes the list again.
- Object › Rasterize's clipping mask is left as it is on main, with
drawn_outline_with removed.
- The symbol-read-count feature of vectorcraft-doc gives other crates'
tests vectorcraft_doc::symbols_read. New tests check that a frame, an SVG
export, a PDF export, the type walk and the artboard crop read the symbol
list once among 2,000 symbols and 300 instances with drop shadows.
Drawing or exporting a symbol instance looked its symbol up by scanning
the document's symbol list, so a document with many instances and many
symbols spent most of a frame or an export on name comparisons. The
renderer, the SVG and PDF writers and the export walks now find symbols
through SymbolBoxes::symbol, which builds the name index once per frame,
export or walk and returns the first symbol of a name as before.
- Renderer: plain instances, inline graphics, instances with object
effects (their art and the symbol budget) and the effect bounds.
- SVG export: instance art, symbol defs and their reuse check, and the
paint reach of filter regions.
- PDF export: instance art, inline graphics and the brush search of
knockout masks.
- Export warnings and artboard crops measured what each object paints
with new symbol boxes per object, which built the name index again for
every instance. painted_bounds_with and drawn_outline_with take the
boxes once; Object › Rasterize's clipping mask uses them too.
The canvas flattened a stroke's outline at 0.25 device pixels with chords
inside each curve, so a wide curved stroke's outer rim drew too light and
its inner rim too dark. A stroke at least 32 drawing tolerances wide now
draws each curve of its outline that spans 128 tolerances or more as lines
placed by its bend, with each line end moved outward by half the line's
bulge, so the lines lie on both sides of the curve. That is 8 and 32
device pixels at 25% and 1:1, and as little as just over 4 and 16 device
pixels at other zooms, where the cached outline's tolerance is the largest
power of two at or below a quarter device pixel.
At 25% zoom an 80 pt ring's worst edge pixel is 24 levels off the exact
coverage at the outer rim and 32 at the inner rim, where it was 54 and 61;
at 1:1 it is 30 and 29, where it was 64 and 58. Curve ends at corners,
lines and short curves stay on the curve. Outlines are cached per zoom
level as before, with refined and plain outlines kept apart.
Raster exports draw the same refined edges as the canvas. Fills, narrower
strokes, strokes with a width profile, strokes in an unevenly scaled view
and vector exports are unchanged.
Tests: render::tests::curvedstrokeedges and
longstroke::a_long_wide_curved_stroke_draws_the_same_pixels_outlined_near_the_view.
The decoding File › Open, Place and the renderer share moves to
vectorcraft-doc (decode.rs: decode_image, decoded_layout), and SVG
import's images read through it: the size from the header against the
allowance first, then the pixels as stored with the profile the file
embeds (a TIFF's still read by the TIFF reader).
decoded_pixels_are_those_the_image_crate_read compares PNG, GIF, WebP,
TIFF and BMP at each depth the image crate writes with its pixels, and
JPEG within two steps.
The raster path tells formats with craft-image-codecs' detect, reads the
size from the header (vectorcraft-doc's header_size, the renderer's
decoded_layout, a Targa's own header) and decodes with the renderer's
decode_image, the pixels as stored, with the profile the file embeds.
The size notes Open, Place and the Links panel give, and Glass's Load
Texture, read the same way.
opened_rasters_are_the_pixels_the_image_crate_read compares BMP, TGA and
TIFF at 8 and 16 bits, gray and color, with and without alpha, with the
image crate's pixels, and PNG, JPEG, GIF and WebP stored as they are.
The renderer's image paint reads sizes from the header (vectorcraft-doc's
header_size, craft-image-codecs' inspect_raster) and decodes through
craft-image-codecs, the pixels as stored, for the formats it drew
before (PNG, JPEG, GIF, WebP, TIFF and BMP). A test compares the pixels
with the image crate's for each PNG color type and depth, palettes and
1-bit gray, GIF, WebP, TIFF, BMP and JPEG.
The JPEG writer goes back to main's jpeg-encoder one: the craft-image-codecs
version wrote a CMYK JPEG's resolution in a little-endian EXIF of another
layout, failing the tests of main's #3084 fix. TIFF LZW strips stay on
craft-stream-codecs, checked against weezl (now a dev-dependency): read
back the same and never larger.
Outline views left out an Abutting trace's seam fills only while their
clip group kept the name "Seam Fills". Renamed, the group drew its
clipping box and, on a stretched image, the outlines of its filled
seam bands. The group is now also left out when it is still the lowest
traced shape, where the trace puts it.
The outline-view test samples inside the seam band beside the shared
edge on the stretched image, and checks that renaming the group leaves
the view unchanged.
A group's or layer's own Drop Shadow, glow, blur, Feather or pixel filter
listed before its last Transform effect that makes copies now goes with each
copy, made of all the copy's members together. Its sizes scale by the copy's
mean scale, and a Drop Shadow's offset turns, reflects and scales with the
copy. Before, one shadow was drawn around all the copies at the group's own
distances. A raster effect listed after the Transform effect still paints
once around all the copies, and the members' own raster effects stay as a
copying Transform effect leaves them.
Each copy is a group holding the members. A clip group's copies each clip,
a layer's art stays a layer, and its ruler guides stay once above the
copies. Compound shapes, Shaper groups and groups with Pathfinder, 3D, Crop
Marks, Vector Halftone, a painting plug-in, a perspective or fills and
strokes with geometry effects keep the earlier behavior.
The canvas, the object's bounds, baking for export (type in such a group is
no longer kept as type under one shadow), export with raster effects as
images and Expand Appearance draw the same copies. Expand Appearance gives
the copies ids of their own, expanding a copy with a random Transform effect
before its ids change so it keeps the canvas's random values.
A region whose edge falls inside a pixel no longer drops a slice that overlaps it, and no longer writes a slice that lies past it. The overlap is found in document coordinates, and only that part is converted to pixels.
The Cookie dictionary in a type layer's text engine data uses a key that
the format defines and that names a vendor product. The line now carries
a brand-ok comment, so cargo xtask brands passes.
A Drop Shadow, glow, blur, Feather or pixel filter listed before a fill's
or stroke's own Transform effect that makes copies is now drawn by each
copy from that copy's fill area or stroke outline, with its sizes scaled
by the copy's mean scale and a Drop Shadow's offset turned, reflected and
scaled with the copy. With Transform Patterns or Scale Strokes & Effects
on, the shadow is no longer scaled a second time. A raster effect listed
after the Transform effect paints once around all the copies, and with
either option on it stays on each copy as before.
Each copy of a path's own Transform effect that makes copies now carries
the raster effects of its fills and strokes the same way, for a single
fill, a single stroke, or several.
Before, one shadow was drawn around all the copies at the fill's or
stroke's own distances. The canvas, the object's bounds, export and
Expand Appearance draw the same copies, and copies that stop at the
effect budget each keep their effects. A fill or stroke whose effects
list raster effects before a Transform effect that makes copies and
another raster effect after it and before a later Transform effect that
makes copies or moves at random (for example Drop Shadow, Transform,
Drop Shadow, Transform) still paints its raster effects around all of
the copies.
A PSD export now writes image resource 1050 in version 6 of the PSD file
format specification's slices resource format, the form that Import
Slices reads (crates/engine/src/cmd/fileio/psdslices.rs, version_6).
Flat and layered exports both carry it.
- The user and object slices that reach into the exported artboard are
written, clipped to it in its pixels, at least one pixel each way.
Auto slices are left out; opening the file lays them out again.
- An object slice is written as a user slice over its object's bounds,
and an HTML Text slice as No Image with its type's text as HTML. Name,
type, link, target, message, alternative text, cell text and
background color are kept; text alignment is written as the default.
- Slice IDs count from 1.
- More than 10000 slices or a text longer than 65536 characters is an
export error, matching the reader's limits. A slice without finite
bounds, or slices that would make the resource longer than 4 GB, is
also an export error; the size is checked before each text is added.
A type layer records neither the language nor the composer, so point type
whose runs name another language, or whose paragraphs use a Standard
composer, is written as pixels. New type's default paragraph settings
(the every-line composer, Burasagari and Mojikumi) no longer keep it from
becoming a type layer; Mojikumi other than the default still does in type
with Chinese, Japanese or Korean characters.
On an image stretched more one way than another, a seam stroke was as
wide as 1.5 pixels at the larger scale, so across the less stretched
direction it reached far past its edge: on a 40 x 20 image scaled 20x
across, a stroke along a horizontal edge covered 15 pixels on each
side, over transparent rows too.
On such an image, the seam fills are now each stroke's outline in image
pixels (butt caps, round joins), filled with the stroke's paint. An
image scaled alike in every direction keeps strokes. The anchor limit
counts the outlines' anchors. Outline views and Expand by color
recognize a seam fills group of filled outlines as they do one of
strokes, and Expand by color again recognizes the unclipped seam fills
group of a trace made before the seam fills were clipped.
A Drop Shadow, glow, blur, Feather or pixel filter listed before a
Transform effect that makes copies of type, an image or a symbol instance
was drawn once under all the copies, at the object's own distances. Each
copy now carries those raster effects, as paths' copies do: scaled by the
copy's mean scale, with a Drop Shadow's offset turned, reflected and
scaled with the copy. Raster effects listed after the Transform effect
still paint once around all the copies.
Type is copied as its outlines, an image in its frame and a symbol
instance as its symbol's art. The canvas, the object's cull bounds,
export and Expand Appearance use the same art; type whose Transform
effect only moves its copies is exported as its outlines in that case.
Type and symbol instances in perspective, objects whose fill or stroke
has geometry effects of its own, and objects with a linked opacity mask
keep one set of raster effects.
A type layer now records the type's own anti-aliasing method (None,
Sharp, Crisp or Strong; None when the export draws without
anti-aliasing) instead of Smooth. Type with a character that its font
lacks, and so is drawn with a fallback font, stays pixels; breaks,
joiners and variation selectors do not count. Hidden type that the export
leaves out (Include Hidden Layers off) no longer splits its layer, and a
fill or stroke that blends in a mode other than Normal keeps the layer
whole like an object that does.
The reader test uses craft-psd, which replaced the psd crate on main.
The PSD Options dialog gets Preserve Text Editability, and document.export
takes preserveText (with layers). Horizontal and vertical point type is
written as a type layer (a TySh block with its EngineData) that a reader
can edit, and keeps its pixels. The layer holds the text, its fonts by
PostScript name, size, leading, tracking, scaling, baseline shift, caps,
underline, strikethrough, fill color, Fractional Widths, paragraph
alignment and orientation.
Type that a type layer would draw differently stays pixels: area type,
type on a path, strokes, non-solid fills, fractional tracking, character
attributes the layer does not carry, paragraphs that set more than their
alignment or run right to left, System Layout, Optical Margin Alignment,
ruby, effects, an appearance of its own and opacity masks. A layer that
holds type becomes a group of its type layers and pixel layers of the art
between them, unless other art in it blends in a mode other than Normal.
- Test files whose image→craft-image-codecs rewrites didn't compile against
main's newer tests go back to main's versions (engine fileio/tests.rs,
tests_tiffbmp.rs, tests/menucmds.rs, eps tests.rs); they still use the image
crate, which keeps its format features.
- craft_jxl::encode, craft_image_codecs::encode and Image::icc at d6cd7836d.
- jp2read and pdf export pass DecodeOptions, not Limits.
- EPS DCTDecode: grey JPEGs no longer use the image after moving it, and keep
main's one-channel output.
- svg keeps its direct usvg dependency for main's image href code; pdf keeps
jpeg-encoder for CMYK JPEGs.
- clippy -D warnings and rustfmt clean.
Conflicts resolved in favour of main/#7664 in the 13 source files both touched
(doc/cmyk.rs, metafile/dib.rs, pdf images, svg import/files.rs, render paint and
encode tests, trace, engine load.rs), keeping main's newer TIFF/CMYK, DIB and PDF
image fixes. vectorcraft-doc stays on main's version until its CMYK reader moves
to craft-tiff. The image crate keeps its format features, and usvg, tiff,
zune-jpeg, hayro-ccitt and jpeg-encoder stay for the readers not yet moved.
Codec crates pinned to craft-libs d6cd7836d364177661b0ae17f48a0805e83a5f32.
Also fixes the compile errors CodeRabbit flagged (jp2read DecodeOptions,
filters.rs use-after-move) and the encode() arity at d6cd7836d.
Port main's new variable-library parsing (variable kinds, image, visibility
and graph values) from roxmltree to craft-xml with the branch's strict
options and attribute validation. Keep both sides' variable tests.
Drop the stale docx::nesting doc link.