You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: SVG import: text under a transform or viewBox scale shows its SVG font-size in the Character panel but draws at a different size #396
Description
When an SVG's text sits under a scale (a transform on the <text>, a transform on a parent <g>, or a viewBox that differs from width/height), the imported text keeps the SVG's nominal font-size as its size and carries the scale in the object's transform. The Character panel then shows that nominal size, but the text draws at size × scale. Two objects can both read 7 pt and look very different, and setting 7 pt again changes nothing.
In Illustrator the drawn size always matches the size the Character panel shows, and SVG text under a scale opens with the scale applied to its size (unverified on this exact file).
Steps to reproduce
Save this as t.svg and open it (File › Open):
<svgxmlns="http://www.w3.org/2000/svg"width="612"height="792"viewBox="0 0 612 792">
<textx="50"y="100"font-family="Source Sans 3"font-size="7">HHHH Hamburg</text>
<gtransform="scale(3)"><textx="16"y="60"font-family="Source Sans 3"font-size="7">HHHH Hamburg</text></g>
<textx="50"y="400"font-family="Source Sans 3"font-size="7"transform="scale(2)">HHHH Hamburg</text>
</svg>
Select each text object and read the size in the Character panel.
Optional: the same text in a file whose viewBox is twice its size, e.g. width="306" height="396" viewBox="0 0 612 792".
Actual result
All objects show 7 pt, but they draw at different sizes. Measured with text.getRange (run size) and document.inspect (drawn bounds height):
Text
Run size
Drawn height
Drawn size
No transform
7
9.28
7 pt
Inside <g transform="scale(3)">
7
27.85
21 pt
Own transform="scale(2)"
7
18.56
14 pt
viewBox 612×792 at 306×396
7
4.64
3.5 pt
Expected result
The Character panel shows the size the text draws at (21 pt, 14 pt, 3.5 pt), and setting 7 pt makes all of them draw at the same 7 pt. A uniform scale could be folded into the run sizes on import; a non-uniform one into horizontal and vertical scale.
Where it comes from
crates/svg/src/import/text.rs:369-370 copies the nominal font-size into CharStyle.size, and the scale stays in the object's xf (assignments at lines 586, 606 and 611).
The renderer draws text with view * xf (crates/render/src/lib.rs:1208), so the drawn size is CharStyle.size × the scale in xf.
The Character panel (crates/ui-egui/src/panels/character.rs:258) shows and writes CharStyle.size as is; crates/engine/src/cmd/textedit.rs:199 stores it without the xf factor.
The same mismatch follows any scale that lands in a text object's xf: the Scale tool, Free Transform, Object › Transform › Scale, the W/H fields, and Selection-tool handle drags on point type (Fix #252: area type resizes its frame with the mouse #289 fixed area-type handle drags only). Fixing it in the panel (show and set the effective size) would cover all of these; fixing it in the importer covers SVG only.
Text made with the Type tool is not affected: a click and a drag both draw 7 pt at 7 pt.
Environment
VectorCraft 0.4.0 on macOS. The SVG text importer, text.rs and character.rs show no related changes between v0.4.0 and main.
Thanks for the detailed report and the measurements, @houseoftag! This should be fixed by #408.
Size: SVG text under a transform or viewBox scale now opens with that scale folded into its size, so the Character panel shows the size it draws at: 7 / 21 / 14 pt in your file, and 3.5 pt in the half-size viewBox variant. Leading, baseline shift and character strokes scale with it.
Other transforms: any stretch, skew, rotation or reflection that can't become a size stays as the object's transform.
Round trips: SVG export then import keeps the sizes.
Not covered yet: point type scaled inside the app (Scale tool, bounding box) still keeps its scale in the transform. That's the wider form you pointed out, and it's next on the list.
Description
When an SVG's text sits under a scale (a
transformon the<text>, atransformon a parent<g>, or aviewBoxthat differs fromwidth/height), the imported text keeps the SVG's nominalfont-sizeas its size and carries the scale in the object's transform. The Character panel then shows that nominal size, but the text draws at size × scale. Two objects can both read 7 pt and look very different, and setting 7 pt again changes nothing.In Illustrator the drawn size always matches the size the Character panel shows, and SVG text under a scale opens with the scale applied to its size (unverified on this exact file).
Steps to reproduce
t.svgand open it (File › Open):viewBoxis twice its size, e.g.width="306" height="396" viewBox="0 0 612 792".Actual result
All objects show 7 pt, but they draw at different sizes. Measured with
text.getRange(run size) anddocument.inspect(drawn bounds height):<g transform="scale(3)">transform="scale(2)"Expected result
The Character panel shows the size the text draws at (21 pt, 14 pt, 3.5 pt), and setting 7 pt makes all of them draw at the same 7 pt. A uniform scale could be folded into the run sizes on import; a non-uniform one into horizontal and vertical scale.
Where it comes from
crates/svg/src/import/text.rs:369-370copies the nominalfont-sizeintoCharStyle.size, and the scale stays in the object'sxf(assignments at lines 586, 606 and 611).view * xf(crates/render/src/lib.rs:1208), so the drawn size isCharStyle.size× the scale inxf.crates/ui-egui/src/panels/character.rs:258) shows and writesCharStyle.sizeas is;crates/engine/src/cmd/textedit.rs:199stores it without thexffactor.xf: the Scale tool, Free Transform, Object › Transform › Scale, the W/H fields, and Selection-tool handle drags on point type (Fix #252: area type resizes its frame with the mouse #289 fixed area-type handle drags only). Fixing it in the panel (show and set the effective size) would cover all of these; fixing it in the importer covers SVG only.Environment
text.rsandcharacter.rsshow no related changes between v0.4.0 andmain.Found while testing VectorCraft with Claude Code.