feat: concurrently load & parse fonts

This commit is contained in:
Itsusinn 2024-04-28 18:29:32 +08:00 committed by Jeremy Soller
parent 5e82de11cf
commit 658025314c
3 changed files with 66 additions and 2 deletions

View file

@ -158,3 +158,26 @@ impl Font {
})
}
}
#[cfg(test)]
mod test{
#[test]
fn test_fonts_load_time(){
use crate::FontSystem;
use sys_locale::get_locale;
#[cfg(not(target_arch = "wasm32"))]
let now = std::time::Instant::now();
let mut db = fontdb::Database::new();
let locale = get_locale().unwrap();
db.load_system_fonts();
FontSystem::new_with_locale_and_db(locale, db);
#[cfg(not(target_arch = "wasm32"))]
println!(
"Fonts load time {}ms.",
now.elapsed().as_millis()
)
}
}