From 80e39212b8f3d40261076229dec642e937f723a1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 3 Sep 2020 17:14:55 +0530 Subject: [PATCH] Linux: Fix automatic detection of bold/italic faces for fonts such as IBM Plex Mono and have the regular face with a full name that is the same as the family name Fixes #2951 --- docs/changelog.rst | 4 ++++ kitty/fonts/fontconfig.py | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b73c7a9fa..2f4bb6293 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -40,6 +40,10 @@ To update |kitty|, :doc:`follow the instructions `. - Implement special rendering for various characters from the set of "Symbols for Legacy Computing" from the Unicode 13 standard +- Linux: Fix automatic detection of bold/italic faces for fonts such as IBM + Plex Mono and have the regular face with a full name that is the same as the + family name (:iss:`2951`) + 0.18.3 [2020-08-11] ------------------- diff --git a/kitty/fonts/fontconfig.py b/kitty/fonts/fontconfig.py index 97e4b3202..90825264a 100644 --- a/kitty/fonts/fontconfig.py +++ b/kitty/fonts/fontconfig.py @@ -84,9 +84,14 @@ def find_best_match(family: str, bold: bool = False, italic: bool = False, monos # First look for an exact match for selector in ('ps_map', 'full_map', 'family_map'): candidates = font_map[selector].get(q) - if candidates: - candidates.sort(key=score) - return candidates[0] + if not candidates: + continue + if len(candidates) == 1 and (bold or italic) and candidates[0].get('family') == candidates[0].get('full_name'): + # IBM Plex Mono does this, where the full name of the regular font + # face is the same as its family name + continue + candidates.sort(key=score) + return candidates[0] # Use fc-match to see if we can find a monospaced font that matches family for spacing in (FC_MONO, FC_DUAL):