feat: configurable fonts

This commit is contained in:
Michael Aaron Murphy 2024-10-03 21:27:06 +02:00 committed by Michael Murphy
parent e645dee2f0
commit 9e064e7fa0
20 changed files with 143 additions and 124 deletions

View file

@ -10,59 +10,31 @@ use iced::{
};
use iced_core::font::Family;
pub const DEFAULT: Font = FONT;
pub const FONT: Font = Font {
family: Family::Name("Fira Sans"),
weight: iced_core::font::Weight::Normal,
stretch: iced_core::font::Stretch::Normal,
style: iced_core::font::Style::Normal,
};
pub const FONT_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-Regular.otf");
pub const FONT_LIGHT: Font = Font {
family: Family::Name("Fira Sans"),
weight: iced_core::font::Weight::Light,
stretch: iced_core::font::Stretch::Normal,
style: iced_core::font::Style::Normal,
};
pub const FONT_LIGHT_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-Light.otf");
pub const FONT_SEMIBOLD: Font = Font {
family: Family::Name("Fira Sans"),
weight: iced_core::font::Weight::Semibold,
stretch: iced_core::font::Stretch::Normal,
style: iced_core::font::Style::Normal,
};
pub const FONT_SEMIBOLD_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-SemiBold.otf");
pub const FONT_BOLD: Font = Font {
family: Family::Name("Fira Sans"),
weight: iced_core::font::Weight::Bold,
stretch: iced_core::font::Stretch::Normal,
style: iced_core::font::Style::Normal,
};
pub const FONT_BOLD_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-Bold.otf");
pub const FONT_MONO_REGULAR: Font = Font {
family: Family::Name("Fira Mono"),
weight: iced_core::font::Weight::Normal,
stretch: iced_core::font::Stretch::Normal,
style: iced_core::font::Style::Normal,
};
pub const FONT_MONO_REGULAR_DATA: &[u8] = include_bytes!("../res/Fira/FiraMono-Regular.otf");
pub fn load_fonts() -> Command<Result<(), Error>> {
Command::batch(vec![
load(FONT_DATA),
load(FONT_LIGHT_DATA),
load(FONT_SEMIBOLD_DATA),
load(FONT_BOLD_DATA),
load(FONT_MONO_REGULAR_DATA),
])
pub fn default() -> Font {
Font::from(crate::config::interface_font())
}
pub fn light() -> Font {
Font {
weight: iced_core::font::Weight::Light,
..default()
}
}
pub fn semibold() -> Font {
Font {
weight: iced_core::font::Weight::Semibold,
..default()
}
}
pub fn bold() -> Font {
Font {
weight: iced_core::font::Weight::Bold,
..default()
}
}
pub fn mono() -> Font {
Font::from(crate::config::monospace_font())
}