You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by "Radu Coravu (JIRA)" <ji...@apache.org> on 2015/06/03 13:31:49 UTC
[jira] [Commented] (BATIK-1112) CSS style Parser does not handle
style names with leading dash
[ https://issues.apache.org/jira/browse/BATIK-1112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14570684#comment-14570684 ]
Radu Coravu commented on BATIK-1112:
------------------------------------
+1
One more of our users encountered this problem:
https://www.oxygenxml.com/forum/post34176.html#p34176
{code}<text
xml:space="preserve"
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15px;line-height:125%;font-family:Arial;-inkscape-font-specification:'Arial, Normal';text-indent:0;text-align:end;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:end;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.5px;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
......................{code}
Again, all other CSS properties specified after the "-inkscape-font-specification" property are ignored.
> CSS style Parser does not handle style names with leading dash
> --------------------------------------------------------------
>
> Key: BATIK-1112
> URL: https://issues.apache.org/jira/browse/BATIK-1112
> Project: Batik
> Issue Type: Bug
> Components: CSS
> Affects Versions: 1.7
> Reporter: Tony BenBrahim
> Priority: Minor
>
> Consider the following fragment:
> {code}
> <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>
> {code}
> 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:
> {code}
> 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);
> }
> }
> }
> {code}
> 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
> {code}
> XMLResourceDescriptor.setCSSParserClassName(MyParser.class.getName());
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org