Output font features in debug info

This commit is contained in:
Kovid Goyal 2024-08-25 11:19:36 +05:30
parent 0d57253300
commit ab3cefd81f
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 20 additions and 4 deletions

View file

@ -1070,10 +1070,16 @@ static CTFontRef nerd_font(CGFloat sz) {
static PyObject*
identify_for_debug(CTFace *self) {
return PyUnicode_FromFormat("%V: %V", self->postscript_name, "[psname]", self->path, "[path]");
RAII_PyObject(features, PyTuple_New(self->font_features.count)); if (!features) return NULL;
char buf[128];
for (unsigned i = 0; i < self->font_features.count; i++) {
hb_feature_to_string(self->font_features.features + i, buf, sizeof(buf));
PyObject *f = PyUnicode_FromString(buf); if (!f) return NULL;
PyTuple_SET_ITEM(features, i, f);
}
return PyUnicode_FromFormat("%V: %V\nFeatures: %S", self->postscript_name, "[psname]", self->path, "[path]", features);
}
// }}}

View file

@ -261,7 +261,10 @@ def debug_config(opts: KittyOpts) -> str:
p(green('Fonts:'))
for k, font in current_fonts().items():
if hasattr(font, 'identify_for_debug'):
p(yellow(f' {k}:'), font.identify_for_debug())
flines = font.identify_for_debug().splitlines()
p(yellow(f'{k.rjust(8)}:'), flines[0])
for fl in flines[1:]:
p(' ' * 9, fl)
p(green('Paths:'))
p(yellow(' kitty:'), os.path.realpath(kitty_exe()))
p(yellow(' base dir:'), kitty_base_dir)

View file

@ -747,7 +747,14 @@ identify_for_debug(PyObject *s, PyObject *a UNUSED) {
Face *self = (Face*)s;
FaceIndex instance;
instance.val = self->face->face_index;
return PyUnicode_FromFormat("%s: %V:%d", FT_Get_Postscript_Name(self->face), self->path, "[path]", instance.val);
RAII_PyObject(features, PyTuple_New(self->font_features.count)); if (!features) return NULL;
char buf[128];
for (unsigned i = 0; i < self->font_features.count; i++) {
hb_feature_to_string(self->font_features.features + i, buf, sizeof(buf));
PyObject *f = PyUnicode_FromString(buf); if (!f) return NULL;
PyTuple_SET_ITEM(features, i, f);
}
return PyUnicode_FromFormat("%s: %V:%d\nFeatures: %S", FT_Get_Postscript_Name(self->face), self->path, "[path]", instance.val, features);
}
static PyObject*