From 9ccdc157a7aa6d79e996735d26427011a190a5cd Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 1 May 2021 11:02:26 -0700 Subject: [PATCH] fonts: search locator for fallbacks first Also add an option to control whether we look in font_dirs for fallback. Previously we would, but it could lead to some surprising fallback choices. The default now is to search locator then built-in. refs: https://github.com/wez/wezterm/issues/685 refs: https://github.com/wez/wezterm/issues/727 --- config/src/lib.rs | 3 +++ wezterm-font/src/lib.rs | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/config/src/lib.rs b/config/src/lib.rs index fcbda87fd..f5253b7ce 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -1095,6 +1095,9 @@ pub struct Config { #[serde(default)] pub sort_fallback_fonts_by_coverage: bool, + #[serde(default)] + pub search_font_dirs_for_fallback: bool, + #[serde(default)] pub swallow_mouse_click_on_pane_focus: bool, diff --git a/wezterm-font/src/lib.rs b/wezterm-font/src/lib.rs index 208cbb06b..2a4d0905b 100644 --- a/wezterm-font/src/lib.rs +++ b/wezterm-font/src/lib.rs @@ -224,15 +224,26 @@ impl FontConfigInner { fallback_str.escape_unicode() ); - match font_dirs.locate_fallback_for_codepoints(&no_glyphs) { + match locator.locate_fallback_for_codepoints(&no_glyphs) { Ok(ref mut handles) => extra_handles.append(handles), Err(err) => log::error!( - "Error: {:#} while resolving fallback for {} from font_dirs", + "Error: {:#} while resolving fallback for {} from font-locator", err, fallback_str.escape_unicode() ), } + if config.search_font_dirs_for_fallback { + match font_dirs.locate_fallback_for_codepoints(&no_glyphs) { + Ok(ref mut handles) => extra_handles.append(handles), + Err(err) => log::error!( + "Error: {:#} while resolving fallback for {} from font_dirs", + err, + fallback_str.escape_unicode() + ), + } + } + match built_in.locate_fallback_for_codepoints(&no_glyphs) { Ok(ref mut handles) => extra_handles.append(handles), Err(err) => log::error!( @@ -242,15 +253,6 @@ impl FontConfigInner { ), } - match locator.locate_fallback_for_codepoints(&no_glyphs) { - Ok(ref mut handles) => extra_handles.append(handles), - Err(err) => log::error!( - "Error: {:#} while resolving fallback for {} from font-locator", - err, - fallback_str.escape_unicode() - ), - } - let mut wanted = RangeSet::new(); for c in no_glyphs { wanted.add(c as u32);