1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 13:21:38 +03:00

fonts: fix fontconfig monospace alias resolution

This got broken by 58ece29f00
This commit structures things so that we're less likely to overlook
this in the future!

cc: @unrelentingtech

refs: #1250
This commit is contained in:
Wez Furlong 2022-01-02 08:24:31 -07:00
parent 69e8d9144c
commit c05491f831
2 changed files with 29 additions and 0 deletions

View File

@ -16,6 +16,8 @@ As features stabilize some brief notes about them will accumulate here.
#### Updated and Improved
#### Fixed
* Regression that broke fontconfig aliases such as `"monospace"` [#1250](https://github.com/wez/wezterm/pull/1250)
### 20220101-133340-7edc5b5a
* Fancy Tab Bars are now the default. The default tab bar colors have changed to accommodate the new more native look. You can turn them off by setting [use_fancy_tab_bar = false](config/lua/config/use_fancy_tab_bar.md).

View File

@ -611,7 +611,13 @@ impl FontConfigInner {
candidates.append(&mut built_in.candidates(attr));
}
let mut is_fallback = false;
for attr in attrs {
if attr.is_fallback {
is_fallback = true;
}
if loaded.contains(attr) {
continue;
}
@ -628,6 +634,27 @@ impl FontConfigInner {
});
}
}
if !is_fallback && loaded.is_empty() {
// We didn't explicitly match any names.
// When using fontconfig, the system may have expanded a family name
// like "monospace" into the real font, in which case we wouldn't have
// found a match in the `named_candidates` vec above, because of the
// name mismatch.
// So what we do now is make a second pass over all the located candidates,
// ignoring their names, and just match based on font attributes.
let located_candidates: Vec<_> = located.iter().collect();
for attr in attrs {
if let Some(idx) =
ParsedFont::best_matching_index(attr, &located_candidates, pixel_size)
{
located_candidates.get(idx).map(|&p| {
loaded.insert(attr.clone());
handles.push(p.clone().synthesize(attr))
});
}
}
}
}
Ok((handles, loaded))