diff --git a/src/fontique/backend/android.rs b/src/fontique/backend/android.rs index bc1efe58..37d77a31 100644 --- a/src/fontique/backend/android.rs +++ b/src/fontique/backend/android.rs @@ -31,7 +31,7 @@ pub struct SystemFonts { pub name_map: Arc, pub generic_families: Arc, family_map: HashMap, - locale_fallback: Box<[(LanguageIdentifier, FamilyId)]>, + locale_fallback: Box<[(Box, FamilyId)]>, script_fallback: Box<[(Script, FamilyId)]>, } @@ -114,6 +114,7 @@ impl SystemFonts { }) { for lang in langs { if let Some(scr) = lang.strip_prefix("und-") { + // Undefined lang for script-only fallbacks script_fallback.push((scr.into(), *family)); } else if let Ok(locale) = LanguageIdentifier::try_from_bytes( @@ -121,6 +122,7 @@ impl SystemFonts { ) { if let Some(scr) = locale.script { + // Also fallback for the script on its own script_fallback .push((scr.as_str().into(), *family)); if "Hant" == scr.as_str() { @@ -133,7 +135,8 @@ impl SystemFonts { .push(("Hani".into(), *family)); } } - locale_fallback.push((locale, *family)); + locale_fallback + .push((locale.to_string().into(), *family)); } } } @@ -142,7 +145,7 @@ impl SystemFonts { // when postScriptName is unavailable. } - // family-specific fallback families, currently unimplimented + // family-specific fallback families, currently unimplemented // because it requires a GenericFamily to be plumbed through // the `RangedStyle` `font_stack` from `resolve` where it is // currently thrown away. @@ -181,7 +184,7 @@ impl SystemFonts { .and_then(|li| { self.locale_fallback .iter() - .find(|(lid, _)| li == lid.to_string()) + .find(|(lid, _)| li == lid.as_ref()) .map(|(_, fid)| *fid) }) .or_else(|| {