Skip to content

Respect viewBox attribute #73

Description

@player-03

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions