mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
android/ohos: fonts: Ignore ascii case when searching for font family (#32725)
The input for this function commonly comes from a `LowercaseString`, while our actual font family name has cases. Since font family lookup should be case-neutral, we do a compare ignoring the ascii case. I'm not too familiar with the CSS standard so I'm not 100% sure if this is sufficient, or if we need to use a different method to compare strings for arbitrary non-ascii font names. Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
This commit is contained in:
parent
89944bd330
commit
8cd1e22f8d
2 changed files with 12 additions and 4 deletions
|
@ -259,11 +259,15 @@ impl FontList {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_family(&self, name: &str) -> Option<&FontFamily> {
|
fn find_family(&self, name: &str) -> Option<&FontFamily> {
|
||||||
self.families.iter().find(|f| f.name == name)
|
self.families
|
||||||
|
.iter()
|
||||||
|
.find(|family| family.name.eq_ignore_ascii_case(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_alias(&self, name: &str) -> Option<&FontAlias> {
|
fn find_alias(&self, name: &str) -> Option<&FontAlias> {
|
||||||
self.aliases.iter().find(|f| f.from == name)
|
self.aliases
|
||||||
|
.iter()
|
||||||
|
.find(|family| family.from.eq_ignore_ascii_case(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse family and font file names
|
// Parse family and font file names
|
||||||
|
|
|
@ -108,11 +108,15 @@ impl FontList {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_family(&self, name: &str) -> Option<&FontFamily> {
|
fn find_family(&self, name: &str) -> Option<&FontFamily> {
|
||||||
self.families.iter().find(|f| f.name == name)
|
self.families
|
||||||
|
.iter()
|
||||||
|
.find(|family| family.name.eq_ignore_ascii_case(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_alias(&self, name: &str) -> Option<&FontAlias> {
|
fn find_alias(&self, name: &str) -> Option<&FontAlias> {
|
||||||
self.aliases.iter().find(|f| f.from == name)
|
self.aliases
|
||||||
|
.iter()
|
||||||
|
.find(|family| family.from.eq_ignore_ascii_case(name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue