Skip to content

SVG gradientUnits not handled correctly? #2613

@JeremyRand

Description

@JeremyRand

The below SVG image seems to be rendered with an incorrect gradient in WeasyPrint; WeasyPrint renders the entire shape as cyan, while the shape is supposed to be 5 colors (as observed in Firefox). I suspect (but have not proven) that the bug relates to the gradientUnits attribute, as the rendering in Firefox with this attribute removed matches the rendering in WeasyPrint with this attribute present.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns="http://www.w3.org/2000/svg"
   width="530.00037"
   height="123.07568"
   version="1.1">
  <defs>
    <linearGradient id="gradient1" x1="0" x2="0" y1="314" y2="348" gradientUnits="userSpaceOnUse">
      <stop offset="0%" stop-color="#5BCEFA" />
      <stop offset="20%" stop-color="#5BCEFA" />
      <stop offset="20%" stop-color="#F5A9B8" />
      <stop offset="40%" stop-color="#F5A9B8" />
      <stop offset="40%" stop-color="white" />
      <stop offset="60%" stop-color="white" />
      <stop offset="60%" stop-color="#F5A9B8" />
      <stop offset="80%" stop-color="#F5A9B8" />
      <stop offset="80%" stop-color="#5BCEFA" />
      <stop offset="100%" stop-color="#5BCEFA" />
    </linearGradient>
  </defs>
  <g
     transform="translate(62.781694,-470.2193)">
    <g
       transform="matrix(1.4378176,0,0,1.4378176,-369.49057,-753.39275)">
      <g
         transform="matrix(1.0286879,0,0,1.0286879,-47.28006,553.99226)"
         style="fill:url(#gradient1)">
        <path
           id="path5-1"
           d="m 345.423,316.135 c 0.703,-0.207 1.478,-0.442 2.325,-0.713 0.847,-0.27 1.798,-0.518 2.852,-0.744 1.054,-0.226 2.232,-0.414 3.534,-0.559 1.302,-0.146 2.779,-0.217 4.433,-0.217 4.877,0 8.225,1.405 10.044,4.217 1.818,2.811 2.128,6.654 0.93,11.531 l -4.216,17.606 h -9.238 l 4.092,-17.235 c 0.248,-1.074 0.443,-2.117 0.589,-3.132 0.145,-1.012 0.134,-1.899 -0.031,-2.666 -0.166,-0.764 -0.548,-1.383 -1.147,-1.858 -0.6,-0.476 -1.519,-0.713 -2.759,-0.713 -1.199,0 -2.418,0.123 -3.658,0.371 l -6.014,25.233 h -9.238 l 7.502,-31.121 z"
            />
      </g>
    </g>
  </g>
</svg>

Tested with Git commit 0220156 (the bug also shows up in v62.3 as packaged in Debian Forky). Let me know if there's anything I can do to help reproduce this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugExisting features not working as expected

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions