mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-27 11:21:32 +00:00
Add more font selection tests
This commit is contained in:
parent
46f391ae63
commit
b06a2bb937
2 changed files with 14 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue