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
This commit is contained in:
Wez Furlong committed 2021-05-01 16:45:57 -07:00
1 parent faaf6dea30
commit 9ccdc157a7
2 files changed
+16 -11

No files matched your search

+3
View File
@@ -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,
+13 -11
View File
@@ -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);