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

Respect viewBox attribute #73

Open
player-03 opened this issue Sep 23, 2022 · 0 comments
Open

Respect viewBox attribute #73

player-03 opened this issue Sep 23, 2022 · 0 comments

Comments

@player-03
Copy link

Inkscape, the foremost open source SVG editor, always inserts a viewBox attribute when it creates a new SVG. This library ignores viewBox, causing it to scale these images incorrectly.


To demonstrate, I made a new Inkscape file, resized the canvas to 128x128px, and filled it with a circle:

With viewBox

Which looks like this in the XML:

<svg
   width="128px"
   height="128px"
   viewBox="0 0 210 297"
   version="1.1">
  <!-- ... -->
</svg>

And looks like this when rendered in a browser:

drawing.svg


But that's taking viewBox into account, which openfl/svg doesn't. Here's what you get when you use this library:

rendered.png

Note that you get the exact same result if you delete the viewBox attribute in Inkscape:

Without viewBox


I may look into this further at some other point, but I'm hoping someone who already knows this library already knows where to go to fix this. I think you should scale based on the minimum of width and height, but don't quote me on it.

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

1 participant