Skip to content

Loading SVG fails for some files #1244

@villares

Description

@villares

Most appropriate sub-area of Processing 4?

IO ?

Processing version

4.4.7

Operating system

Windows/macOS/Linux

Bug description

Unable to load some SVG files, such as https://commons.wikimedia.org/wiki/File:Aiga_departingflights.svg you get something similar to:

ArrayIndexOutOfBoundsException: Index 43 out of bounds for length 43

Steps to reproduce this

  1. Launch PDE, create a sketch, download https://commons.wikimedia.org/wiki/File:Aiga_departingflights.svg and add it to the data folder of your sketch.

  2. Run the snippet below:

void setup(){
  size(500, 500);
  PShape svg = loadShape("Aiga_departingflights.svg");
  shape(svg);  // will crash before this line... 
}

Additional context

This looks a bit like #750 but the "SVG path notation parsing issue" that causes it to fail seems different.

The provided failing SVG looks like this:

Image

<svg xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 29 29">
<path d="m0 6 3-2 15 4 7-7a2 2 0 013 3l-7 7 4 15-2 3-7-13-5 5v4l-2 2-2-5-5-2 2-2h4l5-5z"/>
</svg>

If you scale it a bit on Inkscape you get a different path notation and it works fine:

<svg xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 29 29">
<path d="m 0,5.9994379 2.9997,-1.9998 14.9985,3.9996 6.9993,-6.99930004 a 2.1211082,2.1211082 0 0 1 2.9997,2.99970004 l -6.9993,6.9993001 3.9996,14.9985 -1.9998,2.9997 -6.9993,-12.9987 -4.9995,4.9995 v 3.9996 l -1.9998,1.9998 -1.9998,-4.9995 -4.9995,-1.9998 1.9998,-1.9998 h 3.9996 l 4.9995,-4.9995 z"/>
</svg>

Would you like to work on the issue?

No, I’m just reporting the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions