Fix SVG stroke-width import: style-parsed widths and element scale#66
Merged
Conversation
…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>
1 task
earlye
added a commit
that referenced
this pull request
Jun 23, 2026
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.
Summary
Bug 1:
loadBoundingBoxAttributeswas resettingmLineWidthto1.0whenever the directstroke-widthXML attribute was absent and the current value was< 1.0. This silently clobbered values already correctly parsed from the elementsstyleattribute (which has higher CSS priority than presentation attributes). Inkscape-exported SVGs nearly always putstroke-widthinstyle`, so this fired constantly.Bug 2:
BoxSvgAttributes::applywas multiplying the stroke width by the elements own transform scale factor at import time, then the same scale was re-applied at render time viafScaledTransform(double-scaling). For a path withtransform="scale(0.26458333)"(Inkscapes px-to-mm factor), the combined effect wasscale^2 = 0.07instead of0.26, making strokes ~4x too wide when both bugs are present.Also adds temporary debug logging under
QT_LOGGING_RULES=friction.svg.importand ajust run-debug-stroke-widthtarget that filters to those lines for verification.Test plan
just run-debug-stroke-width, import the same SVG, confirmrawWidthvalues match the SVGstroke-widthvalues andstrokeScale=1 (fixed)for all pathsstroke:none) are unaffectedstroke-widthas a direct XML attribute (not instyle) are unaffected🤖 Generated with Claude Code