mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 10:41:58 +02:00
Refactor: More f-string for kitty fonts and rc send_text
This commit is contained in:
@@ -29,7 +29,7 @@ def create_font_map(all_fonts: Iterable[CoreTextFont]) -> FontMap:
|
||||
ps = (x['postscript_name'] or '').lower()
|
||||
ans['family_map'].setdefault(f, []).append(x)
|
||||
ans['ps_map'].setdefault(ps, []).append(x)
|
||||
ans['full_map'].setdefault(f + ' ' + s, []).append(x)
|
||||
ans['full_map'].setdefault(f'{f} {s}', []).append(x)
|
||||
return ans
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ def list_fonts() -> Generator[ListedFont, None, None]:
|
||||
for fd in coretext_all_fonts():
|
||||
f = fd['family']
|
||||
if f:
|
||||
fn = (f + ' ' + (fd['style'] or '')).strip()
|
||||
fn = f'{f} {fd.get("style", "")}'.strip()
|
||||
is_mono = bool(fd['monospace'])
|
||||
yield {'family': f, 'full_name': fn, 'postscript_name': fd['postscript_name'] or '', 'is_monospace': is_mono}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ def list_fonts() -> Generator[ListedFont, None, None]:
|
||||
if fn_:
|
||||
fn = str(fn_)
|
||||
else:
|
||||
fn = (f + ' ' + str(fd.get('style', ''))).strip()
|
||||
fn = f'{f} {fd.get("style", "")}'.strip()
|
||||
is_mono = fd.get('spacing') in ('MONO', 'DUAL')
|
||||
yield {'family': f, 'full_name': fn, 'postscript_name': str(fd.get('postscript_name', '')), 'is_monospace': is_mono}
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ def main(argv: Sequence[str]) -> None:
|
||||
groups = create_family_groups()
|
||||
for k in sorted(groups, key=lambda x: x.lower()):
|
||||
if isatty:
|
||||
print('\033[1;32m' + k + '\033[m')
|
||||
print(f'\033[1;32m{k}\033[m')
|
||||
else:
|
||||
print(k)
|
||||
for f in sorted(groups[k], key=lambda x: x['full_name'].lower()):
|
||||
p = f['full_name']
|
||||
if isatty:
|
||||
p = '\033[3m' + p + '\033[m'
|
||||
p = f'\033[3m{p}\033[m'
|
||||
if psnames:
|
||||
p += ' ({})'.format(f['postscript_name'])
|
||||
print(' ', p)
|
||||
|
||||
@@ -515,7 +515,7 @@ def test_fallback_font(qtext: Optional[str] = None, bold: bool = False, italic:
|
||||
try:
|
||||
print(text, f)
|
||||
except UnicodeEncodeError:
|
||||
sys.stdout.buffer.write((text + ' %s\n' % f).encode('utf-8'))
|
||||
sys.stdout.buffer.write(f'{text} {f}\n'.encode('utf-8'))
|
||||
|
||||
|
||||
def showcase() -> None:
|
||||
|
||||
Reference in New Issue
Block a user