mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-22 00:08:04 +02:00
Handle variable fonts like cascadia code that dont have a postfix variation prefix name for some of their faces
This commit is contained in:
@@ -20,7 +20,7 @@ from kitty.fonts.common import (
|
||||
get_variable_data_for_descriptor,
|
||||
get_variable_data_for_face,
|
||||
is_variable,
|
||||
spec_for_descriptor,
|
||||
spec_for_face,
|
||||
)
|
||||
from kitty.fonts.list import create_family_groups
|
||||
from kitty.fonts.render import display_bitmap
|
||||
@@ -134,6 +134,11 @@ def render_family_sample(
|
||||
ResolvedFace = Dict[Literal['family', 'spec'], str]
|
||||
|
||||
|
||||
def spec_for_descriptor(d: Descriptor) -> str:
|
||||
face = face_from_descriptor(d)
|
||||
return spec_for_face(d['family'], face).as_setting
|
||||
|
||||
|
||||
def resolved_faces(opts: Options) -> Dict[OptNames, ResolvedFace]:
|
||||
font_files = get_font_files(opts)
|
||||
ans: Dict[OptNames, ResolvedFace] = {}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"kitty/tools/tui"
|
||||
"kitty/tools/tui/loop"
|
||||
"kitty/tools/utils"
|
||||
"kitty/tools/utils/shlex"
|
||||
"kitty/tools/wcswidth"
|
||||
)
|
||||
|
||||
@@ -28,7 +29,8 @@ type face_panel struct {
|
||||
}
|
||||
|
||||
func (self *face_panel) variable_spec(named_style string, axis_overrides map[string]float64) string {
|
||||
ans := fmt.Sprintf(`family="%s" variable_name="%s"`, self.family, self.current_preview.Variable_data.Variations_postscript_name_prefix)
|
||||
vname := self.current_preview.Variable_data.Variations_postscript_name_prefix
|
||||
ans := fmt.Sprintf(`family=%s variable_name=%s`, shlex.Quote(self.family), shlex.Quote(vname))
|
||||
if axis_overrides != nil {
|
||||
axis_values := self.current_preview.current_axis_values()
|
||||
maps.Copy(axis_values, axis_overrides)
|
||||
@@ -36,7 +38,7 @@ func (self *face_panel) variable_spec(named_style string, axis_overrides map[str
|
||||
ans += fmt.Sprintf(" %s=%g", tag, val)
|
||||
}
|
||||
} else if named_style != "" {
|
||||
ans += fmt.Sprintf(" style=\"%s\"", named_style)
|
||||
ans += fmt.Sprintf(" style=%s", shlex.Quote(named_style))
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user