RTL text with multi-line <tspan dy> layout collapses onto one line (usvg 0.47.0)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 348
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Description
When a single `` element lays out multiple lines using per-`` dy offsets, and the text is RTL (Arabic/Persian, Hebrew, …), usvg positions the glyphs incorrectly: all lines collapse onto the first baseline and only the logically-first character of each subsequent `` receives the vertical offset. The same structure with LTR text lays out correctly.
This is a layout/positioning bug only — glyph selection and shaping (joining forms, ZWNJ, combining marks) are correct.
Example SVG:
```
```
Example to reproduce:
```
let mut opt = usvg::Options::default();
opt.fontdb_mut().load_system_fonts();
let tree = usvg::Tree::from_str(INPUT_SVG, &opt).unwrap();
// Freeze usvg's layout: glyphs become s at the computed positions.
let flattened = tree.to_string(&usvg::WriteOptions {
preserve_text: false,
..Default::default()
});
std::fs::write("flattened.svg", flattened).unwrap();
```
[A minimal example, but generated by AI.](https://github.com/user-attachments/files/30053791/usvg-example.zip)
One possible workaround is to use `y` instead of `dy`.
Thank you for your attention and support :)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Rust reproduction with the supplied SVG and compare the flattened output for RTL and LTR text. Trace usvg's text layout and positioning for per- dy offsets, then verify that RTL lines retain separate baselines while glyph shaping remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100