[go: up one dir, main page]

Page MenuHomePhabricator

Offer to invert text-anchor for RTL languages
Open, Needs TriagePublicBUG REPORT

Description

When writing about Positioning text for easier translation, I realized that the suggestion of "using text-anchor properly" breaks down for RTL languages. Basically the story goes:

  • You want to label something to the text's right, so you want right-alignment for positioning to be independent of text length. For English that's text-anchor: end, and it works for other LTR languages like Chinese too. (Or maybe to the left, in which case you do start. Or maybe above or below, you get the point.)
  • You realize that RTL languages exist. You feed the thing through SVG Translate Tool, and paste in some random Arabic test for testing.
  • Since the tool does not yet invert the anchor, your output is all messed up. Anchoring to the end becomes left-align, so you see text colliding with the object you have meant to label.

The SVG-TT can have a little checkbox to deal with these things. center stays as center, but start and end are swapped, CSS or XML attribute.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

The issue is much more complicated.

text-anchor, direction, and BIDI interact.

For the most part, SVG Translate should be able to ignore the problem by assuming that direction="ltr" and the .textContent will be strong LTR or strong RTL. In that case, BIDI reordering does the right thing. All text starts out LTR and has an appropriate text-anchor. If RTL text is encountered, Unicode BIDI embeds the RTL text into a separate RTL block within the initial LTR block. Doing nothing sort of works out. Things break down if some strong LTR text is encountered after the RTL: it will be placed to the right rather than the left of the RTL text block. But as long as the .textContent does not change direction, it will work out.

If one wants to do it right, then one must change both direction and text-anchor.

But that gets into trouble immediately. librsvg does not handle text-anchor correctly when when direction is RTL.

https://commons.wikimedia.org/wiki/File:SVG_Test_TextAlign.svg

The clever way to handle swapping text-anchor and direction is to put them in a CSS style element, but librsvg does not handle language selectors (e.g., :lang(ar)) or attribute selectors (e.g., [systemLanguage="ar"]).

To add more confusion, CSS text-align uses left or right in addition to (the experimental) start or end. IIRC, SVG 1.1 does not have that property.

The simple version is this issue is stalled until librsvg is fixed or WMF uses a different renderer.

Every time I hear a librsvg bug, I can't help but ask: "is it a Debian stable librsvg bug or an actual librsvg bug?" (urgh) And indeed, a quick test using rsvg-convert from libsrvg 2.50 shows the red and black text on the last line overlapping fine.

(Angry remarks about Debian "stale" and "please backport from testing" omitted.)

JMcLeod_WMF changed the subtype of this task from "Task" to "Bug Report".Aug 15 2022, 2:24 PM

From [[ T271663#7050425 | Arthur2e5's comment ]], it sounds like the best way to handle this will be to wait for a librsvg upgrade and see if the problem is still there before starting work on it. Note that we have no timeline for (or control over) librsvg in Production, but we will keep an eye on this ticket, and revisit it if more information becomes available.

@JMcLeod_WMF: Does that imply that this task should have stalled status && its blocking subtask (via "Edit Related Tasks... 🡒 Edit Subtasks") should be set to T265549?

JMcLeod_WMF changed the task status from Open to Stalled.Aug 17 2022, 1:27 PM

@Aklapper yes, thank you. I have updated the ticket.

Has this issue been fixed by the upgrade and the improved text-anchor behaviours?

@Arthur2e5: Could you please answer the last comment? Thanks in advance!

If we're talking about File:SVG_Test_TextAlign.svg: I believe the RTL issue as shown by the KV 15 arabic text is being shown correctly on Commons now. As a result, *if* we get SVG Translate Tool to flip start/end, it will work as expected.

Several other rsvg bugs shown have not yet been fixed, but I do not believe they affect this request.

Pppery subscribed.

If we're talking about File:SVG_Test_TextAlign.svg: I believe the RTL issue as shown by the KV 15 arabic text is being shown correctly on Commons now. As a result, *if* we get SVG Translate Tool to flip start/end, it will work as expected.

Several other rsvg bugs shown have not yet been fixed, but I do not believe they affect this request.

Assuming that means this task can be closed as resolved.

If we're talking about File:SVG_Test_TextAlign.svg: I believe the RTL issue as shown by the KV 15 arabic text is being shown correctly on Commons now. As a result, *if* we get SVG Translate Tool to flip start/end, it will work as expected.

Several other rsvg bugs shown have not yet been fixed, but I do not believe they affect this request.

Assuming that means this task can be closed as resolved.

That does not imply resolution. This issue is about an SVG Translate feature request. Bugs in WMF's renderer would hinder the SVG Translate feature. Apparently, the renderer has been fixed, but that still leaves the feature request open.