1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00

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
This commit is contained in:
Wez Furlong 2020-10-03 11:08:36 -07:00
parent b2911ccc41
commit 316cc56ea8
2 changed files with 16 additions and 1 deletions

View File

@ -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));

View File

@ -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<Vec<FontDataHandle>> {
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<Vec<FontDataHandle>> {
font_info.sort_by_key(|(names, _, _)| names.full_name.clone());
for (names, _, _) in &font_info {
log::warn!("available font: {}", names.full_name);