mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
...
This commit is contained in:
@@ -120,7 +120,7 @@ def get_features(features: Dict[str, Optional['FeatureData']]) -> Dict[str, FD]:
|
|||||||
|
|
||||||
|
|
||||||
def render_face_sample(font: Descriptor, opts: Options, dpi_x: float, dpi_y: float, width: int, height: int) -> RenderedSample:
|
def render_face_sample(font: Descriptor, opts: Options, dpi_x: float, dpi_y: float, width: int, height: int) -> RenderedSample:
|
||||||
face = face_from_descriptor(font)
|
face = face_from_descriptor(font, opts.font_size, dpi_x, dpi_y)
|
||||||
face.set_size(opts.font_size, dpi_x, dpi_y)
|
face.set_size(opts.font_size, dpi_x, dpi_y)
|
||||||
metadata = {
|
metadata = {
|
||||||
'variable_data': get_variable_data_for_face(face),
|
'variable_data': get_variable_data_for_face(face),
|
||||||
@@ -150,7 +150,7 @@ def render_family_sample(
|
|||||||
ans: Dict[str, RenderedSampleTransmit] = {}
|
ans: Dict[str, RenderedSampleTransmit] = {}
|
||||||
font_files = get_font_files(opts)
|
font_files = get_font_files(opts)
|
||||||
for x in family_key:
|
for x in family_key:
|
||||||
key: FaceKey = x + ': ' + getattr(opts, x).created_from_string, base_key
|
key: FaceKey = x + ': ' + str(getattr(opts, x)), base_key
|
||||||
if x == 'font_family':
|
if x == 'font_family':
|
||||||
desc = font_files['medium']
|
desc = font_files['medium']
|
||||||
elif x == 'bold_font':
|
elif x == 'bold_font':
|
||||||
@@ -174,8 +174,8 @@ def render_family_sample(
|
|||||||
ResolvedFace = Dict[Literal['family', 'spec'], str]
|
ResolvedFace = Dict[Literal['family', 'spec'], str]
|
||||||
|
|
||||||
|
|
||||||
def spec_for_descriptor(d: Descriptor) -> str:
|
def spec_for_descriptor(d: Descriptor, font_size: float) -> str:
|
||||||
face = face_from_descriptor(d)
|
face = face_from_descriptor(d, font_size, 288, 288)
|
||||||
return spec_for_face(d['family'], face).as_setting
|
return spec_for_face(d['family'], face).as_setting
|
||||||
|
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ def resolved_faces(opts: Options) -> Dict[OptNames, ResolvedFace]:
|
|||||||
ans: Dict[OptNames, ResolvedFace] = {}
|
ans: Dict[OptNames, ResolvedFace] = {}
|
||||||
def d(key: Literal['medium', 'bold', 'italic', 'bi'], opt_name: OptNames) -> None:
|
def d(key: Literal['medium', 'bold', 'italic', 'bi'], opt_name: OptNames) -> None:
|
||||||
descriptor = font_files[key]
|
descriptor = font_files[key]
|
||||||
ans[opt_name] = {'family': descriptor['family'], 'spec': spec_for_descriptor(descriptor)}
|
ans[opt_name] = {'family': descriptor['family'], 'spec': spec_for_descriptor(descriptor, opts.font_size)}
|
||||||
d('medium', 'font_family')
|
d('medium', 'font_family')
|
||||||
d('bold', 'bold_font')
|
d('bold', 'bold_font')
|
||||||
d('italic', 'italic_font')
|
d('italic', 'italic_font')
|
||||||
|
|||||||
@@ -197,6 +197,12 @@ class FontSpec(NamedTuple):
|
|||||||
a(key, f'{val:g}')
|
a(key, f'{val:g}')
|
||||||
return ' '.join(ans)
|
return ' '.join(ans)
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return self.as_setting
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return repr(str(self))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Descriptor = Union[FontConfigPattern, CoreTextFont]
|
Descriptor = Union[FontConfigPattern, CoreTextFont]
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ def get_font_from_spec(
|
|||||||
ans = get_fine_grained_font(spec, bold, italic, resolved_medium_font=resolved_medium_font, family_axis_values=family_axis_values,
|
ans = get_fine_grained_font(spec, bold, italic, resolved_medium_font=resolved_medium_font, family_axis_values=family_axis_values,
|
||||||
match_is_more_specific_than_family=match_is_more_specific_than_family)
|
match_is_more_specific_than_family=match_is_more_specific_than_family)
|
||||||
if spec.features:
|
if spec.features:
|
||||||
|
ans = ans.copy()
|
||||||
ans['features'] = spec.features
|
ans['features'] = spec.features
|
||||||
return ans
|
return ans
|
||||||
family = spec.system or ''
|
family = spec.system or ''
|
||||||
|
|||||||
Reference in New Issue
Block a user