Line reported to be longer than I expected
When I load something like this: <svg width="200mm" height="400mm" viewBox="0 0 200 400" version="1.1"> <g fill="none" stroke="black" stroke-width="2" > <line x1="1" y1="0" x2="1" y2="400" /> </g> </svg> The line is reported to be 2mm longer than I expected (402mm), even though it touches the bottom and top of the page perfectly, the page is reported to be exactly 400mm high. Is this a bug or a feature?
The line is reported to be 2mm longer than I expected (402mm), even though it touches the bottom and top of the page perfectly, the page is reported to be exactly 400mm high. Is this a bug or a feature?
It's a bug. Lines' bboxes extend beyond line ends by the line width. This is because the bbox is now calculated simply by adding half the stroke width to all 4 sides of the without-stroke bbox, but in this case (for unclosed horizontal line) it should be added only to the top and bottom. It is a very difficult bug to fix because we currently have no code to reliably determine how far the stroke of a given shape extends, which may be affected not only by stroke width but also by (as in your case) shape orientation and closeness, join and cap types, and miter limit.
Anyway, I think we don't yet have this in our bug tracker, so please submit it (with my comments).
participants (2)
-
bulia byak
-
Jasper van de Gronde