Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi-value text geometry attributes #248

Open
zhang-hai opened this issue Mar 11, 2022 · 1 comment
Open

Support multi-value text geometry attributes #248

zhang-hai opened this issue Mar 11, 2022 · 1 comment

Comments

@zhang-hai
Copy link

zhang-hai commented Mar 11, 2022

Issue

I find this question when load svg file.

normal
image23

But lost the '<' when useing this library to load the svg:
image

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;
      }
   }
@BigBadaboom
Copy link
Owner

BigBadaboom commented Mar 11, 2022

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

@BigBadaboom BigBadaboom changed the title svg show exception Support multi-value text geometry attributessvg show exception Mar 11, 2022
@BigBadaboom BigBadaboom changed the title Support multi-value text geometry attributessvg show exception Support multi-value text geometry attributes Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants