mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-09 23:54:20 +02:00
DRYer
This commit is contained in:
@@ -157,6 +157,14 @@ class FontSpec(NamedTuple):
|
||||
Descriptor = Union[FontConfigPattern, CoreTextFont]
|
||||
DescriptorVar = TypeVar('DescriptorVar', FontConfigPattern, CoreTextFont, Descriptor)
|
||||
|
||||
|
||||
class Score(NamedTuple):
|
||||
variable_score: int
|
||||
style_score: float
|
||||
monospace_score: int
|
||||
width_score: int
|
||||
|
||||
|
||||
class Scorer:
|
||||
|
||||
def __init__(self, bold: bool = False, italic: bool = False, monospaced: bool = True, prefer_variable: bool = False) -> None:
|
||||
|
||||
@@ -8,12 +8,11 @@ from functools import lru_cache
|
||||
from typing import Dict, Generator, Iterable, List, NamedTuple, Optional, Sequence, Tuple
|
||||
|
||||
from kitty.fast_data_types import CTFace, coretext_all_fonts
|
||||
from kitty.fonts import FontSpec, family_name_to_key
|
||||
from kitty.options.types import Options
|
||||
from kitty.typing import CoreTextFont
|
||||
from kitty.utils import log_error
|
||||
|
||||
from . import Descriptor, DescriptorVar, ListedFont, Scorer, VariableData
|
||||
from . import Descriptor, DescriptorVar, FontSpec, ListedFont, Score, Scorer, VariableData, family_name_to_key
|
||||
|
||||
attr_map = {(False, False): 'font_family',
|
||||
(True, False): 'bold_font',
|
||||
@@ -74,13 +73,6 @@ def list_fonts() -> Generator[ListedFont, None, None]:
|
||||
'is_variable': is_variable(fd), 'descriptor': fd, 'style': fd['style']}
|
||||
|
||||
|
||||
class Score(NamedTuple):
|
||||
variable_score: int
|
||||
style_score: float
|
||||
monospace_score: int
|
||||
width_score: int
|
||||
|
||||
|
||||
class WeightRange(NamedTuple):
|
||||
minimum: float = 99999
|
||||
maximum: float = -99999
|
||||
|
||||
@@ -21,7 +21,7 @@ from kitty.fast_data_types import (
|
||||
from kitty.fast_data_types import fc_match as fc_match_impl
|
||||
from kitty.typing import FontConfigPattern
|
||||
|
||||
from . import Descriptor, DescriptorVar, ListedFont, Scorer, VariableData, family_name_to_key
|
||||
from . import Descriptor, DescriptorVar, ListedFont, Score, Scorer, VariableData, family_name_to_key
|
||||
|
||||
FontCollectionMapType = Literal['family_map', 'ps_map', 'full_map', 'variable_map']
|
||||
FontMap = Dict[FontCollectionMapType, Dict[str, List[FontConfigPattern]]]
|
||||
@@ -83,13 +83,6 @@ def fc_match(family: str, bold: bool, italic: bool, spacing: int = FC_MONO) -> F
|
||||
return fc_match_impl(family, bold, italic, spacing)
|
||||
|
||||
|
||||
class Score(NamedTuple):
|
||||
variable_score: int
|
||||
style_score: float
|
||||
monospace_score: int
|
||||
width_score: int
|
||||
|
||||
|
||||
class WeightRange(NamedTuple):
|
||||
minimum: int = sys.maxsize
|
||||
maximum: int = -1
|
||||
|
||||
Reference in New Issue
Block a user