Skip to content

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

@houseoftag

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

  1. Save this as t.svg and open it (File › Open):
<svg xmlns="http://www.w3.org/2000/svg" width="612" height="792" viewBox="0 0 612 792">
<text x="50" y="100" font-family="Source Sans 3" font-size="7">HHHH Hamburg</text>
<g transform="scale(3)"><text x="16" y="60" font-family="Source Sans 3" font-size="7">HHHH Hamburg</text></g>
<text x="50" y="400" font-family="Source Sans 3" font-size="7" transform="scale(2)">HHHH Hamburg</text>
</svg>
  1. Select each text object and read the size in the Character panel.
  2. 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.

Found while testing VectorCraft with Claude Code.

Activity

  1. added 2 commits that reference this issue on Oct 8, 2026
    33f653c
    ffed92a
  2. bflatastic commented on Oct 8, 2026

    @bflatastic
    Member

    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.

    If it still looks wrong once this lands, please reopen this issue. If you're not on our Discord yet, come say hi: https://discord.gg/artcraft

  3. added a commit that references this issue on Oct 8, 2026
    2a43419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions