🐛 Fix asynchronous content dependant rendering (#6142)

* 🐛 Fix custom fonts rendering

* 🐛 Fix asynchronous content dependant rendering

* 🎉 Renaming clear_cache to clear_drawing_cache
This commit is contained in:
Alejandro 2025-03-25 09:49:47 +01:00 committed by GitHub
parent 9653e72e47
commit 065b50f5a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 10 deletions

View file

@ -1,4 +1,4 @@
use skia_safe::{self as skia, textlayout, Font};
use skia_safe::{self as skia, textlayout, Font, FontMgr};
use crate::shapes::FontFamily;
@ -31,8 +31,8 @@ impl FontStore {
font_provider.register_typeface(emoji_font, DEFAULT_EMOJI_FONT);
let mut font_collection = skia::textlayout::FontCollection::new();
font_collection.set_default_font_manager(Some(font_provider.clone().into()), None);
font_collection.set_dynamic_font_manager(Some(font_provider.clone().into()));
font_collection.set_default_font_manager(FontMgr::default(), None);
font_collection.set_dynamic_font_manager(FontMgr::from(font_provider.clone()));
let debug_typeface = font_provider
.match_family_style("robotomono-regular", skia::FontStyle::default())
@ -72,6 +72,8 @@ impl FontStore {
self.font_provider
.register_typeface(typeface, alias.as_str());
self.refresh_font_collection();
Ok(())
}
@ -79,4 +81,12 @@ impl FontStore {
let serialized = format!("{}", family);
self.font_provider.family_names().any(|x| x == serialized)
}
fn refresh_font_collection(&mut self) {
self.font_collection = skia::textlayout::FontCollection::new();
self.font_collection
.set_default_font_manager(FontMgr::default(), None);
self.font_collection
.set_dynamic_font_manager(FontMgr::from(self.font_provider.clone()));
}
}