yWorks/svg2pdf.js

Nested tspans don't work

edemaine opened this issue · 0 comments

Describe the bug
Nested <tspan>s don't seem to respect the hierarchy, and dy sometimes gets skipped. In my case, I need a <tspan> to advance each line (via dy) and nested <tspan>s to change the font within a line.

To Reproduce
See this playground.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 150">
  <text fill="black" style="font-size:40px">HELLO
    <tspan x="0" dy="1.25em"><tspan class="code">WORLD</tspan></tspan>
  </text>
</svg>

Expected behavior
I would have expected the PDF to render HELLO above WORLD, like in the SVG.
This is in accordance to the following SVG spec.
Instead HELLO and WORLD render on top of each other:

image

I believe the code is getting interpreted as if the first <tspan> was closed before the second one, so it doesn't render because it's empty.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Version: 101