mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 06:25:13 +02:00
CoreText: When finding medium face for a family prefer variable font if available
This commit is contained in:
@@ -92,7 +92,7 @@ def pprint(*a: Any) -> None:
|
||||
pprint(*a)
|
||||
|
||||
|
||||
def find_medium_variant(font: Descriptor) -> Descriptor:
|
||||
def find_medium_variant(font: DescriptorVar) -> DescriptorVar:
|
||||
font = font.copy()
|
||||
vd = get_variable_data_for_descriptor(font)
|
||||
for i, ns in enumerate(vd['named_styles']):
|
||||
|
||||
@@ -183,6 +183,15 @@ def find_best_match(
|
||||
if possible != ignore_face:
|
||||
return possible
|
||||
|
||||
# See if we have a variable font
|
||||
if not bold and not italic and font_map['variable_map'].get(q):
|
||||
candidates = font_map['variable_map'][q]
|
||||
candidates = scorer.sorted_candidates(candidates)
|
||||
possible = candidates[0]
|
||||
if possible != ignore_face:
|
||||
from .common import find_medium_variant
|
||||
return find_medium_variant(possible)
|
||||
|
||||
# Let CoreText choose the font if the family exists, otherwise
|
||||
# fallback to Menlo
|
||||
if q not in font_map['family_map']:
|
||||
|
||||
Reference in New Issue
Block a user