iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.69k stars 1.16k forks source link

Invisible text in svgs after updating to 0.3.0 #870

Closed PotatoSquid closed 12 months ago

PotatoSquid commented 3 years ago

An svg in iced 0.2.0:

svg in iced 0 2 0

The same svg in iced 0.3.0:

svg in iced 0 3 0

Code:

iced_svg_test.zip

hecrj commented 3 years ago

I think this is caused by resvg switching its renderer to tiny-skia, which does not support text (yet?).

alec-deason commented 1 year ago

I believe this is happening because resvg needs the convert_text method to be called on trees before they are rendered. But that requires a fontdb::Database loaded with fonts. I have a draft PR up (#1908) that shows doing that by naively loading all system fonts, the same way resvg's command line tool does it. And that works for my test case but it seems like the wrong approach given that iced already has a text system with a fontdb::Database in the iced_tiny_skia/iced_wgpu::text::Pipeline structs.

Since I'm brand new to this code base it's not obvious to me how the font database should be shared between the text pipeline and the svg pipeline, but it seems like it should. I'll poke around some more and see if I can work it out but I'd love guidance if anyone has some.

alec-deason commented 1 year ago

I updated the PR with a possible approach to sharing the font database across systems. It feels like it has some ugliness in how the database references get passed around but it works. I'd still love anyone's thoughts on how best to handle this.