linebender / linebender/resvg

`<text>` with `font-size="0px"` containing empty `<tspan>` followed by whitespaces is rendered in the wrong location

Open
#739 6 comments 0 reactions 0 assignees View on GitHub

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:
out

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.