Skip to content

loadShape() cannot load SVG with the scientific notation #870

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

Closed
Junology opened this issue Dec 7, 2024 · 0 comments · Fixed by #873
Closed

loadShape() cannot load SVG with the scientific notation #870

Junology opened this issue Dec 7, 2024 · 0 comments · Fixed by #873
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Junology
Copy link
Contributor

Junology commented Dec 7, 2024

Most appropriate sub-area of Processing 4?

Image

Processing version

4.3

Operating system

Linux

Steps to reproduce this

"1. Create a new sketch and put https://github.com/yeyushengfan258/Win11-icon-theme/blob/main/src/mimes/48/application-x-executable.svg into data folder.

  1. Enter the code in the MWE below and Run.

  2. Got RuntimeException: shape command not handled: e-4."

snippet

PShape shapeIconExe;

void setup() {
  shapeIconExe = loadShape("application-x-executable.svg");
}

void draw() {
  shape(shapeIconExe, 0, 0, 48, 48);
}

Additional context

The scientific notation 3.4e-4 for 0.00034 in the SVG file causes the error.
Glancing at PShapeSVG::parsePath in core/src/processing/core/PShapeSVG.java, the parser does not seem to handle the scientific notation, though the SVG grammar specification (https://www.w3.org/1999/08/WD-SVG-19990812/paths.html#PathDataBNF) explicitly allows it.

I would really appreciate it if Processing is capable of loading such SVG files.

I found several Forum Post mentioning the problem too (e.g.~https://discourse.processing.org/t/shape-command-not-handled-e-4/44894).
Workaround is to edit SVG to fix the scientific notation to the ordinary decimal by hand or scripts.
This may, however, cause License issues especially when one considers re-distribution, so fixing core seems ideal IMHO.

@Junology Junology added the bug Something isn't working label Dec 7, 2024
@SableRaf SableRaf added the help wanted Extra attention is needed label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants