fix(app): preload embedded Fira fonts
This commit is contained in:
parent
73f0596650
commit
173a9557c2
2 changed files with 26 additions and 8 deletions
|
|
@ -45,6 +45,8 @@ pub mod message {
|
|||
}
|
||||
}
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub use self::command::Command;
|
||||
pub use self::core::Core;
|
||||
pub use self::settings::Settings;
|
||||
|
|
@ -72,6 +74,8 @@ pub(crate) fn iced_settings<App: Application>(
|
|||
settings: Settings,
|
||||
flags: App::Flags,
|
||||
) -> iced::Settings<(Core, App::Flags)> {
|
||||
preload_fonts();
|
||||
|
||||
let mut core = Core::default();
|
||||
core.debug = settings.debug;
|
||||
core.icon_theme_override = settings.default_icon_theme.is_some();
|
||||
|
|
@ -882,3 +886,21 @@ fn single_instance_subscription<App: ApplicationExt>() -> Subscription<Message<A
|
|||
},
|
||||
)
|
||||
}
|
||||
|
||||
const EMBEDDED_FONTS: &[&[u8]] = &[
|
||||
include_bytes!("../../res/Fira/FiraSans-Light.otf"),
|
||||
include_bytes!("../../res/Fira/FiraSans-Regular.otf"),
|
||||
include_bytes!("../../res/Fira/FiraSans-SemiBold.otf"),
|
||||
include_bytes!("../../res/Fira/FiraSans-Bold.otf"),
|
||||
include_bytes!("../../res/Fira/FiraMono-Regular.otf"),
|
||||
];
|
||||
|
||||
fn preload_fonts() {
|
||||
let mut font_system = iced::advanced::graphics::text::font_system()
|
||||
.write()
|
||||
.unwrap();
|
||||
|
||||
EMBEDDED_FONTS
|
||||
.into_iter()
|
||||
.for_each(move |font| font_system.load_font(Cow::Borrowed(font)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue