-
Notifications
You must be signed in to change notification settings - Fork 110
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
Allow setting the fallback fonts #126
Comments
It's possible to set fallback fonts. I was trying to compile for WASM and stumbled onto this issue. Looks line let mut fonts = vec![];
for mut font in [
DEJAVU_SANS,
DEJAVU_SANS_BOLD,
DEJAVU_SANS_BOLD_OBLIQUE,
DEJAVU_SANS_OBLIQUE,
] {
let mut data = vec![];
if let Err(e) = lzma_rs::lzma_decompress(&mut font, &mut data) {
panic!("Failed to load embedded font: {}", e);
} else {
fonts.push(Source::Binary(Arc::new(data)));
}
}
let fonts_system = FontSystem::new_with_fonts(fonts.into_iter()); I was able to render text on the web using this |
Did you test it thoroughly? It seems like it would work on Linux, but not for Windows where there are different fallback fonts. |
I'm trying to add support for WASM to my
piet-cosmic-text
crate by embedding a font into the executable. However, it seems that, even after I set the font usingset_sans_serif_font
on thefontdb::Database
, I get this panic:It would be nice to be able to set the fallback font to something such that it can be used in the event where none are available.
cc notgull/piet-cosmic-text#11
The text was updated successfully, but these errors were encountered: