`<text>` with `font-size="0px"` containing empty `<tspan>` followed by whitespaces is rendered in the wrong location
Open
Nobody has claimed this yet.
bug
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 348
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Description
resvg version: 0.41.0
When a <text> with font-size="0px" starts with an empty <tspan> followed by whitespace, the <text> is rendered in the wrong place.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="300px" height="300px" version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mei="http://www.music-encoding.org/ns/mei"
overflow="visible">
<svg viewBox="-100 -100 400 400">
<!-- Rendered in a wrong location -->
<text x="40" y="80" font-size="0px">
<tspan></tspan>
<tspan font-size="48px">Text</tspan>
</text>
<!-- Rendered correctly -->
<text x="40" y="120" font-size="0px">
<tspan font-size="48px">Text</tspan>
<tspan></tspan>
</text>
<!-- Rendered correctly -->
<text x="40" y="160" font-size="1px">
<tspan></tspan>
<tspan font-size="48px">Text</tspan>
</text>
<!-- Rendered correctly -->
<text x="40" y="200" font-size="0px"><tspan></tspan><tspan font-size="48px">Text</tspan></text>
<!-- Rendered correctly -->
<text x="40" y="240" font-size="0px">
<tspan font-size="48px">Text</tspan>
</text>
</svg>
</svg>
Render result:
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 reproducing the supplied SVG, then trace resvg's SVG text layout and positioning behavior for zero font-size text containing empty tspans and whitespace. Done means the first example renders at the intended position while the other provided cases remain correct.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100