|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java b/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java
|
|
|
bbff9f2 |
index 848ceb5..926b9ef 100644
|
|
|
bbff9f2 |
--- a/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java
|
|
|
bbff9f2 |
+++ b/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java
|
|
|
bbff9f2 |
@@ -113,28 +113,21 @@ protected void build() throws SVGException
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
if (getPres(sty.setName("xlink:href")))
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
-
|
|
|
bbff9f2 |
-
|
|
|
bbff9f2 |
URI src = sty.getURIValue(getXMLBase());
|
|
|
bbff9f2 |
if ("data".equals(src.getScheme()))
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
imageSrc = new URL(null, src.toASCIIString(), new Handler());
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
- else
|
|
|
bbff9f2 |
+ else if (!diagram.getUniverse().isImageDataInlineOnly())
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
-
|
|
|
bbff9f2 |
- if (!diagram.getUniverse().isImageDataInlineOnly())
|
|
|
bbff9f2 |
+ try
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- try
|
|
|
bbff9f2 |
- {
|
|
|
bbff9f2 |
- imageSrc = src.toURL();
|
|
|
bbff9f2 |
- } catch (Exception e)
|
|
|
bbff9f2 |
- {
|
|
|
bbff9f2 |
- Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
|
|
|
bbff9f2 |
- "Could not parse xlink:href " + src, e);
|
|
|
bbff9f2 |
- // e.printStackTrace();
|
|
|
bbff9f2 |
- imageSrc = null;
|
|
|
bbff9f2 |
- }
|
|
|
bbff9f2 |
+ imageSrc = src.toURL();
|
|
|
bbff9f2 |
+ } catch (Exception e)
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
|
|
|
bbff9f2 |
+ "Could not parse xlink:href " + src, e);
|
|
|
bbff9f2 |
+ imageSrc = null;
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
@@ -143,32 +136,33 @@ protected void build() throws SVGException
|
|
|
bbff9f2 |
throw new SVGException(e);
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
- diagram.getUniverse().registerImage(imageSrc);
|
|
|
bbff9f2 |
-
|
|
|
bbff9f2 |
- //Set widths if not set
|
|
|
bbff9f2 |
- BufferedImage img = diagram.getUniverse().getImage(imageSrc);
|
|
|
bbff9f2 |
- if (img == null)
|
|
|
bbff9f2 |
+ if (imageSrc != null)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- xform = new AffineTransform();
|
|
|
bbff9f2 |
- bounds = new Rectangle2D.Float();
|
|
|
bbff9f2 |
- return;
|
|
|
bbff9f2 |
- }
|
|
|
bbff9f2 |
+ diagram.getUniverse().registerImage(imageSrc);
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
- if (width == 0)
|
|
|
bbff9f2 |
- {
|
|
|
bbff9f2 |
- width = img.getWidth();
|
|
|
bbff9f2 |
- }
|
|
|
bbff9f2 |
- if (height == 0)
|
|
|
bbff9f2 |
- {
|
|
|
bbff9f2 |
- height = img.getHeight();
|
|
|
bbff9f2 |
- }
|
|
|
bbff9f2 |
+ //Set widths if not set
|
|
|
bbff9f2 |
+ BufferedImage img = diagram.getUniverse().getImage(imageSrc);
|
|
|
bbff9f2 |
+ if (img == null)
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ xform = new AffineTransform();
|
|
|
bbff9f2 |
+ bounds = new Rectangle2D.Float();
|
|
|
bbff9f2 |
+ return;
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
+
|
|
|
bbff9f2 |
+ if (width == 0)
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ width = img.getWidth();
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
+ if (height == 0)
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ height = img.getHeight();
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
- //Determine image xform
|
|
|
bbff9f2 |
- xform = new AffineTransform();
|
|
|
bbff9f2 |
-// xform.setToScale(this.width / img.getWidth(), this.height / img.getHeight());
|
|
|
bbff9f2 |
-// xform.translate(this.x, this.y);
|
|
|
bbff9f2 |
- xform.translate(this.x, this.y);
|
|
|
bbff9f2 |
- xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
|
|
|
bbff9f2 |
+ //Determine image xform
|
|
|
bbff9f2 |
+ xform = new AffineTransform();
|
|
|
bbff9f2 |
+ xform.translate(this.x, this.y);
|
|
|
bbff9f2 |
+ xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height);
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
@@ -342,16 +336,16 @@ public boolean updateTime(double curTime) throws SVGException
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
URI src = sty.getURIValue(getXMLBase());
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
- URL newVal;
|
|
|
bbff9f2 |
+ URL newVal = null;
|
|
|
bbff9f2 |
if ("data".equals(src.getScheme()))
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
newVal = new URL(null, src.toASCIIString(), new Handler());
|
|
|
bbff9f2 |
- } else
|
|
|
bbff9f2 |
+ } else if (!diagram.getUniverse().isImageDataInlineOnly())
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
newVal = src.toURL();
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
- if (!newVal.equals(imageSrc))
|
|
|
bbff9f2 |
+ if (newVal != null && !newVal.equals(imageSrc))
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
imageSrc = newVal;
|
|
|
bbff9f2 |
shapeChange = true;
|
|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/SVGElement.java b/svg-core/src/main/java/com/kitfox/svg/SVGElement.java
|
|
|
bbff9f2 |
index 384c1a0..1e4a594 100644
|
|
|
bbff9f2 |
--- a/svg-core/src/main/java/com/kitfox/svg/SVGElement.java
|
|
|
bbff9f2 |
+++ b/svg-core/src/main/java/com/kitfox/svg/SVGElement.java
|
|
|
bbff9f2 |
@@ -743,9 +743,10 @@ public StyleAttribute getPresAbsolute(String styName)
|
|
|
bbff9f2 |
return (StyleAttribute) presAttribs.get(styName);
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
+ private static final Pattern TRANSFORM_PATTERN = Pattern.compile("\\w+\\([^)]*\\)");
|
|
|
bbff9f2 |
static protected AffineTransform parseTransform(String val) throws SVGException
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- final Matcher matchExpression = Pattern.compile("\\w+\\([^)]*\\)").matcher("");
|
|
|
bbff9f2 |
+ final Matcher matchExpression = TRANSFORM_PATTERN.matcher("");
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
AffineTransform retXform = new AffineTransform();
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
@@ -758,9 +759,10 @@ static protected AffineTransform parseTransform(String val) throws SVGException
|
|
|
bbff9f2 |
return retXform;
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
+ private static final Pattern WORD_PATTERN = Pattern.compile("([a-zA-Z]+|-?\\d+(\\.\\d+)?(e-?\\d+)?|-?\\.\\d+(e-?\\d+)?)");
|
|
|
bbff9f2 |
static public AffineTransform parseSingleTransform(String val) throws SVGException
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- final Matcher matchWord = Pattern.compile("([a-zA-Z]+|-?\\d+(\\.\\d+)?(e-?\\d+)?|-?\\.\\d+(e-?\\d+)?)").matcher("");
|
|
|
bbff9f2 |
+ final Matcher matchWord = WORD_PATTERN.matcher("");
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
AffineTransform retXform = new AffineTransform();
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
@@ -839,9 +841,10 @@ static protected float nextFloat(LinkedList<String> l)
|
|
|
bbff9f2 |
return Float.parseFloat(s);
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
+ private static final Pattern COMMAND_PATTERN = Pattern.compile("([MmLlHhVvAaQqTtCcSsZz])|([-+]?((\\d*\\.\\d+)|(\\d+))([eE][-+]?\\d+)?)");
|
|
|
bbff9f2 |
static protected PathCommand[] parsePathList(String list)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- final Matcher matchPathCmd = Pattern.compile("([MmLlHhVvAaQqTtCcSsZz])|([-+]?((\\d*\\.\\d+)|(\\d+))([eE][-+]?\\d+)?)").matcher(list);
|
|
|
bbff9f2 |
+ final Matcher matchPathCmd = COMMAND_PATTERN.matcher(list);
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
//Tokenize
|
|
|
bbff9f2 |
LinkedList<String> tokens = new LinkedList<String>();
|
|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java b/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java
|
|
|
bbff9f2 |
index 203f485..fc40717 100644
|
|
|
bbff9f2 |
--- a/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java
|
|
|
bbff9f2 |
+++ b/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java
|
|
|
bbff9f2 |
@@ -200,8 +200,8 @@ protected void prepareViewport()
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
else if (viewBox != null)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- xx = (float)viewBox.x;
|
|
|
bbff9f2 |
- ww = (float)viewBox.width;
|
|
|
bbff9f2 |
+ xx = viewBox.x;
|
|
|
bbff9f2 |
+ ww = viewBox.width;
|
|
|
bbff9f2 |
width = new NumberWithUnits(ww, NumberWithUnits.UT_PX);
|
|
|
bbff9f2 |
x = new NumberWithUnits(xx, NumberWithUnits.UT_PX);
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
@@ -228,8 +228,8 @@ else if (viewBox != null)
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
else if (viewBox != null)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- yy = (float)viewBox.y;
|
|
|
bbff9f2 |
- hh = (float)viewBox.height;
|
|
|
bbff9f2 |
+ yy = viewBox.y;
|
|
|
bbff9f2 |
+ hh = viewBox.height;
|
|
|
bbff9f2 |
height = new NumberWithUnits(hh, NumberWithUnits.UT_PX);
|
|
|
bbff9f2 |
y = new NumberWithUnits(yy, NumberWithUnits.UT_PX);
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
@@ -262,6 +262,12 @@ else if (viewBox != null)
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
public void renderToViewport(Graphics2D g) throws SVGException
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ render(g);
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
+
|
|
|
bbff9f2 |
+ @Override
|
|
|
bbff9f2 |
+ public void render(Graphics2D g) throws SVGException
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
prepareViewport();
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java b/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java
|
|
|
bbff9f2 |
index 3bb9973..7cc1565 100644
|
|
|
bbff9f2 |
--- a/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java
|
|
|
bbff9f2 |
+++ b/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java
|
|
|
bbff9f2 |
@@ -98,9 +98,7 @@
|
|
|
bbff9f2 |
*/
|
|
|
bbff9f2 |
protected double curTime = 0.0;
|
|
|
bbff9f2 |
private boolean verbose = false;
|
|
|
bbff9f2 |
- //Cache reader for efficiency
|
|
|
bbff9f2 |
- XMLReader cachedReader;
|
|
|
bbff9f2 |
-
|
|
|
bbff9f2 |
+
|
|
|
bbff9f2 |
//If true, <imageSVG> elements will only load image data that is included using inline data: uris
|
|
|
bbff9f2 |
private boolean imageDataInlineOnly = false;
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
@@ -576,15 +574,11 @@ public URI getStreamBuiltURI(String name)
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
- private XMLReader getXMLReaderCached() throws SAXException, ParserConfigurationException
|
|
|
bbff9f2 |
+ private XMLReader getXMLReader() throws SAXException, ParserConfigurationException
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- if (cachedReader == null)
|
|
|
bbff9f2 |
- {
|
|
|
bbff9f2 |
- SAXParserFactory factory = SAXParserFactory.newInstance();
|
|
|
bbff9f2 |
- factory.setNamespaceAware(true);
|
|
|
bbff9f2 |
- cachedReader = factory.newSAXParser().getXMLReader();
|
|
|
bbff9f2 |
- }
|
|
|
bbff9f2 |
- return cachedReader;
|
|
|
bbff9f2 |
+ SAXParserFactory factory = SAXParserFactory.newInstance();
|
|
|
bbff9f2 |
+ factory.setNamespaceAware(true);
|
|
|
bbff9f2 |
+ return factory.newSAXParser().getXMLReader();
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
protected URI loadSVG(URI xmlBase, InputSource is)
|
|
|
bbff9f2 |
@@ -600,7 +594,7 @@ protected URI loadSVG(URI xmlBase, InputSource is)
|
|
|
bbff9f2 |
try
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
// Parse the input
|
|
|
bbff9f2 |
- XMLReader reader = getXMLReaderCached();
|
|
|
bbff9f2 |
+ XMLReader reader = getXMLReader();
|
|
|
bbff9f2 |
reader.setEntityResolver(
|
|
|
bbff9f2 |
new EntityResolver()
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
@@ -617,8 +611,8 @@ public InputSource resolveEntity(String publicId, String systemId)
|
|
|
bbff9f2 |
return xmlBase;
|
|
|
bbff9f2 |
} catch (SAXParseException sex)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- System.err.println("Error processing " + xmlBase);
|
|
|
bbff9f2 |
- System.err.println(sex.getMessage());
|
|
|
bbff9f2 |
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
|
|
|
bbff9f2 |
+ "Error processing " + xmlBase, sex);
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
loadedDocs.remove(xmlBase);
|
|
|
bbff9f2 |
return null;
|
|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/Text.java b/svg-core/src/main/java/com/kitfox/svg/Text.java
|
|
|
bbff9f2 |
index 64d2dd5..b306edc 100644
|
|
|
bbff9f2 |
--- a/svg-core/src/main/java/com/kitfox/svg/Text.java
|
|
|
bbff9f2 |
+++ b/svg-core/src/main/java/com/kitfox/svg/Text.java
|
|
|
bbff9f2 |
@@ -178,7 +178,7 @@ public void build() throws SVGException
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
else
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- fontFamily = "Sans Serif";
|
|
|
bbff9f2 |
+ fontFamily = "SansSerif";
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
if (getStyle(sty.setName("font-size")))
|
|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/Tspan.java b/svg-core/src/main/java/com/kitfox/svg/Tspan.java
|
|
|
bbff9f2 |
index 1d9fa32..3b66188 100644
|
|
|
bbff9f2 |
--- a/svg-core/src/main/java/com/kitfox/svg/Tspan.java
|
|
|
bbff9f2 |
+++ b/svg-core/src/main/java/com/kitfox/svg/Tspan.java
|
|
|
bbff9f2 |
@@ -228,13 +228,18 @@ public void appendToShape(GeneralPath addShape, Point2D cursor) throws SVGExcept
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
//Get font
|
|
|
bbff9f2 |
Font font = diagram.getUniverse().getFont(fontFamily);
|
|
|
bbff9f2 |
- if (font == null)
|
|
|
bbff9f2 |
+ if (font == null && fontFamily != null)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
font = FontSystem.createFont(fontFamily, fontStyle, fontWeight, (int)fontSize);
|
|
|
bbff9f2 |
// addShapeSysFont(addShape, font, fontFamily, fontSize, letterSpacing, cursor);
|
|
|
bbff9f2 |
// return;
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
+ if (font == null)
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ font = FontSystem.createFont("Serif", fontStyle, fontWeight, fontStyle);
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
+
|
|
|
bbff9f2 |
// FontFace fontFace = font.getFontFace();
|
|
|
bbff9f2 |
// int ascent = fontFace.getAscent();
|
|
|
bbff9f2 |
// float fontScale = fontSize / (float) ascent;
|
|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt b/svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParser.jjt
|
|
|
bbff9f2 |
similarity index 100%
|
|
|
bbff9f2 |
rename from svg-core/src/main/java/com/kitfox/svg/animation/AnimTimeParser.jjt
|
|
|
bbff9f2 |
rename to svg-core/src/main/java/com/kitfox/svg/animation/parser/AnimTimeParser.jjt
|
|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java b/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java
|
|
|
bbff9f2 |
index 5c4ebf2..df90b64 100644
|
|
|
bbff9f2 |
--- a/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java
|
|
|
bbff9f2 |
+++ b/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java
|
|
|
bbff9f2 |
@@ -47,6 +47,7 @@
|
|
|
bbff9f2 |
import java.awt.font.GlyphVector;
|
|
|
bbff9f2 |
import java.util.HashMap;
|
|
|
bbff9f2 |
import java.util.HashSet;
|
|
|
bbff9f2 |
+import java.util.Locale;
|
|
|
bbff9f2 |
import java.util.regex.Matcher;
|
|
|
bbff9f2 |
import java.util.regex.Pattern;
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
@@ -67,7 +68,7 @@ public static boolean checkIfSystemFontExists(String fontName)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
if (sysFontNames.isEmpty())
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- for (String name: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames())
|
|
|
bbff9f2 |
+ for (String name: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(Locale.ENGLISH))
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
sysFontNames.add(name);
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
@@ -81,15 +82,33 @@ public static FontSystem createFont(String fontFamily, int fontStyle, int fontWe
|
|
|
bbff9f2 |
String[] families = fontFamily.split(",");
|
|
|
bbff9f2 |
for (String fontName: families)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- if (checkIfSystemFontExists(fontName))
|
|
|
bbff9f2 |
+ String javaFontName = mapJavaFontName(fontName);
|
|
|
bbff9f2 |
+ if (checkIfSystemFontExists(javaFontName))
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
- return new FontSystem(fontName, fontStyle, fontWeight, (int) fontSize);
|
|
|
bbff9f2 |
+ return new FontSystem(javaFontName, fontStyle, fontWeight, (int) fontSize);
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
return null;
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
-
|
|
|
bbff9f2 |
+
|
|
|
bbff9f2 |
+ private static String mapJavaFontName(String fontName)
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ if ("serif".equals(fontName))
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ return java.awt.Font.SERIF;
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
+ else if ("sans-serif".equals(fontName))
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ return java.awt.Font.SANS_SERIF;
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
+ else if ("monospace".equals(fontName))
|
|
|
bbff9f2 |
+ {
|
|
|
bbff9f2 |
+ return java.awt.Font.MONOSPACED;
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
+ return fontName;
|
|
|
bbff9f2 |
+ }
|
|
|
bbff9f2 |
+
|
|
|
bbff9f2 |
private FontSystem(String fontFamily, int fontStyle, int fontWeight, int fontSize)
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
int style;
|
|
|
bbff9f2 |
diff --git a/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java b/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java
|
|
|
bbff9f2 |
index bfc0be4..4f1a1df 100644
|
|
|
bbff9f2 |
--- a/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java
|
|
|
bbff9f2 |
+++ b/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java
|
|
|
bbff9f2 |
@@ -54,6 +54,7 @@
|
|
|
bbff9f2 |
{
|
|
|
bbff9f2 |
static final Matcher fpMatch = Pattern.compile("([-+]?((\\d*\\.\\d+)|(\\d+))([eE][+-]?\\d+)?)(\\%|in|cm|mm|pt|pc|px|em|ex)?").matcher("");
|
|
|
bbff9f2 |
static final Matcher intMatch = Pattern.compile("[-+]?\\d+").matcher("");
|
|
|
bbff9f2 |
+ static final Matcher quoteMatch = Pattern.compile("^'|'$").matcher("");
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
/** Creates a new instance of XMLParseUtil */
|
|
|
bbff9f2 |
private XMLParseUtil()
|
|
|
bbff9f2 |
@@ -822,7 +823,7 @@ public static ReadableXMLElement getElement(Class classType, Element root, St
|
|
|
bbff9f2 |
}
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
String key = styles[i].substring(0, colon).trim();
|
|
|
bbff9f2 |
- String value = styles[i].substring(colon + 1).trim();
|
|
|
bbff9f2 |
+ String value = quoteMatch.reset(styles[i].substring(colon + 1).trim()).replaceAll("");
|
|
|
bbff9f2 |
|
|
|
bbff9f2 |
map.put(key, new StyleAttribute(key, value));
|
|
|
bbff9f2 |
}
|