GNOME Bugzilla – Bug 761264
librsvg detects crazy dimension for rectangles with stroke-width <= 0.5
Last modified: 2017-08-29 22:44:48 UTC
I have a <rect> with the following code: <rect y="1046.7383" x="9.4698935" height="2.2477121" width="2.2477121" id="rect3933-15" style="opacity:0.5;fill:#bebebe;fill-opacity:1;stroke:#bebebe;stroke-width:0.25228789;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> The expected size is 2x2, and the position (829, 280) in this particular file. But rsvg_handle_get_position_sub()/rsvg_handle_get_dimensions_sub() returns me crazy numbers 11x1048 (820, -766). As soon as I change the stroke-width parameter over 0,5, or if I disable the stroke (stroke:none), I get expected numbers. Obviously a stroke under 1px is meaningless (Inkscape allows these. I guess it still make sense since the vectorial drawing can be scaled up infinitely), but it should not break librsvg anyway. In any case, this follows SVG spec where numbers can be floats.
This seems to be the same problem causing bug #739916. I added a comment there showing a cause, but the fact that to compute the object bounding box librsvg sets the cairo tolerance to 1.0 certainly does not help getting accurate dimensions and/or positions. see: https://git.gnome.org/browse/librsvg/tree/rsvg-cairo-draw.c#n484 the comments there also explain that GNOME symbolic icons work around these shortcomings adding a <rect /> per icon not stroked nor filled to compute the bounding box.
*** This bug has been marked as a duplicate of bug 760112 ***