Work on listing available styles for a family

This commit is contained in:
Kovid Goyal
2024-05-03 19:57:02 +05:30
parent 3b80ee0981
commit 3814e92f31
6 changed files with 41 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ from kitty.typing import CoreTextFont, FontConfigPattern
class ListedFont(TypedDict):
family: str
style: str
full_name: str
postscript_name: str
is_monospace: bool

View File

@@ -47,7 +47,7 @@ def list_fonts() -> Generator[ListedFont, None, None]:
if not fn:
fn = f'{f} {fd["style"]}'.strip()
yield {'family': f, 'full_name': fn, 'postscript_name': fd['postscript_name'] or '', 'is_monospace': fd['monospace'],
'is_variable': fd['variable'], 'descriptor': fd}
'is_variable': fd['variable'], 'descriptor': fd, 'style': fd['style']}
def create_scorer(bold: bool = False, italic: bool = False, monospaced: bool = True, prefer_variable: bool = False) -> Scorer:

View File

@@ -61,6 +61,7 @@ def list_fonts(only_variable: bool = False) -> Generator[ListedFont, None, None]
yield {
'family': f, 'full_name': fn, 'postscript_name': str(fd.get('postscript_name', '')),
'is_monospace': is_mono, 'descriptor': fd, 'is_variable': fd.get('variable', False),
'style': fd['style'],
}