iced: Most text characters not rendering
Is there an existing issue for this?
- I have searched the existing issues.
Is this issue related to iced?
- My hardware is compatible and my graphics drivers are up-to-date.
What happened?
Most characters do not render when trying to render text. It happens with text widgets, button widgets, etc. The only thing I’ve been able to find that correctly renders text is the text input. I tried to render just a simple text widget:
fn view(&self) -> iced::Element<'_, Self::Message> {
text("asd123+-=';*").into()
}
, and here is what I get:
When running the todos example, I get this:
As you can see, the button has no text and the spacing looks weird for the text input. If I type into the text input, I see this:
Suspiciously, those same characters that actually render for me show up weird here, with what looks like a different font, colour, and spacing. I tried playing around with changing the font, but to no avail.
What is the expected behavior?
I expected text to render correctly with no problems. I have successfully used iced 0.9 in the past and it worked fine, but 0.10 is broken for me.
Version
crates.io release
Operating System
Linux
Do you have any log output?
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 33 (14 by maintainers)
Hello, I’ve been hit by the invisible text mentioned above using either the master or the stable release of this crate. I’ve investigated the issue and I was able to find why it doesn’t work for everyone, at least why it doesn’t work for me. Some context, I am running Guix Linux which is a transactional distribution, you might be more familliar to NixOS, which uses the same concepts.
In simplier terms, both distribution uses a different file structures than the common HFS, multiples symlinks are used to make application or support file font available to the end user. The system mainly relies on fontconfig to ensure that all the fonts are picked up correctly by GUI application.
Looking at the history of this project, it was recently updated to use cosmic-text, that library uses the crate
fontdb
to generalize the access of the fonts on the different operating system. By default the libary on Linux based system look for font in the following directories:On the other hand Guix (I don’t remember NixOS’ installation path) install them in
~/.guix-home/profile/share/fonts/
and it updates fontconfig configuration with the path.By default fontdb doesn’t use fontconfig, see https://github.com/RazrFalcon/fontdb/blob/master/src/lib.rs#L392-L407, there an open issue https://github.com/RazrFalcon/fontdb/issues/56 that suggest enabling it by default.
Looking at the
cosmic-text
repository, thefontconfig
feature was just enabled in https://github.com/pop-os/cosmic-text/pull/174 but there are no official release of the library that include the change.If you update iced to use the
main
branch ofcosmic-text
, it correctly find the font to render.So for now the possible solution are:
I hope it help other people.
Thanks @ph, I fixed this on NixOS by changing the
cosmic-text
dependency to the following intiny_skia/Cargo.toml
: