SVG icon indicating copy to clipboard operation
SVG copied to clipboard

Multiple tspan not rendering correctly

Open TommyN opened this issue 3 years ago • 2 comments

Description

A SVG with multiple tspan elements below a text-node doesn't render correctly when converted to PNG. Below is a simple reproduction SVG using text-anchor "middle", <none> and "end" each with two child tspan elements.

Example data

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1080" height="1080">

  <g transform="translate(200 400)">
      <rect x="-150" y ="-50" width="300" height="100" rx="15" />
      <text text-anchor="middle" fill="#ffffff" font-size="26" font-family="Rubik-Regular, Rubik" letter-spacing="0em">
        <tspan style="font-weight: bold;fill: #ff0000">15</tspan>
        <tspan>Apples</tspan>
      </text>
  </g>

  <g transform="translate(200 600)">
      <rect x="-150" y ="-50" width="300" height="100" rx="15" />
      <text fill="#ffffff" font-size="26" font-family="Rubik-Regular, Rubik" letter-spacing="0em">
        <tspan style="font-weight: bold;fill: #ff0000">15</tspan>
        <tspan>Apples</tspan>
      </text>
  </g>

  <g transform="translate(200 800)">
      <rect x="-150" y ="-50" width="300" height="100" rx="15" />
      <text text-anchor="end" fill="#ffffff" font-size="26" font-family="Rubik-Regular, Rubik" letter-spacing="0em">
        <tspan style="font-weight: bold;fill: #ff0000">15</tspan>
        <tspan>Apples</tspan>
      </text>
  </g>

</svg>

image

It seems @Stoffelche found an issue that he commented on here: https://github.com/svg-net/SVG/issues/769#issuecomment-757167913

Related issue:

  • #459

Used Versions

Svg 3.3.0 .NET Framework 4.7

TommyN avatar Jan 11 '22 09:01 TommyN

I recently updated Chordious to .NET 6 and SVG 3.4.0, and am now seeing this regression.

Downgrading to SVG 3.1.1 seems to resolve the issue for me (though I'm not sure at what other cost).

jonthysell avatar Mar 08 '22 01:03 jonthysell

PR #782 will change rendering result. However, if revert this commit, everything will not be correct.

output

H1Gdev avatar Mar 14 '22 12:03 H1Gdev