Skip to content

Support multi-value text geometry attributes #248

Open
@zhang-hai

Description

@zhang-hai

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;
      }
   }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions