From 316cc56ea86fdebdb91208baf7da697573aa92dc Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 3 Oct 2020 11:08:36 -0700 Subject: [PATCH] wezterm: fixup processing of built-in fonts There was a flaw in processing the built-ins; because we searched the built-ins as part of the font dir step we'd satisfy matching the default fallback from the in-memory fonts and it would accidentally take precedence over the fonts provided by the system font locator. This commit makes an explicit additional (final) step to search the built in fonts. refs: #263 --- src/font/mod.rs | 2 ++ src/font/parser.rs | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/font/mod.rs b/src/font/mod.rs index 414944bf2..09c1a600a 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -110,6 +110,8 @@ impl FontConfiguration { let attributes = style.font_with_fallback(); let mut handles = parser::ParsedFont::load_fonts(&config, &attributes)?; handles.append(&mut self.locator.load_fonts(&attributes)?); + handles.append(&mut parser::ParsedFont::load_built_in_fonts(&attributes)?); + log::debug!("handles: {:#?}", handles); let mut rasterizers = vec![]; for _ in &handles { rasterizers.push(RefCell::new(None)); diff --git a/src/font/parser.rs b/src/font/parser.rs index d123efb02..46377c158 100644 --- a/src/font/parser.rs +++ b/src/font/parser.rs @@ -93,8 +93,21 @@ impl ParsedFont { } } - load_built_in_fonts(&mut font_info).ok(); + Self::match_font_info(fonts_selection, font_info) + } + pub fn load_built_in_fonts( + fonts_selection: &[FontAttributes], + ) -> anyhow::Result> { + let mut font_info = vec![]; + load_built_in_fonts(&mut font_info).ok(); + Self::match_font_info(fonts_selection, font_info) + } + + fn match_font_info( + fonts_selection: &[FontAttributes], + mut font_info: Vec<(Names, std::path::PathBuf, FontDataHandle)>, + ) -> anyhow::Result> { font_info.sort_by_key(|(names, _, _)| names.full_name.clone()); for (names, _, _) in &font_info { log::warn!("available font: {}", names.full_name);