From b06a2bb9378eff8b5cb7dca0460b2ecca3b35535 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 15 May 2024 14:35:51 +0530 Subject: [PATCH] Add more font selection tests --- kitty/fonts/common.py | 2 +- kitty_tests/fonts.py | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/kitty/fonts/common.py b/kitty/fonts/common.py index 15ec17c94..1856ce97f 100644 --- a/kitty/fonts/common.py +++ b/kitty/fonts/common.py @@ -256,7 +256,7 @@ def get_font_from_spec( if bold or italic: assert resolved_medium_font is not None family = resolved_medium_font['family'] - if is_variable(resolved_medium_font): + if is_variable(resolved_medium_font) or is_actually_variable_despite_fontconfigs_lies(resolved_medium_font): v = find_bold_italic_variant(resolved_medium_font, bold, italic) if v is not None: return v diff --git a/kitty_tests/fonts.py b/kitty_tests/fonts.py index e45d6560c..a675bca73 100644 --- a/kitty_tests/fonts.py +++ b/kitty_tests/fonts.py @@ -23,12 +23,15 @@ class Selection(BaseTest): def test_font_selection(self): opts = Options() - fonts_map = all_fonts_map(monospaced=True) - family_map = fonts_map['family_map'] - variable_map = fonts_map['variable_map'] - has_source_code_pro = family_name_to_key('Source Code Pro') in family_map - has_source_code_vf = family_name_to_key('sourcecodeVf') in variable_map - del fonts_map, family_map, variable_map + fonts_map = all_fonts_map(True) + names = set(fonts_map['family_map']) | set(fonts_map['variable_map']) + def has(x: str) -> bool: + return family_name_to_key(x) in names + has_source_code_pro = has('Source Code Pro') + has_source_code_vf = has('sourcecodeVf') + has_fira_code = has('Fira Code') + has_hack = has('Hack') + del fonts_map, has def s(family: str, *expected: str) -> None: opts.font_family = parse_font_spec(family) @@ -45,6 +48,10 @@ class Selection(BaseTest): both('Source Code Pro', 'SourceCodePro-Regular', 'SourceCodePro-Semibold', 'SourceCodePro-It', 'SourceCodePro-SemiboldIt') if has_source_code_vf: both('sourcecodeVf', 'SourceCodeVF-Regular', 'SourceCodeVF-Semibold', 'SourceCodeVF-Italic', 'SourceCodeVF-SemiboldItalic') + if has_fira_code: + both('fira code', 'FiraCodeRoman-Regular', 'FiraCodeRoman-SemiBold', 'FiraCodeRoman-Regular', 'FiraCodeRoman-SemiBold') + if has_hack: + both('hack', 'Hack-Regular', 'Hack-Bold', 'Hack-Italic', 'Hack-BoldItalic') class Rendering(BaseTest):