mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Add more font selection tests
This commit is contained in:
@@ -256,7 +256,7 @@ def get_font_from_spec(
|
|||||||
if bold or italic:
|
if bold or italic:
|
||||||
assert resolved_medium_font is not None
|
assert resolved_medium_font is not None
|
||||||
family = resolved_medium_font['family']
|
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)
|
v = find_bold_italic_variant(resolved_medium_font, bold, italic)
|
||||||
if v is not None:
|
if v is not None:
|
||||||
return v
|
return v
|
||||||
|
|||||||
@@ -23,12 +23,15 @@ class Selection(BaseTest):
|
|||||||
|
|
||||||
def test_font_selection(self):
|
def test_font_selection(self):
|
||||||
opts = Options()
|
opts = Options()
|
||||||
fonts_map = all_fonts_map(monospaced=True)
|
fonts_map = all_fonts_map(True)
|
||||||
family_map = fonts_map['family_map']
|
names = set(fonts_map['family_map']) | set(fonts_map['variable_map'])
|
||||||
variable_map = fonts_map['variable_map']
|
def has(x: str) -> bool:
|
||||||
has_source_code_pro = family_name_to_key('Source Code Pro') in family_map
|
return family_name_to_key(x) in names
|
||||||
has_source_code_vf = family_name_to_key('sourcecodeVf') in variable_map
|
has_source_code_pro = has('Source Code Pro')
|
||||||
del fonts_map, family_map, variable_map
|
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:
|
def s(family: str, *expected: str) -> None:
|
||||||
opts.font_family = parse_font_spec(family)
|
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')
|
both('Source Code Pro', 'SourceCodePro-Regular', 'SourceCodePro-Semibold', 'SourceCodePro-It', 'SourceCodePro-SemiboldIt')
|
||||||
if has_source_code_vf:
|
if has_source_code_vf:
|
||||||
both('sourcecodeVf', 'SourceCodeVF-Regular', 'SourceCodeVF-Semibold', 'SourceCodeVF-Italic', 'SourceCodeVF-SemiboldItalic')
|
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):
|
class Rendering(BaseTest):
|
||||||
|
|||||||
Reference in New Issue
Block a user