DOnt be lazy about typing font features
This commit is contained in:
parent
b169831810
commit
ba821cb02f
@ -6,6 +6,7 @@ from typing import (
|
||||
|
||||
import termios
|
||||
from kitty.boss import Boss
|
||||
from kitty.fonts import FontFeature
|
||||
from kitty.fonts.render import FontObject
|
||||
from kitty.options_stub import Options
|
||||
|
||||
@ -886,7 +887,7 @@ def set_font_data(
|
||||
descriptor_for_idx: Callable[[int], Tuple[FontObject, bool, bool]],
|
||||
bold: int, italic: int, bold_italic: int, num_symbol_fonts: int,
|
||||
symbol_maps: Tuple[Tuple[int, int, int], ...], font_sz_in_pts: float,
|
||||
font_feature_settings: Dict[str, Tuple[str, ...]]
|
||||
font_feature_settings: Dict[str, Tuple[FontFeature, ...]]
|
||||
) -> None:
|
||||
pass
|
||||
|
||||
|
||||
@ -11,9 +11,13 @@ class ListedFont(TypedDict):
|
||||
is_monospace: bool
|
||||
|
||||
|
||||
class FontFeature(str):
|
||||
class FontFeature:
|
||||
|
||||
def __new__(cls, name: str, parsed: bytes) -> 'FontFeature':
|
||||
ans: FontFeature = str.__new__(cls, name)
|
||||
ans.parsed = parsed # type: ignore
|
||||
return ans
|
||||
__slots__ = 'name', 'parsed'
|
||||
|
||||
def __init__(self, name: str, parsed: bytes):
|
||||
self.name = name
|
||||
self.parsed = parsed
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return repr(self.name)
|
||||
|
||||
@ -6,6 +6,7 @@ import re
|
||||
from typing import Dict, Generator, Iterable, List, Optional, Tuple
|
||||
|
||||
from kitty.fast_data_types import coretext_all_fonts
|
||||
from kitty.fonts import FontFeature
|
||||
from kitty.options_stub import Options
|
||||
from kitty.typing import CoreTextFont
|
||||
from kitty.utils import log_error
|
||||
@ -50,7 +51,7 @@ def list_fonts() -> Generator[ListedFont, None, None]:
|
||||
yield {'family': f, 'full_name': fn, 'postscript_name': fd['postscript_name'] or '', 'is_monospace': is_mono}
|
||||
|
||||
|
||||
def find_font_features(postscript_name: str) -> Tuple[str, ...]:
|
||||
def find_font_features(postscript_name: str) -> Tuple[FontFeature, ...]:
|
||||
"""Not Implemented"""
|
||||
return ()
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ def fc_match(family: str, bold: bool, italic: bool, spacing: int = FC_MONO) -> F
|
||||
return fc_match_impl(family, bold, italic, spacing)
|
||||
|
||||
|
||||
def find_font_features(postscript_name: str) -> Tuple[str, ...]:
|
||||
def find_font_features(postscript_name: str) -> Tuple[FontFeature, ...]:
|
||||
pat = fc_match_postscript_name(postscript_name)
|
||||
|
||||
if pat.get('postscript_name') != postscript_name or 'fontfeatures' not in pat:
|
||||
|
||||
@ -17,11 +17,12 @@ def generate_stub():
|
||||
all_options,
|
||||
special_types={
|
||||
'symbol_map': 'typing.Dict[typing.Tuple[int, int], str]',
|
||||
'font_features': 'typing.Dict[str, typing.Tuple[str, ...]]'
|
||||
'font_features': 'typing.Dict[str, typing.Tuple[FontFeature, ...]]'
|
||||
},
|
||||
preamble_lines=(
|
||||
'from kitty.types import SingleKey',
|
||||
'from kitty.config import KeyAction, KeyMap, SequenceMap, MouseMap',
|
||||
'from kitty.fonts import FontFeature',
|
||||
),
|
||||
extra_fields=(
|
||||
('keymap', 'KeyMap'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user