From c4f16fe3391b3b447725c10226679a6b47b5e972 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 29 Jan 2024 20:01:48 -0700 Subject: [PATCH] macos: constrain fallback to normal attributes refs: https://github.com/wez/wezterm/issues/4808 --- docs/changelog.md | 2 ++ wezterm-font/src/locator/core_text.rs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 065d21b1f..2ca082a15 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -25,6 +25,8 @@ As features stabilize some brief notes about them will accumulate here. * Not yet! #### New #### Fixed +* macOS: fallback fonts could select thin or otherwise unspecified font + attributes. #4808 ### 20240128-202157-1e552d76 diff --git a/wezterm-font/src/locator/core_text.rs b/wezterm-font/src/locator/core_text.rs index 8879ab3c1..0c4852a01 100644 --- a/wezterm-font/src/locator/core_text.rs +++ b/wezterm-font/src/locator/core_text.rs @@ -162,6 +162,17 @@ impl FontLocator for CoreTextFontLocator { continue; } + let is_normal = font.weight() == FontWeight::REGULAR + && font.stretch() == FontStretch::Normal + && font.style() == FontStyle::Normal; + if !is_normal { + // Only use normal attributed text for fallbacks, + // otherwise we'll end up picking something with + // undefined and undesirable attributes + // + continue; + } + if let Ok(cov) = font.coverage_intersection(&wanted) { // Explicitly check coverage because the list may not // actually match the text we asked about(!)