diff --git a/src/config.rs b/src/config.rs index 6dfeebc04..c872c9d5c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -208,6 +208,12 @@ impl TextStyle { bold: None, italic: None, }); + #[cfg(target_os = "macos")] + font.push(FontAttributes { + family: "Zapf Dingbats".into(), + bold: None, + italic: None, + }); #[cfg(windows)] font.push(FontAttributes { family: "Segoe UI".into(), diff --git a/src/font/coretext.rs b/src/font/coretext.rs index 7a3214ac1..e655e1ba7 100644 --- a/src/font/coretext.rs +++ b/src/font/coretext.rs @@ -108,7 +108,7 @@ fn glyph_index(ct_font: &CTFont, codepoint: char) -> Option { } } -#[derive(Debug)] +#[derive(Debug, Default)] struct Metrics { font_metrics: FontMetrics, ascent: f64, @@ -150,8 +150,9 @@ impl CoreTextFontImpl { let w_metrics = metrics('W', &ct_font); let m_metrics = metrics('M', &ct_font); let zero_metrics = metrics('0', &ct_font); - let metrics = - w_metrics.unwrap_or_else(|| m_metrics.unwrap_or_else(|| zero_metrics.unwrap())); + let metrics = w_metrics.unwrap_or_else(|| { + m_metrics.unwrap_or_else(|| zero_metrics.unwrap_or_else(|| Default::default())) + }); Self { ct_font, hb_font, diff --git a/src/font/mod.rs b/src/font/mod.rs index 902c58722..793903c2d 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -58,10 +58,12 @@ impl Default for FontSystemSelection { not(feature = "force-rusttype") )) { FontSystemSelection::FontConfigAndFreeType - } else if cfg!(not(feature = "force-rusttype")) { - FontSystemSelection::FontLoaderAndFreeType - } else { + } else if cfg!(feature = "force-rusttype") { FontSystemSelection::FontLoaderAndRustType + } else if cfg!(target_os = "macos") { + FontSystemSelection::CoreText + } else { + FontSystemSelection::FontLoaderAndFreeType } } } @@ -104,7 +106,7 @@ impl std::str::FromStr for FontSystemSelection { fn from_str(s: &str) -> Result { match s.to_lowercase().as_ref() { "fontconfigandfreetype" => Ok(FontSystemSelection::FontConfigAndFreeType), - "fontloadandfreetype" => Ok(FontSystemSelection::FontLoaderAndFreeType), + "fontloaderandfreetype" => Ok(FontSystemSelection::FontLoaderAndFreeType), "fontloaderandrusttype" => Ok(FontSystemSelection::FontLoaderAndRustType), "coretext" => Ok(FontSystemSelection::CoreText), _ => Err(format_err!(