mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
Fix matching against style names in presence of elision
This commit is contained in:
@@ -417,7 +417,7 @@ def get_named_style(face_or_descriptor: Union[Face, Descriptor]) -> Optional[Nam
|
||||
d: Descriptor = face_or_descriptor
|
||||
vd = get_variable_data_for_descriptor(d)
|
||||
if d['descriptor_type'] == 'fontconfig':
|
||||
ns = d.get('named_instance', -1)
|
||||
ns = d.get('named_style', -1)
|
||||
if ns > -1 and ns < len(vd['named_styles']):
|
||||
return vd['named_styles'][ns]
|
||||
axis_map = {}
|
||||
@@ -444,7 +444,7 @@ def get_axis_map(face_or_descriptor: Union[Face, Descriptor]) -> Dict[str, float
|
||||
d: Descriptor = face_or_descriptor
|
||||
vd = get_variable_data_for_descriptor(d)
|
||||
if d['descriptor_type'] == 'fontconfig':
|
||||
ns = d.get('named_instance', -1)
|
||||
ns = d.get('named_style', -1)
|
||||
if ns > -1 and ns < len(vd['named_styles']):
|
||||
base_axis_map = vd['named_styles'][ns]['axis_values'].copy()
|
||||
axis_map = {}
|
||||
|
||||
@@ -248,6 +248,11 @@ def set_named_style(name: str, font: CoreTextFont, vd: VariableData) -> bool:
|
||||
for i, ns in enumerate(vd['named_styles']):
|
||||
if ns['name'].lower() == q:
|
||||
return set_axis_values(ns['axis_values'], font, vd)
|
||||
if vd['elided_fallback_name']:
|
||||
for i, ns in enumerate(vd['named_styles']):
|
||||
eq = ' '.join(ns['name'].replace(vd['elided_fallback_name'], '').strip().split()).lower()
|
||||
if q == eq:
|
||||
return set_axis_values(ns['axis_values'], font, vd)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
@@ -245,6 +245,12 @@ def set_named_style(name: str, font: FontConfigPattern, vd: VariableData) -> boo
|
||||
if ns['name'].lower() == q:
|
||||
font['named_style'] = i
|
||||
return True
|
||||
if vd['elided_fallback_name']:
|
||||
for i, ns in enumerate(vd['named_styles']):
|
||||
eq = ' '.join(ns['name'].replace(vd['elided_fallback_name'], '').strip().split()).lower()
|
||||
if q == eq:
|
||||
font['named_style'] = i
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user