Skip to content

Commit

Permalink
fonts: allow svg fonts to take precedence over bitmap versions
Browse files Browse the repository at this point in the history
But note that we don't currently render svg

refs: #4148
  • Loading branch information
wez committed Aug 15, 2023
1 parent 0f1ffac commit 8c77ea1
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions wezterm-font/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,21 +617,27 @@ impl ParsedFont {
// Reduce to matching weight
candidates.retain(|&idx| fonts[idx].weight == weight);

// Check for best matching pixel strike
if let Some((_distance, idx)) = candidates
// Check for best matching pixel strike, but only if all
// candidates have pixel strikes
if candidates
.iter()
.map(|&idx| {
let distance = fonts[idx]
.pixel_sizes
.iter()
.map(|&size| ((pixel_size as i32) - (size as i32)).abs())
.min()
.unwrap_or(i32::MAX);
(distance, idx)
})
.min()
.all(|&idx| !fonts[idx].pixel_sizes.is_empty())
{
return Some(idx);
if let Some((_distance, idx)) = candidates
.iter()
.map(|&idx| {
let distance = fonts[idx]
.pixel_sizes
.iter()
.map(|&size| ((pixel_size as i32) - (size as i32)).abs())
.min()
.unwrap_or(i32::MAX);
(distance, idx)
})
.min()
{
return Some(idx);
}
}

// The first one in this set is our best match
Expand Down

0 comments on commit 8c77ea1

Please sign in to comment.