Repository navigation
M4: SVG import units and text fidelity (M4.18, M4.19) - #65
Merged
Merged
Conversation
…px map 1:1 to pt, document units follow the file A pixel (and a unitless user unit) is a point and absolute lengths convert at 72 pt per inch (`font-size="12pt"` is 12 pt, `1in` is 72 pt); a root size in absolute units keeps the physical size main already gave it (`210mm` opens as a 595.28 pt artboard, user units being CSS pixels of it). The document's units follow the unit of the root width (pixels when it has none). Text font sizes honour their units (em/ex/% relative to the parent size, CSS size keywords), as do text positions, letter spacing, stroke widths and dashes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd mask; textPath, per-character positions, weights, spacing, paints and CSS selectors survive Each <text> is swapped for a placeholder group before usvg runs, so the text keeps its z-order, parent group, clip, mask, opacity, link and <use> instances, and usvg resolves its gradient and pattern paints (in text space). <textPath> becomes type on a path (startOffset, side, anchor), vertical writing-mode type on a vertical path. Per-character x/y/dx/dy/rotate lists become line breaks (bounded), kerning (absolute x measured against the layout), baseline shift and rotation; baseline-shift, numeric and relative weights (style names), letter/word spacing, kerning and the character stroke's cap, join, miter and dashes are kept. The style cascade supports type, #id, multiple-class, attribute, descendant and child selectors with !important and specificity. <pattern> paints become pattern swatches. The import fuzz covers the new attributes and CSS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of M4 (Files). SVG import keeps physical units and text fidelity: text stays in its place in the stacking order with its group, clip, mask and paints, and
<textPath>, per-character positions, weights, spacing and CSS selectors survive. This ports an earlier session's work onto currentmainand reconciles it with #6, #8, #11 and the M3 import additions.12ptis 12 pt,1inis 72 pt). Unitless 100 stays 100.210mm→ 595.28 pt), with CSS-px user units.width(Pixels without one).<text>is swapped for a placeholder before parsing, so it keeps its z-order, parent group, clip, mask, opacity,<use>instances and<a href>link.<textPath>honoursstartOffset,sideand the text anchor (this replaces SVG import: <textPath> comes back as type on a path #6's simpler version). Verticalwriting-modebecomes type on a vertical path.x/y/dx/dy/rotatebecome line breaks, kerning, baseline shift and rotation. SVG import: tspan line breaks follow the baseline gap (none on the same baseline, bounded far gaps) #8's cap on line breaks is kept, and far-off values stay finite.baseline-shift, numeric weights mapped to style names, letter and word spacing,kerning, and the character-stroke options are kept.#id, several classes, attribute, descendant and child selectors, with!importantand specificity.<pattern>imports as a pattern swatch.Known limits (documented in
svg/src/lib.rs):Checks
Rebased onto
39ce7b0(#30).cargo xtask cipasses all 7 steps (fmt, clippy, test, assets, brands, layers, wasm).svg/tests/import_units.rsandimport_text.rs, covering the spec's cases plus links, strokes, siblings and finite positions. The import fuzz test gains the new attributes and a hostile-CSS property test.mainstill exists (1,913 → 1,942);UI_COMMANDSand MCP tools are unchanged.svg/tests/roundtrip.rs:import_clip_mask_and_warningsnow checks a pattern swatch is imported instead of a "pattern not supported" warning.import_tspan_on_the_same_baseline_stays_on_the_linechecks the red run's exact position, since "world" now sits at its exact x.🤖 Generated with Claude Code