emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
20.61k stars 1.49k forks source link

egui_extras: feature `svg_text` #4659

Open xNWP opened 2 weeks ago

xNWP commented 2 weeks ago

Added

Changed

xNWP commented 2 weeks ago

that allow(unused_mut) caught my eye but otherwise lgtm

edit: i should really read commit messages first, could you put in a comment explaining it?

commented!

murl-digital commented 2 weeks ago

i think for demonstration purposes (and to make testing easier in the future), it'd be a good idea to add an example that shows text in svgs in action

xNWP commented 1 week ago

Would this text rendering work on web?

I was wondering the same thing shortly after making the PR 😅, I'm not great at web dev stuff but I'll take a look at it now and test some things.

i think for demonstration purposes (and to make testing easier in the future), it'd be a good idea to add an example that shows text in svgs in action

after checking the web stuff I'll also look at how y'all test/write example code and see what I can do 😊

xNWP commented 1 week ago

Would this text rendering work on web?

Short answer, no. Long answer is that the main workhorse of this PR is the load_system_fonts function on the Font Database type that resvg re-exports from the fontdb crate (https://github.com/RazrFalcon/fontdb/blob/fd24f8c9d7b57f30a6f6ba560c697a7854c94858/src/lib.rs#L352). This function is just a conditional compilation switch based on the target os which simply does nothing for wasm. I looked into how support could be added to this crate, however it looks like the way to do it would be the Local Font Access API which has little to no browser support (only experimental Chrome + Edge support) https://developer.mozilla.org/en-US/docs/Web/API/Local_Font_Access_API

emilk commented 5 days ago

Thanks for testing web. Please document your findings, i.e. document that the svg_text won't work on web, and why (linking to relevant issues, if any).

We should also figure out a solution to the duplicated dependencies.