Support RTL SVG text anchoring#2755
Open
moreaki wants to merge 2 commits into
Open
Conversation
This was referenced Apr 22, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
SVG text now passes
direction="ltr"/direction="rtl"to the Pango text layout used for SVG text drawing.text-anchorhandling also now follows the SVG inline-base direction:startkeeps the current behavior and extends right fromx.starttreatsxas the right edge and extends left.endtreatsxas the left edge and extends right.This is a small step toward #106 and is stacked on #2754.
Why
SVG 2 defines the
directionproperty as the inline-base direction for SVG text. It determines the start/end points used bytext-anchor, and it can affect text positioning when bidi properties are involved:https://svgwg.org/svg2-draft/text.html#DirectionProperty
Before this change, SVG direction attributes were cascaded but ignored when building the text layout style, so SVG text anchoring stayed effectively LTR.
Visual proof
Source SVG:
Rendered PNG:
The HTML wrapper used to render the proof is:
Scope
This does not implement full RTL/bidi support. In particular, it does not solve the SVG 2 mapping of per-character
x,y,dx,dy, androtatelists onto shaped visual glyph clusters after bidi reordering.Tests