Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadShape() problems with SVGs that have . starting a number in a path #518

Open
benfry opened this issue Jul 30, 2022 · 2 comments
Open
Labels
Help Wanted We have very little time and would like some help

Comments

@benfry
Copy link
Owner

benfry commented Jul 30, 2022

Re-saving the SVG in 1.0 format with Illustrator instead of 1.1 will fix the issue, but the problem seems to be that a leading . in the SVG path code won't render properly, for instance:

  • M3,.6 – parse to M, 3, .6 (may be fixed with 9ef40ba)
  • M.6.7 – parse to M, .6, and .7
  • …etc

This caused a problem with the variable icons, which was fixed commit 805306f, so using the previous version of the SVGs should do the trick for testing.

Test code:

static final String[] names = { 
  "array", "boolean", "byte", "char", "double", "float",  
  "integer", "long", "object", "short", "string"
};

void setup() {
  size(250, 550);
  textAlign(LEFT, CENTER);
  textSize(24);
  fill(0);

  int each = 50;
  int pos = 0;
  for (String name : names) {
    PShape s = loadShape(name + ".svg");
    shape(s, 0, pos, each, each);
    text(name, 60, pos + each/2);
    pos += each;
  }
  saveFrame("issue.png");
}

issue

@benfry benfry changed the title loadShape() doesn't work properly with SVGs that have . starting a number in a path loadShape() partially broken with SVGs that have . starting a number in a path Jul 30, 2022
@benfry benfry changed the title loadShape() partially broken with SVGs that have . starting a number in a path loadShape() problems with SVGs that have . starting a number in a path Jul 30, 2022
@benfry
Copy link
Owner Author

benfry commented Jul 31, 2022

This may be the same as #515

@benfry benfry added the Help Wanted We have very little time and would like some help label Jan 18, 2023
@haschdl
Copy link

haschdl commented Mar 8, 2023

I worked with SVG files had also caused ArrayIndexOutOfBoundsException due to the parsing of the path data and in my case the exception was gone with Processing 4.2 , so It seems the fix for #515 also fixes #518 ? thanks @benfry for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted We have very little time and would like some help
Projects
None yet
Development

No branches or pull requests

2 participants