mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Use the cache for getting variable data for faces
This commit is contained in:
@@ -423,6 +423,7 @@ def fc_match_postscript_name(
|
||||
|
||||
|
||||
class Face:
|
||||
path: Optional[str]
|
||||
def __init__(self, descriptor: Optional[FontConfigPattern] = None, path: str = '', index: int = 0): ...
|
||||
def get_variable_data(self) -> VariableData: ...
|
||||
def identify_for_debug(self) -> str: ...
|
||||
@@ -456,6 +457,7 @@ class CoreTextFont(TypedDict):
|
||||
|
||||
|
||||
class CTFace:
|
||||
path: Optional[str]
|
||||
def __init__(self, descriptor: Optional[CoreTextFont] = None, path: str = ''): ...
|
||||
def get_variable_data(self) -> VariableData: ...
|
||||
def identify_for_debug(self) -> str: ...
|
||||
|
||||
@@ -68,6 +68,16 @@ def get_variable_data_for_descriptor(d: Descriptor) -> VariableData:
|
||||
return ans
|
||||
|
||||
|
||||
def get_variable_data_for_face(d: Face) -> VariableData:
|
||||
path = d.path
|
||||
if not path:
|
||||
return d.get_variable_data()
|
||||
ans = cache_for_variable_data_by_path.get(path)
|
||||
if ans is None:
|
||||
ans = cache_for_variable_data_by_path[path] = d.get_variable_data()
|
||||
return ans
|
||||
|
||||
|
||||
def find_best_match_in_candidates(
|
||||
candidates: Sequence[Descriptor], scorer: Scorer, is_medium_face: bool, ignore_face: Optional[Descriptor] = None
|
||||
) -> Optional[Descriptor]:
|
||||
@@ -293,7 +303,7 @@ def get_named_style(face: Face) -> Optional[NamedStyle]:
|
||||
axis_map = face.get_variation()
|
||||
if axis_map is None:
|
||||
return None
|
||||
vd = face.get_variable_data()
|
||||
vd = get_variable_data_for_face(face)
|
||||
for ns in vd['named_styles']:
|
||||
if ns['axis_values'] == axis_map:
|
||||
return ns
|
||||
|
||||
Reference in New Issue
Block a user