Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
SVG width not rendering correctly #901
I'm not sure this is a bug.
I use images in my document with the regular
The parent tag has a width set to
All the non-SVG images are rendering correctly:
All the SVGs are not:
They are tiny.
I can manually set a width on the images, and that seems to do a good job. However, it's not ideal because of the aspect ratio (taller images are breaking the layout).
Usually, this is a rendering engine specific issue, and several workarounds can be applied. However, I'm not sure what rendering engine is in place here, so I don't know how I can go about debugging it.
Here it is:
The size of your SVG is not defined, that's why this problem appears. You can add
I have to check the spec about that, because the 3 main web renderers increase the size of "sizeless" SVG files, just as if they had a
No problem, I often add technical stuff and specification quotes in comments so that I can remember what I've understood and done after a few months, when new related bugs are reported
From CSS 2.1 (10.3.2):
It means that this use case is undefined, but there's a "suggestion". Browsers actually follow this suggestion. WeasyPrint didn't, because I had found a better solution (as I'm really smarter than those spec nerds, you know).
I was wrong. Of course. And it's not the first time. At all.
I've blindly followed what's in the spec, and the result is now the same as what browsers do. Surprise.
Note that when an image with no intrinsic size is included in a block whose size depends on the children sizes (for example, an SVG
Thanks for the detailed write-up.
<img src="XXX.png" />
<img src="XXX.svg" />
I'm not using inline SVGs (for now).