blackears / svgSalamander

158 stars 57 forks source link

sodipodi + "Keyframe fractions must be increasing" #25

Closed fnatter closed 6 years ago

fnatter commented 7 years ago

hello Mark,

we have a user who used an SVG document from sodipodi (maybe inkscape?) which results in:

Caused by: com.kitfox.svg.SVGException: java.lang.IllegalArgumentException: Keyframe fractions must be increasing: 0.51143
    at com.kitfox.svg.ShapeElement.renderShape(ShapeElement.java:169)
    at com.kitfox.svg.Path.render(Path.java:94)
    at com.kitfox.svg.Group.render(Group.java:205)
    at com.kitfox.svg.Group.render(Group.java:205)
    at com.kitfox.svg.SVGRoot.renderToViewport(SVGRoot.java:329)
    at com.kitfox.svg.SVGDiagram.render(SVGDiagram.java:105)
    at com.kitfox.svg.app.beans.SVGIcon.paintIcon(SVGIcon.java:322)
    ... 69 more
Caused by: java.lang.IllegalArgumentException: Keyframe fractions must be increasing: 0.51143
    at java.awt.MultipleGradientPaint.<init>(MultipleGradientPaint.java:184)
    at java.awt.RadialGradientPaint.<init>(RadialGradientPaint.java:459)
    at com.kitfox.svg.RadialGradient.getPaint(RadialGradient.java:133)
    at com.kitfox.svg.ShapeElement.renderShape(ShapeElement.java:167)
    ... 75 more

Here is the SVG: https://raw.githubusercontent.com/fnatter/svgtest/master/src/main/resources/rihard_minus.svg

It can be fixed by: https://github.com/fnatter/svgtest/commit/b9e2c3e23009c92318e934a775ca2ab9a93b91f1

So I wonder whether you should allow gradient "stops" which are equal and not increasing or we should report a bug against sodipodi/inkscape. (even if it's wrong according to the spec, I think it's good to support this, because existing SVGs use ite).

Many Thanks and Best Regards, Felix

blackears commented 6 years ago

I've just submitted a fix so that gradients should be able to handle out of order stops and multiple stops with the same offset.