mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-13 03:59:23 +02:00
...
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
from enum import Enum, IntEnum, auto
|
||||
from typing import Callable, Dict, List, Literal, NamedTuple, Tuple, TypedDict, Union
|
||||
from typing import TYPE_CHECKING, Callable, Dict, List, Literal, NamedTuple, Tuple, TypedDict, Union
|
||||
|
||||
from kitty.types import run_once
|
||||
from kitty.typing import CoreTextFont, FontConfigPattern
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import re
|
||||
|
||||
|
||||
class ListedFont(TypedDict):
|
||||
family: str
|
||||
@@ -162,6 +166,11 @@ Descriptor = Union[FontConfigPattern, CoreTextFont]
|
||||
Scorer = Callable[[Descriptor], Score]
|
||||
|
||||
|
||||
def family_name_to_key(family: str) -> str:
|
||||
@run_once
|
||||
def fnname_pat() -> 're.Pattern[str]':
|
||||
import re
|
||||
return re.sub(r'\s+', ' ', family.lower())
|
||||
return re.compile(r'\s+')
|
||||
|
||||
|
||||
def family_name_to_key(family: str) -> str:
|
||||
return fnname_pat().sub(' ', family).strip().lower()
|
||||
|
||||
Reference in New Issue
Block a user