linebender / linebender/resvg

Root svg transform inconsistent with Chromium/Firefox/Inkscape

Open
#899 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.1k
Forks
348
Avg merge
1d 14h
Merged PRs (30d)
3

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal SVG reproduction in the issue and compare resvg with Chromium, Firefox, and Inkscape. Inspect how root SVG transforms interact with the viewBox, using issue #874 as related context. Done means resvg renders the root transform consistently with the other implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.