Commons:Requests for comment/Technical needs survey/Fix rsvg text alignment regression

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Previous proposal Overview page Next proposal

Fix rsvg text alignment regression[edit]

Description of the Problem[edit]

  • Problem description:

The latest thumbnail-image-maker (named rsvg) unfortunately has a bug which misaligns centre- or right-aligned text tags containing tspan tags on the same line. Many existing files have been affected.

  • Proposal type: bugfix / feature request / process request
  • Proposed solution:

Fix rsvg or use a version without the bug.

  • Phabricator ticket:

http://phabricator.wikimedia.org/T97233

  • Further remarks:

@Glrx: described the root cause as follows:

The problem is computing the width of an SVG "text chunk". If the text chunk consists of multiple XML nodes, then librsvg is using the width of the last node as the width of the entire text chunk. (librsvg is correctly tossing out the initial and final whitespace for the text element.)

Discussion[edit]

Yes, User:Minoa, I think that is the same problem. Having <tspan font-size="18">APPROVED</tspan> embedded in a <text> specification falls prey to this bug. RCraig09 (talk) 07:12, 22 December 2023 (UTC)[reply]
  •  Strong support: this has to be fixed, because the problem affected two of my uploads and the made centring of text with different font sizes tedious. --Minoa (talk) 03:18, 24 December 2023 (UTC)[reply]
    Thanks, @Minoa: not just tedious but strictly impossible, if the specified font is unavailable and another is substituted. cmɢʟee ⋅τaʟκ 01:36, 25 December 2023 (UTC)[reply]
    I personally recommend changing to a fasterer and less buggy renderer, see phab:T40010, in more details can be found at: User:JoKalliauer/SVG_test_suites  — Johannes Kalliauer - Talk | Contributions 14:16, 25 December 2023 (UTC)[reply]
  •  Comment This issue is not a problem with rsvg but rather WMF's development practices that use out-of-date software. Many years ago, Gnome (the developers of rsvg, rewrote rsvg in Rust (a programming language). WMF did not switch to the Rust version but rather continued to use the C++ version. The C++ version was no longer the primary focus of Gnome, but it did receive some important updates. One of those updates fixed the "text chunk" bug about 3 years ago for both the (actively supported) Rust and the (moribund) C++ versions. WMF was often updating the C++ version of rsvg, so the "text chunk" problem was fixed. WMF was using an ancient operating system image. In April 2023, WMF updated the operating system image, but it went from an ancient image to a (IIRC) 5-year-old image. The old version of the operating system now supported Rust and had a preloaded (but 5-year-old) Rust version of rsvg. Consequently, WMF effectively reverted to a much older Rust version and reintroduced the above "text chunk" issue. Glrx (talk) 17:23, 19 January 2024 (UTC)[reply]

Votes[edit]

  •  Strong support In practical terms: This bug causes <text> elements containing <tspan > sub-elements (for subscripting, italicizing, boldfacing, coloring, font-sizing, etc.) to be rendered in the wrong place in Wikipedia thumbnails and on Commons file description pages—despite rendering properly within browsers during development. Example: text that should be centered on the page, runs off the right margin. Over years, this bug has required me to revise a few dozen .svg images to specify all attributes within each <text> element, or even to compromise content to work around rendering problems. RCraig09 (talk) 06:32, 21 December 2023 (UTC)[reply]
— Examples: see earlier versions of these images: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14. — RCraig09 (talk) 22:34, 26 December 2023 (UTC)[reply]
@RCraig09: Another buggy file for your records. Cheers, cmɢʟee ⋅τaʟκ 06:15, 2 January 2024 (UTC)[reply]