Page MenuHomePhabricator

librsvg 2.44.10 causes a regression: <text> with text-anchor="middle" and multiple <tspan>s is misaligned
Closed, DuplicatePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

  • The text labels overlap with the shapes.

What should have happened instead?:

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

Cmglee renamed this task from librsvg 2.44.10 causes <text> with text-anchor="middle" and multiple <tspan>s to be misaligned to librsvg 2.44.10 causes a regression: <text> with text-anchor="middle" and multiple <tspan>s is misaligned.May 17 2023, 6:15 PM
JoKalliauer changed the task status from Open to Stalled.May 19 2023, 12:27 PM
JoKalliauer triaged this task as Low priority.
JoKalliauer added projects: Upstream, Thumbor, Commons.
descriptionSVG-filelibrsvg 2.40(svgcheck)librsvg2.44(Wikimedia)librsvg2.56(Fedora38)resvginkscape
descriptionsvg-file
sixth power example_svgcheck.png (400×400 px, 27 KB)
20230515045519!Sixth_power_example.svg.png (400×400 px, 24 KB)
Sixth power example_librsvg.png (400×400 px, 25 KB)
Sixth power example_rendersvg.png (400×400 px, 122 KB)
Sixth power example_Inkscape.png (400×400 px, 27 KB)

Screenshot_20230521_003321.png (758×1 px, 306 KB)

A haphazard build of 2.56.0 does not show this issue. See build instructions in https://phabricator.wikimedia.org/T265549#8868748.

1.png (2×2 px, 219 KB)

Renderer miscalculates the width of a text chunk.

See T97233

Instead of using the width of all constituents of the text chunk, librsvg uses the width of the last constituent.

For OP's first example, text-anchor: end; was in effect for

<text x="340"  y="180"><tspan >4</tspan><tspan dy="-1ex" font-size="80">3</tspan></text>

Width used is just of the second tspan, so the current position is only adjusted by the width the "3" rather than "4" and "3".

More tests are at
*https://commons.wikimedia.org/wiki/File:SVG_Text_Chunk_Test.svg

Gnome fixed this bug two years ago. They apparently fixed it in both the C and Rust versions then. It has reappeared on MW because we went from a recent C version to an old Rust version.

So I see this issue as a dup of T97233