Add forbidden font families

This commit is contained in:
Jeremy Soller 2022-10-14 09:38:27 -06:00
parent ce835d7014
commit 9519696a5b
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
5 changed files with 24 additions and 1 deletions

View file

@ -8,6 +8,11 @@ pub fn common_fallback() -> &'static [&'static str] {
]
}
// Fallbacks to never use
pub fn forbidden_fallback() -> &'static [&'static str] {
&[]
}
// Fallbacks to use per script
pub fn script_fallback(script: &Script, locale: &str) -> &'static [&'static str] {
//TODO: abstract style (sans/serif/monospaced)

View file

@ -123,10 +123,13 @@ impl<'a> Iterator for FontFallbackIter<'a> {
//TODO: do we need to do this?
//TODO: do not evaluate fonts more than once!
let forbidden_families = forbidden_fallback();
while self.other_i < self.fonts.len() {
let font = &self.fonts[self.other_i];
self.other_i += 1;
return Some(font);
if ! forbidden_families.contains(&font.info.family.as_str()) {
return Some(font);
}
}
self.end = true;

View file

@ -5,6 +5,11 @@ pub fn common_fallback() -> &'static [&'static str] {
&[]
}
// Fallbacks to never use
pub fn forbidden_fallback() -> &'static [&'static str] {
&[]
}
// Fallbacks to use per script
pub fn script_fallback(script: &Script, locale: &str) -> &'static [&'static str] {
&[]

View file

@ -13,6 +13,11 @@ pub fn common_fallback() -> &'static [&'static str] {
]
}
// Fallbacks to never use
pub fn forbidden_fallback() -> &'static [&'static str] {
&[]
}
fn han_unification(locale: &str) -> &'static [&'static str] {
match locale {
// Japan

View file

@ -12,6 +12,11 @@ pub fn common_fallback() -> &'static [&'static str] {
]
}
// Fallbacks to never use
pub fn forbidden_fallback() -> &'static [&'static str] {
&[]
}
fn han_unification(locale: &str) -> &'static [&'static str] {
//TODO!
match locale {