SVG complete paths

I found the SVG parser doesn't handle paths that don't have a 'z' tag and that finish in the same place as they started. 

This can be solved by modifying parsePathString() in juce_SVGParser.cpp as follows:

void parsePathString (Path& path, const String& pathString) const
{
    ...

    
    if (subpathStart == path.getCurrentPosition())
    {
        path.closeSubPath();
    }
}

 

I have attached an example SVG file (from w3.org), as well as screenshots of before and after the modification.

I'm not sure if the image conforms to the SVG spec because it doesn't close its paths, but browsers don't seem to have a problem with this so I guess they detect that it finishes in the same place.

 

Interesting, thanks for letting me know about that! Maybe there's some hidden corner of the SVG spec where it says this.. Will get it sorted out right away!