* SVG export: preserve document unit in viewBox and width/height (#864)
When exporting SVG documents with physical units (mm, cm, in, pc), emit
the physical unit suffix on the root <svg width=... height=...>
attributes while keeping viewBox numbers and inner coordinates in 1:1 points
per SVG 1.1 coords §7.10. This avoids the 75% scaling mismatch when opening
drawings in external tools such as Inkscape or LightBurn, and preserves
the document unit setting across save/open round trips. Unitless documents
(points, pixels) continue to emit unitless dimensions.
Tested via export_physical_units_writes_unit_suffixes in vectorcraft-svg
and full round-trip svg_round_trip_preserves_document_units in vectorcraft-engine.
Ran cargo xtask ci (fmt, clippy, tests, xtask gates).
* SVG export: preserve nonzero width and viewBox on extreme small dimensions
A transform no longer leaves locked guide paths in place: a guide in a
group moves with its group again, as on main. Keeping them put made
Align, Transform Each, the pixel-grid snap and Objects on Path measure or
place art the transform did not move. Scaling::keep_guides and its
engine wiring and test are removed.
The marquee rule now covers the rest of the selection side, while guides
are locked or hidden:
- the guide rule goes down the walk as an explicit Rules value instead
of a thread-local guard;
- an Enclosing Lasso loop does not take a compound path for its guide
contours;
- an enclosing marquee measures a group without its guide paths
(Node::without_guides);
- Direct Selection's marquee takes no anchor or crossed segment of a
guide path.
Docs: the Guides area row, its evidence entry and the M1 row describe
the marquee behaviour; status lines and revision rows say a guide in a
group still moves with it.
While guides were locked, a guide path inside a group was still touched by
a selection marquee, so the marquee selected the group and moving the
group moved the guide (#8538). Clicks already skip guides (#3074).
- hit: marquee_in_view and enclosure_candidates take skip_guides; the
Selection, Direct Selection, Group Selection and Enclosing Lasso tools
pass !cx.guides, and the marquee then touches no guide path at any depth.
- doc: Scaling::keep_guides leaves the guide paths among a group's,
layer's or Intertwine group's children in place, as a ruler guide in a
transformed layer already stays.
- engine: transforms (apply_transform), Transform Each and Align and
Distribute set it while Lock Guides is on; a copy takes a copy of the
guide with the copied art and leaves the original.
Fixes#8538
The writer passed no language to craft-pdf, so exported and printed
PDFs had no /Lang and accessibility checkers failed primary-language.
Writer::new now passes the BCP 47 tag of the Document Setup language
(new vectorcraft_doc::setup::language_tag, en-US by default) through
write::Writer::new_with_language, which writes the catalog's /Lang and
the XMP dc:language. A language with no tag writes none. /MarkInfo is
left for tagged PDF (#3643).
- `Unit::parse` keeps main's paragraph about units after `*` and `/` as it
was; the new `x` paragraph follows it, and the limit line names the
signs it counts again.
- `object.path.offsetPath` takes `"0.05x2 in"` (0.1 in), which it refused
before; `"0x10"` reads as 0 pt. docs/mcp.md states both.
A marquee across the shapes that the geometry effects of a symbol
instance's active fill or stroke paint outside its box now selects the
instance, as a click there does. An image is likewise touched where its
own fills and strokes paint outside its frame. Outline mode keeps the
box alone.
The Arrow Style dropdown in Dimension Tool Options and in the Properties
panel's Dimension section showed only the names Filled, Open, Tick and
None. Each style now shows its arrowhead at the end of a short line
before its name, in the open list and in the closed field, drawn with
the Stroke panel's arrowhead previews. The four styles and their saved
values are unchanged.
ArrowStyle::arrowhead holds the style-to-arrowhead mapping, so the
dimension line and the preview use the same head.
dropdown_icon_names_sized takes an icon size that is not square.
Part of #8049.
addon.units.convert reads its value through Unit::parse, so after the
merge of main it takes x, X and × as multiplication signs as well. Its
128-sign limit counted only + - * /. The new
vectorcraft_doc::arithmetic_signs counts each multiplication sign as a
*, and both Unit::parse and the converter use it.
- The converter's params text and docs/mcp.md list the signs.
- Tests cover 2pX3 and 2p×3 (6 picas), 8.5x11 in (refused before, now
93.5 in) and the converter's reading and limit.
- The test message says "millimeters", and the doc comments wrap at
the file's width.
DocState::proxy_mixed, which decides whether the Fill and Stroke proxies
show "?", walked every node of the document to find the selected
objects, even with one object selected. The Tools panel proxies, the
paint chips and the task bar ask for it on every frame whose revision
changed, which includes each frame of a drag preview, and new art asks
for it after a selection change.
Document::nodes_in_order finds every node with one of the given ids in
tree order. When the id cache holds each id once at a path that still
checks out, it reads the nodes along those paths; otherwise, and for a
selection of an eighth of the document or more, it walks the tree once,
as before. Unlike Document::index_paths it returns every node with a
repeated id, so a damaged file that repeats an id keeps the question
marks it had. proxy_mixed now gathers the selected objects through it.
Tests compare the result with a copy of the old walk for one object,
different fills and strokes, a group, a group with one of its objects,
two layers, a hidden object, Appearance items, picked gradient mesh
points beside another object, ids not in the document and a repeated id
with different paints, with the cache built and dropped, and for 200
random selections. A cost test shows that with one object selected only
that object is read and the tree is not walked. Document tests compare
nodes_in_order with a walk.
The gain shows on large documents. On 50,000 rectangles in 500 groups
on 5 layers (release build on Linux, thread CPU time, median of seven
alternating runs of both versions in one process; an ignored test,
proxy_mixed_timing, times them):
Selection old new
1 object 995 us under 5 us
2 objects, different fills 810 us under 5 us
a group of 100 875 us 5 us
all 500 groups 3,615 us 2,575 us
all 50,000 objects 4,075 us 3,470 us
Value fields and length strings read `x`, `X` and `×` as a
multiplication sign: `10x2` is 20, `2x3 mm` is 6 mm and `3cmx50%` is
1.5 cm. A lowercase `x` right after a `p` stays the `px` unit, so
`2px x 3` is 6 px and `2px3` is not read. The change is in
`Unit::parse` and `parse_number`, so every field that reads its text
through them takes it. Each sign counts toward the 128-sign limit,
which is checked before the text is copied.
Docs: docs/mcp.md, docs/ui-parity.md, docs/target-app-parity.md.
The Blend panel, the Object › Blend, Envelope Distort and Gradient Mesh
menu items and their commands looked up every ancestor of each selected
object by id to find its nearest blend, envelope or mesh, and dropped
repeats with a linear scan. They now read the object's cached place in
the tree once, test the nodes on that path, and keep a set of the ones
already listed. The checks of whether one is selected stop at the first
selected object that has one. An id that the lookup cache does not
place on that path (a repeated id, or a cache older than the tree) is
still looked up by id, so the results, their order and the errors are
the same. Explicit ids given to the live commands drop nested ones with
a set as well.
With Select All of 102,200 objects (100,000 rectangles, 2,000 blends and
200 envelopes), a release build took a median of 16.5 ms of thread CPU
time for the Blend check before and 0.5 ms after.
Each round of the repeated hit test that Select Behind uses in isolation
mode and in Edit Contents skipped the objects already found by searching
the found list, which made one Cmd/Ctrl-click cubic in the number of
objects under the point. A set beside the ordered list answers the same
lookups, so the objects and their order do not change.
A test compares the set lookup with the list lookup on random documents
for every object isolated in turn, and an ignored timing test measures
both on 200 and 1,000 stacked objects.
After an edit of a document with symbols, the refresh of inline graphics
walked every node of every layer. It now keeps the document the last
refresh left resolved, with the symbol bounds it measured, and checks
only the layer trees that are not the same nodes as that document's,
as long as the symbols, graph designs, pattern tiles and foreign data
(which holds the symbols' natural sizes and 9-slice guides) are the
same and each measured symbol still measures the same. Otherwise the
full pass runs, as before. Visit order is unchanged, so the document
and the ids of the texts laid out again equal the full pass's.
A line drawn with the Line Segment tool now shows Line Properties in the
Transform panel and the Properties panel's Transform section, with the two
properties the help page lists for a line:
https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-live-shapes/live-shape-properties.html
- object.setLiveShape takes lineLength (pt, above 0) and lineAngle
(degrees, brought into 0 to 360). Every selected line changes in one
undo step; a value that changes nothing records none.
- VectorCraft's own rules: the angle runs counterclockwise from 3 o'clock,
as the Rotate field does; a new length keeps the first end in place and
a new angle turns the line about its midpoint; a line whose ends meet
reads 0 degrees; the section shows only while every selected object is a
live line; a line that would reach past the coordinate limit is an error
that changes no line.
Docs: docs/mcp.md, docs/target-app-parity.md.
Add Used Colors and New Color Group link the selected art's paints to
global swatches through Document::map_solid_paints_in, which drops each
id that sits inside another listed id. It searched the whole id list for
each ancestor of each id, so the work grew with the square of the
selection. It now looks each ancestor up in a set of the ids, as
without_inner in crates/engine/src/cmd/edit.rs does. The roots keep the
order of the list, duplicates and ids missing from the document, so the
same paints are linked in the same order.
- mapping_within_ids_matches_a_search_of_the_ids compares the count, the
paints visited and the resulting document with the search for every
list of up to three ids from a nested tree (nested ids in both orders,
duplicates, a missing id and an empty list).
- crates/engine/examples/link_colors_bench.rs times both ways in one
process. With 20,000 selected rectangles the call takes 16 ms of CPU
time instead of 128 ms; with 2,000 it takes 1.4 ms instead of 2.5 ms.
The drawn-art store that main added for clicks now keeps its entries as
the shared Evaluated type, so a kept entry is also measured again when a
symbol's 9-slice guides or natural size change. Evaluated::new builds an
entry for both stores.
Type on a path sits at fractions of its path's length. Scaling the path
non-uniformly changes where a fraction lands (CodeRabbit's case: M0 0 L100 0
L100 100 under diag(2, 1) moves the start bracket from (200, 0) to (150, 0)).
Path type now bakes the vertical scale into the character sizes and scales
its path uniformly by it, which keeps every fraction where it was; the
horizontal stretch stays in the transform.