Skip to content

Fix SVG stroke-width import: style-parsed widths and element scale#66

Merged
earlye merged 2 commits into
mainfrom
stroke-width
Jun 22, 2026
Merged

Fix SVG stroke-width import: style-parsed widths and element scale#66
earlye merged 2 commits into
mainfrom
stroke-width

Conversation

@earlye

@earlye earlye commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bug 1: loadBoundingBoxAttributes was resetting mLineWidth to 1.0 whenever the direct stroke-width XML attribute was absent and the current value was < 1.0. This silently clobbered values already correctly parsed from the elements styleattribute (which has higher CSS priority than presentation attributes). Inkscape-exported SVGs nearly always putstroke-widthinstyle`, so this fired constantly.

  • Bug 2: BoxSvgAttributes::apply was multiplying the stroke width by the elements own transform scale factor at import time, then the same scale was re-applied at render time via fScaledTransform(double-scaling). For a path withtransform="scale(0.26458333)" (Inkscapes px-to-mm factor), the combined effect was scale^2 = 0.07 instead of 0.26, making strokes ~4x too wide when both bugs are present.

  • Also adds temporary debug logging under QT_LOGGING_RULES=friction.svg.import and a just run-debug-stroke-width target that filters to those lines for verification.

Test plan

  • Import a character SVG from slime-at-school; check that stroke widths on scaled paths now visually match Inkscape at equivalent zoom
  • Run just run-debug-stroke-width, import the same SVG, confirm rawWidth values match the SVG stroke-width values and strokeScale=1 (fixed) for all paths
  • Verify paths with no stroke (stroke:none) are unaffected
  • Verify paths with stroke-width as a direct XML attribute (not in style) are unaffected

🤖 Generated with Claude Code

earlye and others added 2 commits June 22, 2026 10:51
…e-apply element scale

Two bugs in BoxSvgAttributes::loadBoundingBoxAttributes caused imported
stroke widths to be ~4x too wide for paths where stroke-width lives in
the style attribute and the element has its own scale transform (common
in Inkscape-exported SVGs).

Bug 1 (svgimporter.cpp:1504): the direct-attribute fallback block reset
mLineWidth to 1.0 whenever it was < 1.0 and the direct stroke-width
attribute was absent - silently clobbering the value already parsed from
the style attribute.

Bug 2 (svgimporter.cpp:1652): the element's own transform scale was
baked into the stored stroke width at import time, then the same scale
was applied again via fScaledTransform at render time (double-scaling).

Also adds temporary debug logging (QT_LOGGING_RULES=friction.svg.import)
and a just run-debug-stroke-width target that filters to those messages
to aid in verifying the fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@earlye earlye merged commit 9d49718 into main Jun 22, 2026
3 of 4 checks passed
@earlye earlye deleted the stroke-width branch June 22, 2026 15:58
earlye added a commit that referenced this pull request Jun 23, 2026
Document kind:animation-follower SVG desc annotation (PR #65), the
SVG stroke-width import bug fix (PR #66), and the Justfile fix.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant