From 65ac2269dd18b561be6fc7827738ce86dff7b2b6 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 23 Nov 2020 15:01:19 -0800 Subject: [PATCH] wezterm-font: fix exact match of full font name Don't short circuit on just the family portion of the name; if the criteria don't match there, we should fall back to test against the full font name. closes: https://github.com/wez/wezterm/issues/341 --- wezterm-font/src/parser.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/wezterm-font/src/parser.rs b/wezterm-font/src/parser.rs index 8b2eef52c..2087395de 100644 --- a/wezterm-font/src/parser.rs +++ b/wezterm-font/src/parser.rs @@ -542,16 +542,17 @@ pub fn font_info_matches(attr: &FontAttributes, names: &Names) -> bool { // this is a pretty rough approximation if attr.family == *fam { match names.sub_family.as_ref().map(String::as_str) { - Some("Italic") if attr.italic && !attr.bold => true, - Some("Bold") if attr.bold && !attr.italic => true, - Some("Bold Italic") if attr.bold && attr.italic => true, - Some("Medium") | Some("Regular") | None if !attr.italic && !attr.bold => true, - _ => false, + Some("Italic") if attr.italic && !attr.bold => return true, + Some("Bold") if attr.bold && !attr.italic => return true, + Some("Bold Italic") if attr.bold && attr.italic => return true, + Some("Medium") | Some("Regular") | None if !attr.italic && !attr.bold => { + return true + } + _ => {} } - } else { - false } - } else if attr.family == names.full_name && !attr.bold && !attr.italic { + } + if attr.family == names.full_name && !attr.bold && !attr.italic { true } else { false