Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.7
-
None
-
None
Description
Consider the following fragment:
<text id="text8072" y="15.697294" x="1.0898001" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15.67250013px;line-height:125%;font-family:'Arial Unicode MS';-inkscape-font-specification:'Arial Unicode MS, Normal';fill:#ff0000>
the style Parser stops parsing with an exception when it encounters -inkscape-font-specification, which Inkscape adds to every font declaration and which cannot be removed.The rendered text is then missing any style attribute specified afterwards, such as color, anchor, alignment, etc...
possible patch that parses styles correctly:
protected void parseStyleDeclaration(final boolean inSheet) throws CSSException { boolean leadingDash = false; for (;;) { switch (current) { case LexicalUnits.EOF: if (inSheet) { throw createCSSParseException("eof"); } return; case LexicalUnits.RIGHT_CURLY_BRACE: if (!inSheet) { throw createCSSParseException("eof.expected"); } nextIgnoreSpaces(); return; case LexicalUnits.SEMI_COLON: nextIgnoreSpaces(); continue; case LexicalUnits.MINUS: leadingDash = true; next(); break; default: throw createCSSParseException("identifier"); case LexicalUnits.IDENTIFIER: } final String name = (leadingDash ? "-" : "") + scanner.getStringValue(); leadingDash = false; if (nextIgnoreSpaces() != LexicalUnits.COLON) { throw createCSSParseException("colon"); } nextIgnoreSpaces(); LexicalUnit exp = null; try { exp = parseExpression(false); } catch (final CSSParseException e) { reportError(e); } if (exp != null) { boolean important = false; if (current == LexicalUnits.IMPORTANT_SYMBOL) { important = true; nextIgnoreSpaces(); } documentHandler.property(name, exp, important); } } }
workaround:
Create your own parser class that extends org.apache.batik.css.parser.Parser, overriding parseStyleDeclaration with the code above, and add the following line your code
XMLResourceDescriptor.setCSSParserClassName(MyParser.class.getName());