#![cfg(feature = "unstable-fontique-011")]
use slint::fontique_011::fontique;
#[test]
fn register_fonts_before_platform_init() {
unsafe { std::env::set_var("SLINT_BACKEND", "testing") };
let font_data = std::fs::read(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../internal/common/sharedfontique/Inter-VariableFont.ttf"
))
.unwrap();
let blob = fontique::Blob::new(std::sync::Arc::new(font_data));
let mut collection = slint::fontique_011::shared_collection();
let fonts = collection.register_fonts(blob, None);
let (family_id, font_infos) = fonts.first().expect("no font was registered");
assert!(!font_infos.is_empty());
assert_eq!(collection.family_name(*family_id), Some("Inter"));
let script = fontique::Script::from_str_unchecked("Hani");
collection
.append_fallbacks(fontique::FallbackKey::new(script, None), fonts.iter().map(|x| x.0));
assert!(
collection
.fallback_families(fontique::FallbackKey::new(script, None))
.any(|id| id == *family_id),
"the registered font is not in the fallback chain"
);
let invalid = fontique::Blob::new(std::sync::Arc::new(b"donotexist.ttf".to_vec()));
assert!(collection.register_fonts(invalid, None).is_empty());
}