mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-22 16:28:19 +02:00
Dont rely on fontconfig to get postscript names
This commit is contained in:
@@ -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
|
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.
|
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
|
To get the PostScript name for a font, use :code:`kitty + list-fonts --psnames`::
|
||||||
name::
|
|
||||||
|
|
||||||
$ fc-match "Fira Code" postscriptname
|
$ kitty + list-fonts --psnames | grep Fira
|
||||||
:postscriptname=FiraCode-Regular
|
Fira Code
|
||||||
$ fc-match "Fira Code Retina" postscriptname
|
Fira Code Bold (FiraCode-Bold)
|
||||||
:postscriptname=FiraCode-Retina
|
Fira Code Light (FiraCode-Light)
|
||||||
$ fc-match "TT2020Base:style=italic" postscriptname
|
Fira Code Medium (FiraCode-Medium)
|
||||||
:postscriptname=TT2020Base-Italic
|
Fira Code Regular (FiraCode-Regular)
|
||||||
|
Fira Code Retina (FiraCode-Retina)
|
||||||
|
|
||||||
|
The part in brackets is the PostScript name.
|
||||||
|
|
||||||
Enable alternate zero and oldstyle numerals::
|
Enable alternate zero and oldstyle numerals::
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ def list_fonts():
|
|||||||
if f:
|
if f:
|
||||||
fn = (f + ' ' + (fd['style'] or '')).strip()
|
fn = (f + ' ' + (fd['style'] or '')).strip()
|
||||||
is_mono = bool(fd['monospace'])
|
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):
|
def find_best_match(family, bold=False, italic=False):
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ def list_fonts():
|
|||||||
if f:
|
if f:
|
||||||
fn = fd.get('full_name') or (f + ' ' + fd.get('style', '')).strip()
|
fn = fd.get('full_name') or (f + ' ' + fd.get('style', '')).strip()
|
||||||
is_mono = fd.get('spacing') in ('MONO', 'DUAL')
|
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):
|
def family_name_to_key(family):
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ def create_family_groups(monospaced=True):
|
|||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
psnames = '--psnames' in argv
|
||||||
isatty = sys.stdout.isatty()
|
isatty = sys.stdout.isatty()
|
||||||
groups = create_family_groups()
|
groups = create_family_groups()
|
||||||
for k in sorted(groups, key=lambda x: x.lower()):
|
for k in sorted(groups, key=lambda x: x.lower()):
|
||||||
@@ -31,5 +32,7 @@ def main(argv):
|
|||||||
p = f['full_name']
|
p = f['full_name']
|
||||||
if isatty:
|
if isatty:
|
||||||
p = '\033[3m' + p + '\033[m'
|
p = '\033[3m' + p + '\033[m'
|
||||||
|
if psnames:
|
||||||
|
p += ' ({})'.format(f['postscript_name'])
|
||||||
print(' ', p)
|
print(' ', p)
|
||||||
print()
|
print()
|
||||||
|
|||||||
Reference in New Issue
Block a user