Skip to content
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

Loading Custom Fonts #39

Open
discordance opened this issue Sep 9, 2023 · 0 comments
Open

Loading Custom Fonts #39

discordance opened this issue Sep 9, 2023 · 0 comments

Comments

@discordance
Copy link

Looks like iced 0.10 have a new way to load custom fonts. It's not really documented, but using the wgpu integration example, I was able to load the fonts via the renderer instance:

// This is the WGPU renderer
let wgpu_renderer = iced_wgpu::Renderer::new(Backend::new(&device, &queue, Settings::default(), format));

// We wrap the renderer in a type that implements the iced renderer trait
let mut renderer = iced_renderer::Renderer::Wgpu(wgpu_renderer);

// load custom fonts
renderer.load_font(Cow::from(MY_CUSTOM_FONT1_BYTES)); // &[u8]
renderer.load_font(Cow::from(MY_CUSTOM_FONT2_BYTES)); // &[u8]

Then, you can use those fonts using Family::Name("CustomFontName").

I am experimenting on my fork passing fonts extending the IcedBaseviewSettings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant