Skip to content

Bug fixes for RTL text and dx/dy - #1145

Merged
LaurenzV merged 2 commits into
linebender:mainfrom
teolines:fix-rtl-relative-shift
Oct 9, 2026
Merged

LaurenzV merged 2 commits into
linebender:mainfrom
teolines:fix-rtl-relative-shift

Conversation

@teolines

Copy link
Copy Markdown
Contributor

Right-to-left text with dy shifts collapsed onto one line. The shifts are now applied in logical order instead of screen order.

Fixes #1093

LLM Contributions: investigation, implementation and tests with Claude Code, reviewed by me. The description is my own, edited for grammar.

teolines and others added 2 commits October 9, 2026 13:28
`dx` and `dy` shift a character and every character after it in logical
order, but the shifts were accumulated while positioning the clusters in
visual order. In right-to-left text, the first character is the last
cluster, so a `dy` on a `tspan` only moved its first character, and a
multi-line text collapsed onto its first line.

Accumulate the shifts in logical order before positioning the clusters.
Left-to-right text is unchanged.

Fixes linebender#1093
`text-anchor` positioned a chunk by the sum of its advances, ignoring how
`dx` and `textLength` move the characters. Anchor it by the actual extent
of its characters instead, as described by the SVG 2 text layout algorithm.
`textLength` spacing only moves characters, so it isn't part of the extent.

Text on a path also accumulated `dx` and `dy` in visual order. Share the
logical order shift resolution with horizontal text.

Text decorations were split at the cluster that owns a `dx` or `dy`, which
is only where the shift changes in left-to-right text. Split them wherever
neighboring clusters have a different shift instead.
@LaurenzV
LaurenzV force-pushed the fix-rtl-relative-shift branch from cfb199a to b1ce728 Compare October 9, 2026 14:28
@LaurenzV LaurenzV changed the title Apply dx and dy in logical order in right-to-left text Bug fixes for RTL text and tx/ty Oct 9, 2026
@LaurenzV LaurenzV changed the title Bug fixes for RTL text and tx/ty Bug fixes for RTL text and dx/dy Oct 9, 2026
@LaurenzV

LaurenzV commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Oh man text is complicated... I looked into it a bit more and found some more issues, it's probably still not 100% correctly but we have more passing tests now, so hopefully this is an improvement.

@LaurenzV

LaurenzV commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

@LaurenzV
LaurenzV merged commit 101e3f1 into linebender:main Oct 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTL text with multi-line <tspan dy> layout collapses onto one line (usvg 0.47.0)

2 participants