androidsvg
androidsvg copied to clipboard
Support multi-value text geometry attributes
Issue
I find this question when load svg file.
normal
But lost the '<' when useing this library to load the svg:

Solution
SVGAndroidRenderer.java
private void enumerateTextSpans(TextContainer obj, TextProcessor textprocessor)
{
if (!display())
return;
Iterator<SvgObject> iter = obj.children.iterator();
boolean isFirstChild = true;
// get the array of x info
List<Length> xList = null;
int size = 0;
if (obj instanceof Text){
xList = ((Text) obj).x;
size = xList.size();
}
while (iter.hasNext())
{
SvgObject child = iter.next();
if (child instanceof TextSequence) {
final String text = ((TextSequence) child).text;
//When the length of the string is greater than 1 and consistent with the length of the X coordinate array, each character needs to be drawn separately
if (text.length() > 1 && text.length() == size){
for (int i = 0;i < text.length();i++){
String s = text.substring(i,i+1);
if (textprocessor instanceof PlainTextDrawer){
((PlainTextDrawer) textprocessor).x = xList.get(i).value;
}
textprocessor.processText(s);
}
}else {
textprocessor.processText(textXMLSpaceTransform(text, isFirstChild, !iter.hasNext() /*isLastChild*/));
}
} else {
processTextChild(child, textprocessor);
}
isFirstChild = false;
}
}
Hi. Thanks for your report.
This is failing because AndroidSVG doesn't currently support multivalue x attributes in text. For example:
x="706 1612"
This is a rarely used feature of the SVG spec. And is complicated to implement properly. So it didn't seem high on the priority list.
I'm curious... What software generated this SVG?
PL