Skip to content

anyrender_svg: don't apply text transform twice - #79

Closed
nicoburns wants to merge 1 commit into
mainfrom
devin/1786157279-svg-text-transform
Closed

anyrender_svg: don't apply text transform twice#79
nicoburns wants to merge 1 commit into
mainfrom
devin/1786157279-svg-text-transform

Conversation

@nicoburns

@nicoburns nicoburns commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

SVG <text> was rendered with its transform applied twice, so text on e.g. shields.io badges (https://img.shields.io/crates/v/blitz.svg, which wraps text in <g transform="scale(.1)"> with font-size="110") ended up 100× too small and mispositioned (effectively invisible).

In render_group, each child's abs_transform() is pre-multiplied into transform before dispatch. The children of usvg::Text::flattened() already carry the text node's absolute transform, so the Node::Text branch must recurse with Affine::IDENTITY (as the Node::Group branch does), not with the accumulated transform:

 usvg::Node::Text(text) => {
-    render_group(scene, text.flattened(), transform, global_transform, error_handler);
+    render_group(scene, text.flattened(), Affine::IDENTITY, global_transform, error_handler);
 }

Verified via Blitz's screenshot example: badge text now renders identically to resvg's reference output.

Before / after (rendered by Blitz):

before
after

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/e3ee5d93814646ef9f657861d05792d9
Requested by: @nicoburns

The children of usvg's flattened text group already carry the text
node's absolute transform, so recursing with the accumulated transform
applied it twice, misplacing and mis-scaling all SVG text.
@nicoburns nicoburns self-assigned this Aug 8, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@staging-devin-ai-integration

Copy link
Copy Markdown

Superseded by DioxusLabs/resvg#2, which reverts the usvg 0.48 behaviour change instead — with that revert, the existing anyrender_svg code is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant