diff --git a/docs/changelog.rst b/docs/changelog.rst index 03b537efa..8b125c9dc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -27,11 +27,14 @@ Changelog - macOS: Fix drag and drop of files not working on mojave (:iss:`1058`) -- macOS: Fix IME input for east asian languages (:iss:`910`) +- macOS: Fix IME input for East Asian languages (:iss:`910`) - macOS: Fix rendering frames-per-second very low when processing large amounts of input in small chunks (:pull:`1082`) +- Linux: Fix match rules used as aliases in Fontconfig configuration not being + respected (:iss:`1085`) + - Fix expansion of env vars not working in the :opt:`env` directive (:iss:`1075`) diff --git a/kitty/fonts/fontconfig.py b/kitty/fonts/fontconfig.py index f10d2f35c..5ef2912be 100644 --- a/kitty/fonts/fontconfig.py +++ b/kitty/fonts/fontconfig.py @@ -44,8 +44,12 @@ def list_fonts(): yield {'family': f, 'full_name': fn, 'is_monospace': is_mono} +def family_name_to_key(family): + return re.sub(r'\s+', ' ', family.lower()) + + def find_best_match(family, bold=False, italic=False, monospaced=True): - q = re.sub(r'\s+', ' ', family.lower()) + q = family_name_to_key(family) font_map = all_fonts_map(monospaced) def score(candidate): @@ -61,6 +65,16 @@ def find_best_match(family, bold=False, italic=False, monospaced=True): candidates.sort(key=score) return candidates[0] + # Use fc-match to see if we can find a monospaced font that matches family + possibility = fc_match(family, False, False) + for key, map_key in (('postscript_name', 'ps_map'), ('full_name', 'full_map'), ('family', 'family_map')): + val = possibility.get(key) + if val: + candidates = font_map[map_key].get(family_name_to_key(val)) + if candidates: + candidates.sort(key=score) + return candidates[0] + # Use fc-match with a generic family family = 'monospace' if monospaced else 'sans-serif' return fc_match(family, bold, italic)