linebender / linebender/resvg

Failed to rendering a text in nested SVG

Open
#740 8 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

I wrote are two SVGs and I nested those and I got a blank image unexpectedly.

Is this a bug...? (Sorry. I can't classify that problem as bug, unimplemented feature, undefined behaviour or something else, because I'm not an expert of SVG specification.)

Version: 0.41.0
OS: Windows 11 23H2 22631.3447 (x86_64) and Arch Linux.

I got a same results in --use-fonts-dir option.

Text containing SVG (child.svg)

Works expectedly if this file only.
This file just needs to contain a text element.
But I wrote some elements and attributes for visiblity.

Note: I choose a Noto Sans but this problem is occured too in any system fonts.

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" width="100px" height="100px">
	<rect x="25" y="25" width="25" height="25" fill="red" />
	<text
		x="50" y="50" dominant-baseline="middle" text-anchor="middle"
		font-size="25" font-family="Noto Sans"
		fill="black"
	>
		Hello
	</text>
</svg>
Rendered Image (child.svg):
resvg child.svg child.png

child

Parent SVG (parent.svg)

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" width="100px" height="100px">
	<image x="0" y="0" width="100" height="100" href="child.svg" />
</svg>
Rendered Image (parent.svg):
resvg parent.svg parent.png
Actually behaviour (parent.svg)

parent

and I got warning:

Warning (in usvg::text::layout:1115): No match for '"Noto Sans"' font-family.
Expected behaviour (parent.svg)

Completly same as child.svg in this case.

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

Reproduce the issue with the provided child.svg and parent.svg files, then inspect nested SVG image handling and font resolution. The fix is complete when rendering parent.svg produces the same visible text as child.svg without the missing-font warning.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.