This commit is contained in:
Antonio Scandurra 2023-10-21 18:33:08 +02:00
parent 7bb99c9b9c
commit 3740c9d852
3 changed files with 9 additions and 2 deletions

View file

@ -95,6 +95,10 @@ impl App {
pub fn executor(&self) -> Executor { pub fn executor(&self) -> Executor {
self.0.lock().executor.clone() self.0.lock().executor.clone()
} }
pub fn text_system(&self) -> Arc<TextSystem> {
self.0.lock().text_system.clone()
}
} }
type Handler = Box<dyn Fn(&mut AppContext) -> bool + Send + Sync + 'static>; type Handler = Box<dyn Fn(&mut AppContext) -> bool + Send + Sync + 'static>;

View file

@ -55,6 +55,10 @@ impl TextSystem {
} }
} }
pub fn add_fonts(&self, fonts: &[Arc<Vec<u8>>]) -> Result<()> {
self.platform_text_system.add_fonts(fonts)
}
pub fn font_id(&self, font: &Font) -> Result<FontId> { pub fn font_id(&self, font: &Font) -> Result<FontId> {
let font_id = self.font_ids_by_font.read().get(font).copied(); let font_id = self.font_ids_by_font.read().get(font).copied();
if let Some(font_id) = font_id { if let Some(font_id) = font_id {

View file

@ -652,8 +652,7 @@ fn load_embedded_fonts(app: &App) {
}); });
} }
})); }));
app.platform() app.text_system()
.fonts()
.add_fonts(&embedded_fonts.into_inner()) .add_fonts(&embedded_fonts.into_inner())
.unwrap(); .unwrap();
} }