Skip to content

Root svg transform inconsistent with Chromium/Firefox/InkscapeΒ #899

@reznakt

Description

@reznakt

I have found that resvg renders this SVG inconsistently with Chromium/Firefox/Inkscape:

<svg xmlns="http://www.w3.org/2000/svg" height="1000" transform="scale(.5)" viewBox="5 5 100 100" width="1000">
  <g>
    <circle cx="10" cy="10" r="3" stroke="black" stroke-width=".1"/>
    <circle cx="20" cy="10" r="3" stroke="black" stroke-width=".1"/>
    <line stroke="black" stroke-width=".1" x1="10" x2="20" y1="10" y2="10"/>
  </g>
</svg>

Here's a comparison of the output of Firefox/Chromium/Inkscape (left) and resvg (right):

I suspect the culprit here is probably the transform on the root SVG coupled with viewBox. I believe the support for transform on the svg element was added in SVG 2 and there have been inconsistencies among implementations in the past (see f.e. https://lists.w3.org/Archives/Public/www-svg/2015May/0024.html).

The output of resvg seems to be equivalent to rendering the following SVG with f.e. Firefox:

<svg xmlns="http://www.w3.org/2000/svg" height="1000" viewBox="5 5 100 100" width="1000">
  <g transform="scale(.5)">
    <circle cx="10" cy="10" r="3" stroke="black" stroke-width=".1"/>
    <circle cx="20" cy="10" r="3" stroke="black" stroke-width=".1"/>
    <line stroke="black" stroke-width=".1" x1="10" x2="20" y1="10" y2="10"/>
  </g>
</svg>

Might be related to #874.

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