Open tmbb opened 1 week ago
I can't really reproduce it, I just tried your example with main (v0.44) and those are the values I'm getting:
rect-1,26.667,26.667,1.778,1.778
those are the values before v0.42:
20,20,1.333,1.333
I'm pretty sure the reason for the change in behavior is that usvg
now also flattens the viewBox
, meaning that the bounding box includes the transforms that is applied to account for the view box. If I remove the viewBox, I get the same values as before.
Which units should these numbers be?
I believe they should be in pixels.
Yes, this is the correct output now. There we some changes to what --query-all
reports.
Here is a post-processed SVG:
<svg width="40" height="26.666666" xmlns="http://www.w3.org/2000/svg">
<defs/>
<g transform="matrix(1.3333333 0 0 1.3333333 0.00000191 0.00000095)">
<path id="rect-1" fill="#000000" stroke="none" d="M 20 20 L 21.333334 20 L 21.333334 21.333334 L 20 21.333334 Z"/>
</g>
</svg>
As you can see, viewBox transform was flattened and will be applied to the rect.
Remember that width="30pt" height="20pt"
!= viewBox="0 0 30 20"
. viewBox
uses pixels, not points.
Thanks, I'll have to dive deeper into measurement units in SVGz which is a very confusing topic.
I have noticed some wierd things about measurements returned
resvg --query-all
. The units are not obvious, and measurements have changed from v0.42 onwards.Let's sayy we call
resvg --query-all
on the following SVG file using versions v0.34 to v0.44:We get the following (I used an Elixir project to download the 10 versiona and set things up, the important part are the measurements returned by each version):
I can't find these differences documented anywhere. Is any of these the expected value? Which units should these numbers be? What changes in v0.42? I actualy found about this when using resvg to get some text measurements, where there seems to be further "weirdness", but even the 1pt-side rectangle has left me a bit stumped...
Thanks for any help.