SVG export: type is laid out once for its live, on-path, outline and character-stroke writers

SVG export lays out each type object once and hands that layout to the
writer for live text, type on a path, outlines and inside or outside
character strokes, where each of them laid the same type out again.
Type on a path, bidirectional type and type that falls back to
outlines go from two layouts to one; inside or outside character
strokes and the object's own fills go from up to four to one. The
outline and character-stroke writers also group glyphs by run in one
pass instead of filtering every glyph for each run. The written SVG,
warnings and notes are unchanged.

A test compares the export with each writer laying the type out on
its own over 17 kinds of type and checks the layout counts; an ignored
test times a large document.
This commit is contained in:
dotCooCoo
2026-11-17 15:37:54 -08:00
parent ee60c51fd9
commit 1aef05110b
3 changed files with 292 additions and 47 deletions
+1
View File
@@ -1973,6 +1973,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
`.ai` and EPS editing-data import reads a text document whose keys are written by name, as files saved for version 11 write them, and the keys that later files write by name among the numbered ones (a font record's version, a paragraph's direction). The type of such a file comes from its text document, so type outside the artboards opens and each text object keeps its own story A run that names its paragraph or character style by the style's number takes that style (`a_text_document_with_named_keys_gives_type_off_the_page_too`, `a_text_document_with_named_keys_takes_a_runs_style_by_its_number`, `crates/eps/src/import/ate/names.rs`).
In SVG export without Fewer `<tspan>` Elements, each character of live type that justification or Mojikumi moves (the letter gaps of a Justify All line without word spaces, the gaps between the characters of a justified Japanese line, closed-up punctuation, the space between Japanese and Latin letters) starts its own positioned `<tspan>`, and type scaled horizontally on a justified line is stretched to its own width (`crates/svg/tests/it/text_layout.rs`).
To find those characters, SVG export lays a type object out a second time only when the second layout can differ from the first: point type with Line-end Punctuation Half Width and no Japanese punctuation or letters, the setting new type gets, is laid out once. Exporting 5,000 such objects takes a median of 109.4 ms instead of 171.5 ms on Windows 11, with the same SVG (`crates/svg/src/export/text/tests.rs`).
SVG export lays each type object out once and draws that layout in all of its writers (live text, type on a path, outlines, and inside or outside character strokes), and groups the glyphs of type written as outlines or with such strokes by run in one pass, with the same SVG. Exporting 1,000 objects of type on a path, 1,000 of bidirectional type and 300 with an outside character stroke lays type out 2,300 times instead of 4,900 and takes a median of 665 ms of CPU time instead of 893 ms over seven runs each, alternating, on Linux; grouping the glyphs of 300 texts of 1,000 runs by run takes 10 ms instead of 190 ms (`crates/svg/src/export/text/tests.rs`).
SVG export (live text), legacy `.ai` saves (text objects), DXF export (`TEXT` entities) and the CSS Properties panel write area type that Shrink Text to Fit scales down at the size it draws at, and scale its tracking, kerning, leading and baseline shifts the same way where the format holds them.
Legacy `.ai` saves (version 7) write type with rotated characters (Character Rotation, Touch Type turns) as its outlines, with a warning that it is no longer editable text (unless `outlineText` already asks for every type object as outlines): a version 7 text object has no character rotation ([Adobe Illustrator File Format Specification 7.0](https://www.nationalarchives.gov.uk/PRONOM/fmt/423), §15), and the outlines keep each character's rotation, baseline shift and scale (`legacy_ai::tests::type_with_rotated_characters_is_outlines_that_keep_the_rotation`).
Legacy `.ai` type keeps its manual kerning pairs (`Tk`, `TK`), its discretionary hyphens (`T+`, `T-`) as soft hyphens and its hyphenation language (`XL`) when it opens, and legacy `.ai` saves write manual kerning as `Tk` and soft hyphens as `T+` ([file format specification, version 7](https://web.archive.org/web/20050126105313/https://partners.adobe.com/public/developer/en/illustrator/sdk/AI7FileFormat.pdf), §15.4.6.1, §15.4.10.1 and §22.6). A file whose type sets a line breaking value (`TG`) or Japanese layout rules (`Xu`, `Tu`), which VectorCraft doesn't keep, opens with a warning for each (`import::ai::tests::legacy_manual_pair_kerning_is_kept`, `legacy_line_breaking_and_japanese_layout_rules_are_warned_once`, `legacy_ai::tests::manual_kerning_and_soft_hyphens_are_written_and_read_back`).