diff --git a/docs/changelog.rst b/docs/changelog.rst index 418aeb453..c1d04cda1 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -110,6 +110,8 @@ Detailed list of changes - Shell integration: bash: Dont fail if an existing PROMPT_COMMAND ends with a semi-colon (:iss:`4645`) +- Linux: Fix fontconfig alias not being used if the aliased font is dual spaced instead of monospaced (:iss:`4649`) + 0.24.2 [2022-02-03] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/fonts/fontconfig.py b/kitty/fonts/fontconfig.py index 01c3ba047..7c9f901a9 100644 --- a/kitty/fonts/fontconfig.py +++ b/kitty/fonts/fontconfig.py @@ -115,8 +115,13 @@ def find_best_match(family: str, bold: bool = False, italic: bool = False, monos 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): - possibility = fc_match(family, False, False, spacing) + # When aliases are defined, spacing can cause the incorrect font to be + # returned, so check with and without spacing and use the one that matches. + mono_possibility = fc_match(family, False, False, FC_MONO) + dual_possibility = fc_match(family, False, False, FC_DUAL) + any_possibility = fc_match(family, False, False, 0) + tries = (dual_possibility, mono_possibility) if any_possibility == dual_possibility else (mono_possibility, dual_possibility) + for possibility in tries: for key, map_key in (('postscript_name', 'ps_map'), ('full_name', 'full_map'), ('family', 'family_map')): val: Optional[str] = cast(Optional[str], possibility.get(key)) if val: