Merge pull request #7715 from dotCooCoo/fix/svg-open-path-type-before-start

Type on a path: type on an open path can start before the path
This commit is contained in:
BFlat
2026-11-15 10:46:42 +07:00
committed by GitHub
35 changed files with 652 additions and 55 deletions
+19 -8
View File
@@ -9750,7 +9750,9 @@ neighbors, the kerning of the two characters keeps it and the characters after i
wider or narrower character moves the characters after it by the change in its width. Touch Type gives the character
before it a kerning value of its own (with `dx`, and with any other change where the font kerned the character with
its neighbors), and that character can then move by the font's kerning pair with the one before
it, as with any style change to one character (`text.setRangeStyle`). The type stays editable.
it, as with any style change to one character (`text.setRangeStyle`). The type stays editable. The characters of type
on an open path that are not drawn because they fall before the path's start cannot be selected with the tool, and
`text.touchType` returns an error for them.
```json
{"name":"run_command","arguments":{"command":"text.touchType","params":{"id":7,"start":1,"dx":10,"dy":4}}}
@@ -9840,9 +9842,10 @@ same in any language. Saved documents keep what they say, and imported text (PDF
Type on a path flows between a start and an end bracket, stored as fractions of its path's length.
`type.pathOptions {start?, end?, flip?, effect?, alignToPath?, spacing?, ids?}` sets them and the rest of Type on a
Path Options: `end: null` puts the end bracket back at the end of the path (or once round a closed one); `flip`
then turns the type to the other side of its path, the path running the other way and the brackets swapping ends so
the type keeps its stretch of the path; `alignToPath` runs the `ascender`, `descender`, `center` or `baseline` (the
Path Options: `end: null` puts the end bracket back at the end of the path (or once round a closed one); on an open
path a `start` below 0 starts the text that far before the path's start (on a closed path it is the path's start);
`flip` then turns the type to the other side of its path, the path running the other way and the brackets swapping
ends so the type keeps its stretch of the path; `alignToPath` runs the `ascender`, `descender`, `center` or `baseline` (the
default) along the path, each character by its own font, size and vertical scale: `ascender` runs the top of the
font's em box along it (its ideographic em box, else an em box centered on the cap height), `descender` runs the
bottom of the font's bounding box along it, and `center` runs a line at half the height of the top of the font's H
@@ -9855,6 +9858,13 @@ show selected type on a path's brackets: dragging the start or end bracket (`poi
begins or ends, dragging the centre bracket slides the type along its path and, dragged across the path, flips it
(with Cmd/Ctrl held it only slides). Each is one undo step.
Type on an open path that starts before the path's start keeps every character, and the characters whose middle falls
before the path's start are not drawn. A `flip` starts it at the start bracket, and dragging the center bracket slides
it from where it starts and no further before the path. Past the path's end, text that does not fit is overflow, as
for other type on a path. SVG import reads a `<textPath>` anchored or offset before an open path's start this way, and
SVG export writes it as a negative `startOffset`. Releasing it to point type keeps the first drawn character where it
was drawn.
```json
{"name":"run_command","arguments":{"command":"type.pathOptions","params":{"start":0.25,"end":0.75,"flip":true}}}
```
@@ -12219,10 +12229,11 @@ VectorCraft addition and changes no parity score.
the path's fill and stroke), so the released path has no fill and no stroke.
- **The text** keeps its runs with their character attributes and its paragraph attributes, and becomes point type on
one straight line along the object's own axis, with the baseline starting where the first character sat on the path
(type with no characters starts at its start bracket). Type on a Path Options (effect, align to path, spacing, flip,
brackets) don't apply to point type and are dropped. Type with Dynamic Text on (`type.dynamicText`) becomes point
type with it off, at the sizes it was drawn at: each size, leading and baseline shift is multiplied by the fit factor.
Without `keepOriginal` the type object itself becomes the point
(type with no characters starts at its start bracket; type that starts before an open path's start keeps its first
drawn character where it was drawn, with the characters that were not drawn before it). Type on a Path Options
(effect, align to path, spacing, flip, brackets) don't apply to point type and are dropped. Type with Dynamic Text
on (`type.dynamicText`) becomes point type with it off, at the sizes it was drawn at: each size, leading and
baseline shift is multiplied by the fit factor. Without `keepOriginal` the type object itself becomes the point
type, keeping its id, so a frame of threaded text leaves its thread with the text it holds, as
`type.convertToPointType` does for area type.
- It acts on the type on a path among `ids` (or `id`, else the selection), groups included; other objects are left
+2 -1
View File
@@ -1739,7 +1739,8 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
SVG import's style cascade, used for hidden objects, non-scaling strokes and type, tests each element only against the `<style>` rules for its id, its classes and its element name, and the rules whose selector ends in none of these (`*`, `[x]`).
SVG import places right-to-left point type and type on a path as [SVG 2's `text-anchor`](https://www.w3.org/TR/SVG2/text.html#TextAnchoringProperties) says: with `direction: rtl`, `start` puts the right edge of the text at its position (on a path, the text ends at `startOffset`) and `end` puts the left edge there. Each line and each absolutely placed chunk is anchored by the `text-anchor` and `direction` of the element holding its first character, a `<tspan>`'s own included, and each line starts at its own `x`. An absolutely placed chunk is anchored by the left and right edges of its glyphs as they are drawn, so a chunk of several right-to-left characters, whose first character is drawn at its right, sits on its anchor too. A letter-spaced right-to-left line keeps the tracking of all its letters inside the advance it anchors (`rtl_point_text_start_and_end_use_directional_edges`, `rtl_type_on_a_path_starts_at_its_directional_edge`, `rtl_letter_spaced_lines_stay_on_their_anchor`, `rtl_lines_use_each_chunk_first_character_direction_and_anchor`, `each_line_starts_at_its_own_x`, `absolutely_placed_chunks_use_their_own_rtl_anchor` and `absolutely_placed_rtl_chunks_of_several_characters_anchor_by_their_visual_edges` in `crates/svg/tests/it/import_text.rs`).
SVG import puts each absolutely placed character of right-to-left text on its own `x`, as [SVG 1.1's text chunks](https://www.w3.org/TR/SVG11/text.html#TextLayoutIntroduction) require, also when the characters run right to left on a later line: in `<text direction="rtl" font-size="20">`, `<tspan x="100 160" y="80 80">אב</tspan>` after a first line puts the right edges of `א` and `ב` at 100 and 160, where import put the right edge of `א` at 393.48 before. Chunks that overlap keep their own anchors, and characters stretched by `lengthAdjust="spacingAndGlyphs"` land on their `x` too. A left-to-right character drawn between two absolutely placed right-to-left characters leaves the one after it where the line puts it, and the import warns about it (`absolutely_placed_right_to_left_characters_sit_on_their_own_x` in `crates/svg/tests/it/import_text.rs`).
SVG import places type on a path of one closed subpath as [SVG 2's `startOffset` attribute](https://www.w3.org/TR/SVG2/text.html#TextPathElementStartOffsetAttribute) describes: text anchored to start before the path's start point, or offset past its end, wraps around the path, so text with `text-anchor="end"` at `startOffset` 0 ends at the start point, and a negative `startOffset` counts back from the end. Text longer than the loop draws its first characters whatever its anchor. A path of several subpaths, and an open path, still start the text at the path's start or end (`text_on_a_closed_path_wraps_past_the_path_start` in `crates/svg/tests/it/import_text.rs`).
SVG import places type on a path of one closed subpath as [SVG 2's `startOffset` attribute](https://www.w3.org/TR/SVG2/text.html#TextPathElementStartOffsetAttribute) describes: text anchored to start before the path's start point, or offset past its end, wraps around the path, so text with `text-anchor="end"` at `startOffset` 0 ends at the start point, and a negative `startOffset` counts back from the end. Text longer than the loop draws its first characters whatever its anchor. A path of several closed subpaths still starts the text at the path's start or end (`text_on_a_closed_path_wraps_past_the_path_start` in `crates/svg/tests/it/import_text.rs`).
Type on an open path can start before the path's start (`type.pathOptions` `start` below 0), and the characters whose middle falls before the path's start are not drawn, as [SVG 2's text on a path layout](https://www.w3.org/TR/SVG2/text.html#TextLayoutPath) describes for the path's start; past the path's end, text that does not fit is overflow, as for other type on a path. The text keeps every character, and the start bracket stays at the path's start. SVG import reads text anchored or offset before an open path's start this way instead of starting it at the path's start, and SVG export writes it with a negative `startOffset`. PDF export writes only the characters drawn on the path, the legacy `.ai` and `.ai` editing data writers write the type from the path's start with a warning, and Release Type on a Path keeps the first drawn character where it was drawn (`type_on_an_open_path_starts_before_the_path` in `crates/doc/src/text/tests.rs`, `on_path_open_start_before_the_path_hides_the_glyphs_before_it` in `crates/text/src/tests.rs`, `text_on_an_open_path_starts_before_the_path` in `crates/svg/tests/it/import_text.rs`, `text_on_an_open_path_starting_before_it_round_trips` in `crates/svg/tests/it/roundtrip.rs`, `options_start_type_before_an_open_path` in `crates/engine/src/tests/pathtype.rs`).
SVG import reads the bidi embedding of a `<tspan>`, `<textPath>` or `<a>` inside a `<text>` as [SVG 1.1's bidi section](https://www.w3.org/TR/SVG11/text.html#RelationshipWithBi-directionality) describes: with `unicode-bidi: embed` its characters take its `direction` as their Character Direction, an element with `normal` stays in its parent's embedding, and the `<text>` keeps its own paragraph direction, so a run that SVG export writes with `direction` and `unicode-bidi="embed"` opens with its Character Direction again. Character Direction holds one level of embedding, so `bidi-override`, `isolate` and `isolate-override` are imported as embeddings in their `direction`, `plaintext` as an embedding in the direction of its first strong character, and an embedding inside another as an embedding of its own, each with an import warning. With `unicode-bidi: plaintext` on the `<text>`, each of its paragraphs runs, and each chunk is anchored, in the direction of its first strong character (`a_tspan_bidi_embedding_becomes_its_character_direction`, `unicode_bidi_is_not_inherited_and_reads_from_the_cascade` and `unicode_bidi_values_the_text_model_cannot_hold_are_reported` in `crates/svg/tests/it/import_text.rs`; `character_direction_reads_back` in `crates/svg/tests/it/text_layout.rs`).
A `.svgz` file copied in a file manager pastes as its art, as a copied `.svg` file does.
SVG export (Save As, Export As, Export for Screens, Asset Export and the clipboard share the writer) writes simple shapes as SVG basic shapes, as the reference app does (an ellipse is an `ellipse` tag until an anchor is added, [forum](https://community.adobe.com/t5/illustrator-discussions/trouble-exporting-shape-with-points-to-svg/td-p/10720325); rectangles come out as `<rect>` and `<polygon>`, [forum](https://community.adobe.com/t5/illustrator-discussions/force-svg-export-using-all-lt-rect-gt/td-p/11282378)): an axis-aligned rectangle as `<rect>`, a circle or ellipse drawn with four standard arcs as `<circle>`/`<ellipse>`, a straight line as `<line>`, and other straight-segment paths as `<polygon>`/`<polyline>`, at the written precision (#4652). A rectangle or ellipse with a dashed stroke, whose dashes would start elsewhere, a turned ellipse, curves and compound paths stay `<path>`. `crates/svg/tests/it/basic_shapes.rs` checks each element, that the picture renders as the canvas does and that the geometry reimports.