Thanks for svg2b2d, it's well integrated with Blend2d, but I'm thinking about two small things
, currently missing, that could be useful for better positioning or framing a picture on a canvas.
-
Class SVGDocument should provide some methods returning the viewbox() and the boundingbox().
-
The width(), height(), viewbox() and bbox() methods should always return a meaningful
(computed) result, even if these attributes are not set.
(* I know boundingbox is not an SVG attribute, but it is useful for sizing the canvas *)
-
Test case 1: tiger.svg
https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg
has the following header ( ... missing width, height)
<svg id="svg2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 900" version="1.1">
and methods width(), height() returns 100.0 100.0
Therefore, when rendered (doc.draw(..)), nothing is drawn.
- Test case 2: * moby.svg
This attched file <mobj.svg>,

has the following header
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="392.466022pt" height="110.322899pt" viewBox="0 0 392.466022 110.322899"
preserveAspectRatio="xMidYMid meet">
here width(), height() return 523.288029 , 147.097199
I suppose they are scaled, but the bad thing is that in this 'viewBox' the true picture (moby)
is much more smaller. there's a lot of white/unused space around the picture
Therefore the measurement of the bounding box would be needed to size the canvas better.
Thanks for svg2b2d, it's well integrated with Blend2d, but I'm thinking about two small things
, currently missing, that could be useful for better positioning or framing a picture on a canvas.
Class SVGDocument should provide some methods returning the viewbox() and the boundingbox().
The width(), height(), viewbox() and bbox() methods should always return a meaningful
(computed) result, even if these attributes are not set.
(* I know boundingbox is not an SVG attribute, but it is useful for sizing the canvas *)
Test case 1: tiger.svg
https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg
has the following header ( ... missing width, height)
<svg id="svg2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 900" version="1.1">and methods width(), height() returns 100.0 100.0
Therefore, when rendered (doc.draw(..)), nothing is drawn.
This attched file <mobj.svg>,
has the following header
here width(), height() return 523.288029 , 147.097199
I suppose they are scaled, but the bad thing is that in this 'viewBox' the true picture (moby)
is much more smaller. there's a lot of white/unused space around the picture
Therefore the measurement of the bounding box would be needed to size the canvas better.