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
<svg width> fails to scale contents to inferred height #41273
changed the title [-]<svg width> does not infer height from viewBox aspect ratio[/-][+]<svg width> fails to scale contents to inferred height[/+]on Dec 15, 2025
We give the SVG document to resvg that determines that the size is 10x300, and everything we see comes from this.
This slide deck shows that not everybody agrees on what should happen in such cases.
I am working on a patch to resvg implementing "the Firefox way", which makes sense to me, but I'm not super confident it will get approved especially if the standard does not give a definite answer on what to do in such cases.
We will see where it gets... (I hope it gets approved because the alternative is for us to patch the SVG XML document before giving it to resvg, and I don't really want to do that ;-))
Activity
delan commentedon Dec 15, 2025
this shows that Servo is inferring height as expected, but failing to scale the contents:
data:text/html,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="300" style="border: 1px solid;"><circle id="myCircle" cx="5" cy="5" r="4"/>[-]<svg width> does not infer height from viewBox aspect ratio[/-][+]<svg width> fails to scale contents to inferred height[/+]simartin commentedon Dec 20, 2025
FWIW, it seems to be happening only if only one of
heightandwidthis specified; when both are, scaling seems to be happeningThis is with
data:text/html,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="300" height="300" style="border: 1px solid;"><circle id="myCircle" cx="5" cy="5" r="4.8"/>simartin commentedon Mar 17, 2026
@servo-highfive assign me
servo-highfive commentedon Mar 17, 2026
Hey @simartin! Thanks for your interest in working on this issue. It's now assigned to you!
delan commentedon Mar 18, 2026
@Loirooriol was this fixed by #42577 (#42573)?
delan commentedon Mar 18, 2026
ahh, i think they are actually unrelated, never mind. height vs width, and SVG contents vs replaced box.
5 remaining items
simartin commentedon May 5, 2026
We give the SVG document to resvg that determines that the size is 10x300, and everything we see comes from this.
This slide deck shows that not everybody agrees on what should happen in such cases.
I am working on a patch to resvg implementing "the Firefox way", which makes sense to me, but I'm not super confident it will get approved especially if the standard does not give a definite answer on what to do in such cases.
We will see where it gets... (I hope it gets approved because the alternative is for us to patch the SVG XML document before giving it to resvg, and I don't really want to do that ;-))
simartin commentedon May 5, 2026
It looks pretty good with resvg patched locally (top is Servo, middle Firefox and bottom Chrome), so I'll go submit this patch 🤞
simartin commentedon May 5, 2026
Funnily enough, my patch looks a lot like linebender/resvg#715, that seems to have disappeared since 🙃 Will figure out what happned and update here...
EDIT: The code is still there, we just need it in some other place. Which increases the likelihood the patch is accepted.
usvg/parser: fix width/height computation when only one is specified
usvg/parser: fix width/height computation when only one is specified
Update resvg from 0.45 to 0.47
simartin commentedon May 6, 2026
This will be unfortunately blocked on a resvg upgrade, itself blocked on the minimum support rust version (see #43204 (comment))
Update resvg from 0.45 to 0.47
Add tests for servo#41273
TimvdLippe commentedon May 10, 2026
Resvg has now been updated
Add tests for servo#41273
simartin commentedon Aug 1, 2026
linebender/resvg#1045 has been merged today so this ticket will be fixed when the resvg folks do their next release and we integrate it.
atouchet commentedon Aug 3, 2026
I think this is fixed now with the resvg update in #46937.
simartin commentedon Aug 3, 2026
Yes indeed, this is fixed now 🎉
The ticket can be closed (I don't have the permissions to do it myself...)