DOnt be lazy about typing font features
This commit is contained in:
@@ -6,6 +6,7 @@ from typing import (
|
|||||||
|
|
||||||
import termios
|
import termios
|
||||||
from kitty.boss import Boss
|
from kitty.boss import Boss
|
||||||
|
from kitty.fonts import FontFeature
|
||||||
from kitty.fonts.render import FontObject
|
from kitty.fonts.render import FontObject
|
||||||
from kitty.options_stub import Options
|
from kitty.options_stub import Options
|
||||||
|
|
||||||
@@ -886,7 +887,7 @@ def set_font_data(
|
|||||||
descriptor_for_idx: Callable[[int], Tuple[FontObject, bool, bool]],
|
descriptor_for_idx: Callable[[int], Tuple[FontObject, bool, bool]],
|
||||||
bold: int, italic: int, bold_italic: int, num_symbol_fonts: int,
|
bold: int, italic: int, bold_italic: int, num_symbol_fonts: int,
|
||||||
symbol_maps: Tuple[Tuple[int, int, int], ...], font_sz_in_pts: float,
|
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:
|
) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,13 @@ class ListedFont(TypedDict):
|
|||||||
is_monospace: bool
|
is_monospace: bool
|
||||||
|
|
||||||
|
|
||||||
class FontFeature(str):
|
class FontFeature:
|
||||||
|
|
||||||
def __new__(cls, name: str, parsed: bytes) -> 'FontFeature':
|
__slots__ = 'name', 'parsed'
|
||||||
ans: FontFeature = str.__new__(cls, name)
|
|
||||||
ans.parsed = parsed # type: ignore
|
def __init__(self, name: str, parsed: bytes):
|
||||||
return ans
|
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 typing import Dict, Generator, Iterable, List, Optional, Tuple
|
||||||
|
|
||||||
from kitty.fast_data_types import coretext_all_fonts
|
from kitty.fast_data_types import coretext_all_fonts
|
||||||
|
from kitty.fonts import FontFeature
|
||||||
from kitty.options_stub import Options
|
from kitty.options_stub import Options
|
||||||
from kitty.typing import CoreTextFont
|
from kitty.typing import CoreTextFont
|
||||||
from kitty.utils import log_error
|
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}
|
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"""
|
"""Not Implemented"""
|
||||||
return ()
|
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)
|
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)
|
pat = fc_match_postscript_name(postscript_name)
|
||||||
|
|
||||||
if pat.get('postscript_name') != postscript_name or 'fontfeatures' not in pat:
|
if pat.get('postscript_name') != postscript_name or 'fontfeatures' not in pat:
|
||||||
|
|||||||
@@ -17,11 +17,12 @@ def generate_stub():
|
|||||||
all_options,
|
all_options,
|
||||||
special_types={
|
special_types={
|
||||||
'symbol_map': 'typing.Dict[typing.Tuple[int, int], str]',
|
'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=(
|
preamble_lines=(
|
||||||
'from kitty.types import SingleKey',
|
'from kitty.types import SingleKey',
|
||||||
'from kitty.config import KeyAction, KeyMap, SequenceMap, MouseMap',
|
'from kitty.config import KeyAction, KeyMap, SequenceMap, MouseMap',
|
||||||
|
'from kitty.fonts import FontFeature',
|
||||||
),
|
),
|
||||||
extra_fields=(
|
extra_fields=(
|
||||||
('keymap', 'KeyMap'),
|
('keymap', 'KeyMap'),
|
||||||
|
|||||||
Reference in New Issue
Block a user