feat: helper for loading fonts

This commit is contained in:
Ashley Wulber 2023-05-10 13:15:56 -04:00
parent 0c1396cac3
commit eb0fcf5278
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
3 changed files with 19 additions and 15 deletions

View file

@ -2,23 +2,24 @@
// SPDX-License-Identifier: MPL-2.0
pub use iced::Font;
use iced::{
font::{load, Error},
Command,
};
pub const FONT: Font = Font::with_name("Fira Sans Regular");
// pub const FONT: Font = Font::External {
// name: "Fira Sans Regular",
// bytes: include_bytes!("../res/Fira/FiraSans-Regular.otf"),
// };
pub const FONT_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-Regular.otf");
pub const FONT_LIGHT: Font = Font::with_name("Fira Sans Light");
// pub const FONT_LIGHT: Font = Font::External {
// name: "Fira Sans Light",
// bytes: include_bytes!("../res/Fira/FiraSans-Light.otf"),
// };
pub const FONT_LIGHT_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-Light.otf");
pub const FONT_SEMIBOLD: Font = Font::with_name("Fira Sans SemiBold");
pub const FONT_SEMIBOLD_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-SemiBold.otf");
// pub const FONT_SEMIBOLD: Font = Font::External {
// name: "Fira Sans SemiBold",
// bytes: include_bytes!("../res/Fira/FiraSans-SemiBold.otf"),
// };
pub fn load_fonts() -> Command<Result<(), Error>> {
Command::batch(vec![
load(FONT_DATA),
load(FONT_LIGHT_DATA),
load(FONT_SEMIBOLD_DATA),
])
}