Issue with SVG fill

Hello folks,
I used the JuceDemo (2016-10-04 snapshot) to load and display an SVG image of a chess knight, and seeing a fill anomaly.

I’m running on Linux x86-64, and I tried the software and opengl renderers, with identical results.

The SVG image itself is at:
https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces#/media/File:Chess_ndt45.svg
(and should display fine in a browser). Under Juce, it looks like:

After narrowing it down a bit, I think Juce has an issue filling open SVG paths. SVG Tiny 1.2 section 11.3 says, “Open subpaths must be filled by performing the fill operation as if an additional “closepath” command were added to the path to connect the last point of the subpath with the first point of the subpath.”

I believe Juce ignores that when it translates the SVG to a Drawable. In this particular case, since we never did the implicit closepath, the even-odd algorithm that does the fill eventually screws up. Of course I could hack juce_SVGParser.cpp to force-close the path, but I think that would negatively effect stroking.

Neglecting the fact that I could edit the SVGs themselves to work around the issue (iff I know what SVGs to use ahead of time) … I tried to cook up my own fix but I’m unsure of the best approach, though it might involve doing questionable things to juce::Path and/or PathFlatteningIterator. Any chance for an eventual fix from ROLI’s end?

Thanks, --buck

1 Like