Add Tree::intrinsic_dimensions exposing declared root width/height/viewBox - #1119
Add Tree::intrinsic_dimensions exposing declared root width/height/viewBox#1119nicoburns wants to merge 1 commit into
Tree::intrinsic_dimensions exposing declared root width/height/viewBox#1119Conversation
|
Hmm, it feels a bit hacky... Can't you just construct the |
I can, but isn't that a lot more hacky? Aside from anything else, I then have to parse every SVG twice. |
|
Would this even work? All other relative values would be already resolved based on the viewbox. So the one you would store would not mean anything. The SVG spec is comically large and complex, so I have no idea how exactly it suppose to work. But shouldn't we pass the viewport size/bounds to |
I don't tihnk so, no? Can't you just construct the
Maybe hacky is not the right word. Basically, my point was |
Yes, this is the intended use case for this PR: computing the correct scale factor to apply during rendering. That's significantly cheaper than re-parsing the SVG every time the size I want to render it at changes. Importantly, for SVGs embedded in HTML documents:
|
|
What about If you still want this, I'm happy to approve, so just let me know, but I still think the better approach would still be to just construct the |
3289a9b to
0cca401
Compare
Exposes raw/unresolved
width/height/viewBoxonTree.This is necessary to correctly size SVGs within an HTML document (e.g. in Servo/Blitz) in the case that
widthorheightare defined as a percentage. In that case, resvg's existing approach of eagerly resolving sizes doesn't work, as you cannot correctly resolve the sizes until you have a basis to resolve the percentages against (which are only computed as part of layout).Exposed as a separate method to the existing
width()andheight()methods as it's a little bit of an advanced use case, and the existing methods make some sense for the simple cases.