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

SVG Path Import/Export not working correctly #2057

Open
pzich opened this issue Dec 6, 2023 · 2 comments
Open

SVG Path Import/Export not working correctly #2057

pzich opened this issue Dec 6, 2023 · 2 comments

Comments

@pzich
Copy link

pzich commented Dec 6, 2023

Description/Steps to reproduce

Something seems to be working incorrectly with the importing->parsing->serializing->exporting flow for SVG path commands.

Here I'm creating a new paper.Path(pathA.getAttribute("d")) from a given SVG, then using paper.project.exportSVG({}) to generate an export. Even for simple shapes like this outlined circle and square, something seems to be working incorrectly, possibly involving how the close path is handled?

circle square hexagon

I'm not familiar with how these commands are processed internally so I'm not sure how best to debug this further.

Link to reproduction test-case

https://codesandbox.io/p/sandbox/paperjs-imp-exp-rn5qt2

Expected result

The imported path should be exported in a visually identical way.

Additional information

macOS 13.6, Safari 17.0

@pzich
Copy link
Author

pzich commented Dec 13, 2023

I found that the issue here is I was using paper.Path instead of paper.CompoundPath. It seems that if you give the normal Path a pathData string containing multiple separate paths, it joins the end of each together.

It seems like this should either:

  • throw an error
  • log some sort of warning
  • automatically create a CompoundPath instead
  • only include one (probably the first?) shape in the pathData

@paradoxmr24
Copy link

Thanks a lot man, you are a life saver 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants