linebender / linebender/resvg

Fill property not being respected on text

Open
#1,038 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.1k
Forks
348
Avg merge
1d 14h
Merged PRs (30d)
3

Description

I apologize if another issue already covers this; I'm not super knowledgeable about the SVG spec, so I'm not quite sure what should cover this.

I've got an SVG with coloured text, generated by Typst:
![Image](https://github.com/user-attachments/assets/a4cea247-4d2c-439a-b448-86521d388c42)

(Hopefully you should be able to use the above to get back an SVG file? If not let me know and I'll figure out another way -- perhaps a zip file?)

As you can see in the GitHub preview, the text is white & red, however when rendered with resvg, I get:

Image

I'm not entirely sure if this is an error on my part, or if this is a bug in resvg.

My code essentially amounts to:
```rs
let tree = Tree::from_data(svg.as_bytes(), &Options::default())?;
let mut buffer = Pixmap::new(...);

buffer.data_mut().fill(0); // resetting from a previous render

let size = tree.size();

let transform = Transform::from_scale(
buffer.width() as f32 / size.width(),
buffer.height() as f32 / size.height(),
);

resvg::render(
&tree,
transform,
&mut buffer,
);
```

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

The issue names no repository file or test. Start by obtaining the attached Typst-generated SVG and reproducing it with the shown Rust snippet, then compare the rendered text fills with the expected output. Done means the fill behavior is corrected or clearly narrowed to an SVG-spec issue, with a regression test for the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.