Support `viewBox` attribute in `svg` tag
Opened this issue · 0 comments
fmaylinch commented
I don't know much about SVG format but at SVGParser:1001 the code looks for attributes width
and height
while I used this SVG file which has a viewBox
attribute with those measures.
So, I changed that code with:
if (localName.equals("svg")) {
Float w = getFloatAttr("width", atts);
Float h = getFloatAttr("height", atts);
if (w == null || h == null)
{
String vb = getStringAttr("viewBox", atts);
if (vb == null) {
throw new RuntimeException("Can't find size attributes: width+height or viewBox");
}
String[] measures = vb.split(" ");
w = Float.parseFloat(measures[2]);
h = Float.parseFloat(measures[3]);
}
int width = (int) Math.ceil(w);
int height = (int) Math.ceil(h);
canvas = picture.beginRecording(width, height);
Thanks for the lib!