diff --git a/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java b/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java index efcfdd87e..908b9dd05 100644 --- a/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java +++ b/src/net/sourceforge/plantuml/emoji/SvgNanoParser.java @@ -10,14 +10,17 @@ import java.util.regex.Pattern; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.awt.geom.Dimension2D; import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.openiconic.SvgPath; import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UImageSvg; import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UText; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.ColorChangerMonochrome; import net.sourceforge.plantuml.ugraphic.color.ColorMapper; @@ -54,12 +57,13 @@ public class SvgNanoParser implements Sprite { this.keepColors = keepColors; for (String singleLine : svg) { - final Pattern p = Pattern.compile("\\<[^<>]+\\>"); + final Pattern p = Pattern + .compile("(\\)|(\\<(svg|path|g|circle|ellipse)[^<>]*\\>)|(\\]*\\>)"); final Matcher m = p.matcher(singleLine); while (m.find()) { final String s = m.group(0); - if (s.contains("") || s.contains("") - || s.contains("") || s.startsWith("") + || s.startsWith(" stack = new ArrayList<>(); for (String s : data) { - if (s.contains("")) { + } else if (s.startsWith("")) { ugs = stack.remove(0); - } else if (s.contains("")) { + } else if (s.startsWith("")) { stack.add(0, ugs); - } else if (s.contains("]*\\>(.*?)\\"); + final Matcher m = p.matcher(s); + if (m.find()) { + final String text = m.group(1); + HColor color = HColorSet.instance().getColorOrWhite(fill); + final FontConfiguration fc = FontConfiguration.create(UFont.sansSerif(fontSize), color, color, false); + final UText utext = new UText(text, fc); + UGraphic ug = ugs.getUg(); + ug = ug.apply(new UTranslate(x, y)); + ug.draw(utext); + } + } + private void drawPath(UGraphicWithScale ugs, String s, HColor colorForMonochrome) { s = s.replace("id=\"", "ID=\""); ugs = applyFill(ugs, s, colorForMonochrome);