Skip to content

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

Closed
@Junology

Description

@Junology

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.

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