Dont rely on fontconfig to get postscript names
This commit is contained in:
parent
8a5f189213
commit
61dd2011f5
@ -291,15 +291,17 @@ Note that this code is indexed by PostScript name, and not the font
|
||||
family. This allows you to define very precise feature settings; e.g. you can
|
||||
disable a feature in the italic font but not in the regular font.
|
||||
|
||||
To get the PostScript name for a font, ask Fontconfig for it, using the family
|
||||
name::
|
||||
To get the PostScript name for a font, use :code:`kitty + list-fonts --psnames`::
|
||||
|
||||
$ fc-match "Fira Code" postscriptname
|
||||
:postscriptname=FiraCode-Regular
|
||||
$ fc-match "Fira Code Retina" postscriptname
|
||||
:postscriptname=FiraCode-Retina
|
||||
$ fc-match "TT2020Base:style=italic" postscriptname
|
||||
:postscriptname=TT2020Base-Italic
|
||||
$ kitty + list-fonts --psnames | grep Fira
|
||||
Fira Code
|
||||
Fira Code Bold (FiraCode-Bold)
|
||||
Fira Code Light (FiraCode-Light)
|
||||
Fira Code Medium (FiraCode-Medium)
|
||||
Fira Code Regular (FiraCode-Regular)
|
||||
Fira Code Retina (FiraCode-Retina)
|
||||
|
||||
The part in brackets is the PostScript name.
|
||||
|
||||
Enable alternate zero and oldstyle numerals::
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ def list_fonts():
|
||||
if f:
|
||||
fn = (f + ' ' + (fd['style'] or '')).strip()
|
||||
is_mono = bool(fd['monospace'])
|
||||
yield {'family': f, 'full_name': fn, 'is_monospace': is_mono}
|
||||
yield {'family': f, 'full_name': fn, 'postscript_name': fd['postscript_name'] or '', 'is_monospace': is_mono}
|
||||
|
||||
|
||||
def find_best_match(family, bold=False, italic=False):
|
||||
|
||||
@ -45,7 +45,7 @@ def list_fonts():
|
||||
if f:
|
||||
fn = fd.get('full_name') or (f + ' ' + fd.get('style', '')).strip()
|
||||
is_mono = fd.get('spacing') in ('MONO', 'DUAL')
|
||||
yield {'family': f, 'full_name': fn, 'is_monospace': is_mono}
|
||||
yield {'family': f, 'full_name': fn, 'postscript_name': fd.get('postscript_name', ''), 'is_monospace': is_mono}
|
||||
|
||||
|
||||
def family_name_to_key(family):
|
||||
|
||||
@ -20,6 +20,7 @@ def create_family_groups(monospaced=True):
|
||||
|
||||
|
||||
def main(argv):
|
||||
psnames = '--psnames' in argv
|
||||
isatty = sys.stdout.isatty()
|
||||
groups = create_family_groups()
|
||||
for k in sorted(groups, key=lambda x: x.lower()):
|
||||
@ -31,5 +32,7 @@ def main(argv):
|
||||
p = f['full_name']
|
||||
if isatty:
|
||||
p = '\033[3m' + p + '\033[m'
|
||||
if psnames:
|
||||
p += ' ({})'.format(f['postscript_name'])
|
||||
print(' ', p)
|
||||
print()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user