Add a simple function for listing basic font data

This commit is contained in:
Kovid Goyal 2024-09-01 10:50:52 +05:30
parent 8a607fa34c
commit ccc3bee9af
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -502,5 +502,14 @@ def s(name: str, d: Descriptor) -> None:
s('Bold-Italic:', ff['bi'])
def list_fonts(monospaced: bool = True) -> dict[str, list[dict[str, str]]]:
ans: dict[str, list[dict[str, str]]] = {}
for key, descriptors in all_fonts_map(monospaced)['family_map'].items():
entries = ans.setdefault(key, [])
for d in descriptors:
entries.append({'family': d['family'], 'psname': d['postscript_name'], 'path': d['path'], 'style': d['style']})
return ans
if __name__ == '__main__':
develop()