-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text shaping and font fallback #33
Comments
After the report in #48, I did a bit of research on script-aware font fallback in |
Recently, it seems that a new player is comming. |
Something else to follow: a native Rust harfbuzz port, which will unlock vector text in WASM. Both by @RazrFalcon. |
Hi! I hope to finish I also plan to write a font matching library, similar to what |
Hey @RazrFalcon, really looking forward to
My knowledge when it comes to this is very limited. I shared a couple of links in a previous comment, but I imagine you are probably aware of them already. I agree having a shared solution would be great. Is the challenge here related to creating a solution that is decoupled from the font parsing/matching library?
Sounds great! Iced would benefit from this too. As of now, Let me know if you have any ideas about how we could help you in your efforts. |
I guess the best one I've saw is: https://raphlinus.github.io/rust/skribo/text/2019/04/04/font-fallback.html But it has more questions than answers. Also, sort of related: https://lord.io/blog/2019/text-editing-hates-you-too/
The biggest problem is the algorithm itself. I'm not an expert either, but afaiu the algorithm involves:
Also, Right now I'm focused only on shaping and font matching, so a font fallback can be implemented on top of them.
Free testers are the best resource 😄 |
As far as I understand there are two main approaches to font fallback:
Skribo aims to eventually provide one of those (not just wrap Harfbuzz) but as you found it’s not there yet. |
@SimonSapin I'm not sure it's possible (or at least robust). HarfBuzz uses font-based, script-based text normalization, which checks not only |
Waiting for iced-rs/iced#33 to be resolved
I noticed, this is on Druid's todo list as well. @RazrFalcon How "ready" is rustybuzz these days? |
Hi I currently am writing a chat client so font fallbacks are a must for me to do emoji. Can you give any hint on how to use kas-text with iced or is that also a non simple job? (aka needs changes to iced). |
@MTRNord that would be quite a significant change to Iced. Also, KAS-text doesn't support emojis or embedded images yet. |
This issue is opened in 2019 and still being open. |
Funny thing is: Iced version 0.3 supported Unicode characters. At least I'm able to set button's text to Cyrillic. And version 0.4 used to support Unicode. I found this commit (https://github.com/iced-rs/iced/tree/15a13a76b4b0534d08afc0328b90267048e41b9d) is allowing me to use Cyrillic and Arabic characters (but not Chinese)... What happened? Why does Iced still use Strings (that support UTF-8 out of the box), but not Unicode? |
Ok, I investigated further. Looks like last commit that supports Unicode (Cyrillic) is https://github.com/iced-rs/iced/tree/1e3feee3a36f25d7e2eda231c3e6b895858952c5 Next commit https://github.com/iced-rs/iced/tree/825c7749ff364cf1f7ae5cab0c25f27ed85c7d82 breaks Unicode support. |
And... simply adding |
UTF-8 is a compressed version of Unicode. This is where the Unicode Char that is a 32bit variable is then transformed into a [u8] pattern based on the symbol used. For example, English symbols would fit into a single u8 while Japanese might only fit into [u8;3]. This is done to reduce the storage space needed to store certain Symbols which are more heavily used than other symbols. Also yes for some reason he disabled the default_system_font from being set on default. |
Thanks for the information about tofu/mojibake. In my defense I may add that my OS (Win 10) is fully Cyrillic and I don't expect to see tofu or mojibake characters anywhere. My concern is the disabled |
@unreal79 PRs welcome 😉 |
Is there any alternative to display coloured emoji? |
Text shaping and font fallback are landing for |
wgpu_glyph
usesglyph-brush
, which in turn usesrusttype
. While the current implementation is able to layout text quite nicely, it does not perform any text shaping.Text shaping with font fallback is a necessary feature for any serious GUI toolkit. It unlocks support to truly localize your application, supporting many different scripts.
The only available library that does a great job at shaping is HarfBuzz, which is implemented in C++.
skribo
seems to be a nice HarfBuzz wrapper for Rust.This feature will probably imply rewriting
wgpu_glyph
entirely, as caching will be more complicated and the API will probably need to ask for more data.The text was updated successfully, but these errors were encountered: