We have discovered that when trying to do multiline text in SVG the dy and dx attributes are not treaded correctly.
Sample svg:
<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xml:lang="en" viewBox="0 0 178 178" version="1.1">
<style type="text/css">
svg {
font-family: Times;
font-size: 44px;
}
</style>
<text x="0" y="0">
<tspan x="0" dy="1.2em">Tata</tspan>
<tspan x="0" dy="1.2em">Toto tu</tspan>
<tspan x="0" dy="1.2em">ppo</tspan>
</text>
</svg>
Expected output:

Acutal output:

If I change the dy's of the svg to
<text x="0" y="0">
<tspan x="0" dy="1.2em">Tata</tspan>
<tspan x="0" dy="2.4em">Toto tu</tspan>
<tspan x="0" dy="3.6em">ppo</tspan>
</text>
It produces the "correct" output.
I believe that it could be related to rsvg and it might be fixed in 2.45.7
- Fix #481: Don't ignore the first x/y/dx/dy in text/tspan elements if
there is more than one position specified.
But I have not been able to verify this because I'm having troubles with figuring out how to build sharp with a newer version of rsvg.
Using the rsvg-convert command line tool, librsvg version 2.44.10 works but version 2.45.5 (as used by the latest sharp) does not. The latest librsvg master branch (version 2.45.91) also fails.
This means it is very likely to be a recent regression in librsvg, possibly as a result of the move from C to Rust. Please can you report this upstream.
Upstream issue: https://gitlab.gnome.org/GNOME/librsvg/issues/494
Which version of sharp uses 2.44.10?
For Linux, the libvips v8.7.0 tarball as used by sharp v0.21.x provides librsvg v2.43.4.
$ npm i [email protected]
$ node -e "console.log(require('sharp').versions.svg)"
2.43.4
From upstream: This is fixed now on master, and the fix will appear in 2.45.91
https://gitlab.gnome.org/GNOME/librsvg/issues/494#note_579774
v0.24.0 is now available with a prebuilt librsvg with the upstream fix. Thanks for reporting this!