Use fc-list instead of fc-match to select fonts

This is because there is no way to force fc-match to return a monospace
font. So if the user specifies a non-existent font we end up with some
non-monospaced font, which looks terrible.

Also, this makes the font selection logic or macOS and Linux similar.
This commit is contained in:
Kovid Goyal
2017-11-10 10:15:37 +05:30
parent b58e900806
commit fefe6c9024
4 changed files with 162 additions and 178 deletions

View File

@@ -18,10 +18,7 @@ from kitty.utils import get_logical_dpi
if isosx:
from .core_text import get_font_files, font_for_text, face_from_font, font_for_family, save_medium_face
else:
from .fontconfig import get_font_files, font_for_text, face_from_font, font_for_family
def save_medium_face(f):
pass
from .fontconfig import get_font_files, font_for_text, face_from_font, font_for_family, save_medium_face
def create_face(font):
@@ -35,10 +32,10 @@ def create_symbol_map(opts):
faces = []
for family in val.values():
if family not in family_map:
font = font_for_family(family)
font, bold, italic = font_for_family(family)
o = create_face(font)
family_map[family] = len(faces)
faces.append((o, font.bold, font.italic))
faces.append((o, bold, italic))
sm = tuple((a, b, family_map[f]) for (a, b), f in val.items())
return sm, tuple(faces)