Closed AndreKR closed 2 years ago
Thanks for the report.
Interesting. It looks like there might be a bug with either child <svg>
elements, or <use>
elements when a viewBox
is involved. I'll have to investigate and see what is happening.
I looked into this a bit and I noticed something...
So, svg.setDocumentViewBox(0f, 0f, svg.documentWidth, svg.documentHeight);
is enough to trigger the issue.
Those little icons look like this in the source:
These three function are involved:
When I didn't call setDocumentViewBox()
then the call to render()
in line 644 would have the viewPort
parameter set to [0.0 0.0 24.0 24.0]
. (This seems to make sense because the icon is to be rendered into a space 24x24 in size?)
But when I called setDocumentViewBox()
then the call to render()
would have viewPort
set to [0.0 0.0 782.0 391.0]
. (That seems to be the full size of the document.) This is because in the error case, state.viewBox
in getCurrentViewPortInUserUnits()
is not null, unlike in the working case where it is null.
Unfortunately this is where I'm a bit stuck because I don't know which state exactly state
is supposed to represent and why the document viewbox might "leak" down into the viewport of sub SVG elements.
Thanks for the new clues. I can reproduce this in a simple test case now. I'm looking into the cause.
This now fixed. The fix will be in the 1.5 release.
I'm trying to render this SVG into an
ImageView
so that it fills the wholeImageView
while keeping the aspect ratio.The SVG has
width
andheight
but noviewBox
, so I added the recommended code (essentially the same case as "Dealing with Inkscape files"):Without the extra settings it renders like this:
With the extra settings the scaling is as desired, but all the embedded images are missing:
Here is the complete code
```kotlin val locationNumber = "2-2192362" val imageView = root.findViewById