aboutsummaryrefslogtreecommitdiffstats
path: root/components/fonts/platform
diff options
context:
space:
mode:
authorJonathan Schwender <55576758+jschwe@users.noreply.github.com>2024-07-08 15:53:41 +0200
committerGitHub <noreply@github.com>2024-07-08 13:53:41 +0000
commit8cd1e22f8dc624deb80de9a730a21ef8d8cc503e (patch)
treec636aec5836aa6f524096859e779b8f4747402ce /components/fonts/platform
parent89944bd330c1e46a6f406c9aa36e5118ddd06902 (diff)
downloadservo-8cd1e22f8dc624deb80de9a730a21ef8d8cc503e.tar.gz
servo-8cd1e22f8dc624deb80de9a730a21ef8d8cc503e.zip
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>
Diffstat (limited to 'components/fonts/platform')
-rw-r--r--components/fonts/platform/freetype/android/font_list.rs8
-rw-r--r--components/fonts/platform/freetype/ohos/font_list.rs8
2 files changed, 12 insertions, 4 deletions
diff --git a/components/fonts/platform/freetype/android/font_list.rs b/components/fonts/platform/freetype/android/font_list.rs
index 3343c7c3788..0fd0c336487 100644
--- a/components/fonts/platform/freetype/android/font_list.rs
+++ b/components/fonts/platform/freetype/android/font_list.rs
@@ -259,11 +259,15 @@ impl FontList {
}
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> {
- 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
diff --git a/components/fonts/platform/freetype/ohos/font_list.rs b/components/fonts/platform/freetype/ohos/font_list.rs
index f4d9ec6200a..819535a618d 100644
--- a/components/fonts/platform/freetype/ohos/font_list.rs
+++ b/components/fonts/platform/freetype/ohos/font_list.rs
@@ -108,11 +108,15 @@ impl FontList {
}
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> {
- self.aliases.iter().find(|f| f.from == name)
+ self.aliases
+ .iter()
+ .find(|family| family.from.eq_ignore_ascii_case(name))
}
}