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
This commit is contained in:
Kovid Goyal
2020-09-03 17:14:55 +05:30
parent d7a6ceb3a6
commit 80e39212b8
2 changed files with 12 additions and 3 deletions

View File

@@ -40,6 +40,10 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- 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]
-------------------

View File

@@ -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):