aboutsummaryrefslogtreecommitdiffstats
path: root/components/fonts/platform/windows
diff options
context:
space:
mode:
Diffstat (limited to 'components/fonts/platform/windows')
-rw-r--r--components/fonts/platform/windows/font.rs4
-rw-r--r--components/fonts/platform/windows/font_list.rs22
2 files changed, 19 insertions, 7 deletions
diff --git a/components/fonts/platform/windows/font.rs b/components/fonts/platform/windows/font.rs
index e33b2ad9d3e..74f592e63b9 100644
--- a/components/fonts/platform/windows/font.rs
+++ b/components/fonts/platform/windows/font.rs
@@ -132,7 +132,9 @@ impl PlatformFontMethods for PlatformFont {
pt_size: Option<Au>,
) -> Result<PlatformFont, &'static str> {
let font_face = FontCollection::system()
- .get_font_from_descriptor(&font_identifier.font_descriptor)
+ .font_from_descriptor(&font_identifier.font_descriptor)
+ .ok()
+ .flatten()
.ok_or("Could not create Font from descriptor")?
.create_font_face();
Self::new(font_face, pt_size)
diff --git a/components/fonts/platform/windows/font_list.rs b/components/fonts/platform/windows/font_list.rs
index d1aa19e178a..e9cdaac8562 100644
--- a/components/fonts/platform/windows/font_list.rs
+++ b/components/fonts/platform/windows/font_list.rs
@@ -25,7 +25,9 @@ where
{
let system_fc = FontCollection::system();
for family in system_fc.families_iter() {
- callback(family.name());
+ if let Ok(family_name) = family.family_name() {
+ callback(family_name);
+ }
}
}
@@ -40,13 +42,17 @@ pub struct LocalFontIdentifier {
impl LocalFontIdentifier {
pub fn index(&self) -> u32 {
FontCollection::system()
- .get_font_from_descriptor(&self.font_descriptor)
+ .font_from_descriptor(&self.font_descriptor)
+ .ok()
+ .flatten()
.map_or(0, |font| font.create_font_face().get_index())
}
pub(crate) fn native_font_handle(&self) -> NativeFontHandle {
let face = FontCollection::system()
- .get_font_from_descriptor(&self.font_descriptor)
+ .font_from_descriptor(&self.font_descriptor)
+ .ok()
+ .flatten()
.expect("Could not create Font from FontDescriptor")
.create_font_face();
let path = face
@@ -62,7 +68,9 @@ impl LocalFontIdentifier {
}
pub(crate) fn read_data_from_file(&self) -> Option<Vec<u8>> {
- let font = FontCollection::system().get_font_from_descriptor(&self.font_descriptor)?;
+ let font = FontCollection::system()
+ .font_from_descriptor(&self.font_descriptor)
+ .ok()??;
let face = font.create_font_face();
let files = face.get_files();
assert!(!files.is_empty());
@@ -86,10 +94,12 @@ where
F: FnMut(FontTemplate),
{
let system_fc = FontCollection::system();
- if let Some(family) = system_fc.get_font_family_by_name(family_name) {
+ if let Ok(Some(family)) = system_fc.font_family_by_name(family_name) {
let count = family.get_font_count();
for i in 0..count {
- let font = family.get_font(i);
+ let Ok(font) = family.font(i) else {
+ continue;
+ };
let template_descriptor = (&font).into();
let local_font_identifier = LocalFontIdentifier {
font_descriptor: Arc::new(font.to_descriptor()),