Output resolved fonts in debug config

This commit is contained in:
Kovid Goyal
2024-04-24 13:05:22 +05:30
parent 3ca20ebc4e
commit b385ccbc45
4 changed files with 24 additions and 3 deletions

View File

@@ -808,6 +808,13 @@ get_variable_data(CTFace *self) {
size_t table_len = cftable ? CFDataGetLength(cftable) : 0; size_t table_len = cftable ? CFDataGetLength(cftable) : 0;
return read_fvar_font_table(table, table_len, self->name_lookup_table); return read_fvar_font_table(table, table_len, self->name_lookup_table);
} }
static PyObject*
identify_for_debug(CTFace *self) {
return PyUnicode_FromFormat("%V: %V", self->postscript_name, "[psname]", self->path, "[path]");
}
// }}} // }}}
@@ -822,6 +829,7 @@ display_name(CTFace *self) {
static PyMethodDef methods[] = { static PyMethodDef methods[] = {
METHODB(display_name, METH_NOARGS), METHODB(display_name, METH_NOARGS),
METHODB(get_variable_data, METH_NOARGS), METHODB(get_variable_data, METH_NOARGS),
METHODB(identify_for_debug, METH_NOARGS),
METHODB(get_best_name, METH_O), METHODB(get_best_name, METH_O),
{NULL} /* Sentinel */ {NULL} /* Sentinel */
}; };

View File

@@ -17,7 +17,7 @@ from kittens.tui.operations import colored, styled
from .child import cmdline_of_pid from .child import cmdline_of_pid
from .cli import version from .cli import version
from .constants import extensions_dir, is_macos, is_wayland, kitty_base_dir, kitty_exe, shell_path from .constants import extensions_dir, is_macos, is_wayland, kitty_base_dir, kitty_exe, shell_path
from .fast_data_types import Color, SingleKey, num_users, opengl_version_string, wayland_compositor_data from .fast_data_types import Color, SingleKey, current_fonts, num_users, opengl_version_string, wayland_compositor_data
from .options.types import Options as KittyOpts from .options.types import Options as KittyOpts
from .options.types import defaults from .options.types import defaults
from .options.utils import KeyboardMode, KeyDefinition from .options.utils import KeyboardMode, KeyDefinition
@@ -257,6 +257,10 @@ def debug_config(opts: KittyOpts) -> str:
p('Running under:', green(compositor_name())) p('Running under:', green(compositor_name()))
p(green('OpenGL:'), opengl_version_string()) p(green('OpenGL:'), opengl_version_string())
p(green('Frozen:'), 'True' if getattr(sys, 'frozen', False) else 'False') p(green('Frozen:'), 'True' if getattr(sys, 'frozen', False) else 'False')
p(green('Fonts:'))
for k, font in current_fonts().items():
if hasattr(font, 'identify_for_debug'):
p(yellow(f' {k}:'), font.identify_for_debug())
p(green('Paths:')) p(green('Paths:'))
p(yellow(' kitty:'), os.path.realpath(kitty_exe())) p(yellow(' kitty:'), os.path.realpath(kitty_exe()))
p(yellow(' base dir:'), kitty_base_dir) p(yellow(' base dir:'), kitty_base_dir)

View File

@@ -420,6 +420,7 @@ def fc_match_postscript_name(
class Face: class Face:
def __init__(self, descriptor: Optional[FontConfigPattern] = None, path: str = '', index: int = 0): ... def __init__(self, descriptor: Optional[FontConfigPattern] = None, path: str = '', index: int = 0): ...
def get_variable_data(self) -> VariableData: ... def get_variable_data(self) -> VariableData: ...
def identify_for_debug(self) -> str: ...
class CoreTextFont(TypedDict): class CoreTextFont(TypedDict):
@@ -445,6 +446,7 @@ class CoreTextFont(TypedDict):
class CTFace: class CTFace:
def __init__(self, descriptor: Optional[CoreTextFont] = None, path: str = ''): ... def __init__(self, descriptor: Optional[CoreTextFont] = None, path: str = ''): ...
def get_variable_data(self) -> VariableData: ... def get_variable_data(self) -> VariableData: ...
def identify_for_debug(self) -> str: ...
def coretext_all_fonts() -> Tuple[CoreTextFont, ...]: def coretext_all_fonts() -> Tuple[CoreTextFont, ...]:

View File

@@ -691,7 +691,7 @@ render_glyphs_in_cells(PyObject *f, bool bold, bool italic, hb_glyph_info_t *inf
} }
static PyObject* static PyObject*
display_name(PyObject *s, PyObject *a UNUSED) { postscript_name(PyObject *s, PyObject *a UNUSED) {
Face *self = (Face*)s; Face *self = (Face*)s;
const char *psname = FT_Get_Postscript_Name(self->face); const char *psname = FT_Get_Postscript_Name(self->face);
if (psname) return Py_BuildValue("s", psname); if (psname) return Py_BuildValue("s", psname);
@@ -699,6 +699,12 @@ display_name(PyObject *s, PyObject *a UNUSED) {
return self->path; return self->path;
} }
static PyObject*
identify_for_debug(PyObject *s, PyObject *a UNUSED) {
Face *self = (Face*)s;
return PyUnicode_FromFormat("%s: %V:%d", FT_Get_Postscript_Name(self->face), self->path, "[path]", self->instance.val);
}
static PyObject* static PyObject*
extra_data(PyObject *self, PyObject *a UNUSED) { extra_data(PyObject *self, PyObject *a UNUSED) {
return PyLong_FromVoidPtr(((Face*)self)->extra_data); return PyLong_FromVoidPtr(((Face*)self)->extra_data);
@@ -862,7 +868,8 @@ static PyMemberDef members[] = {
}; };
static PyMethodDef methods[] = { static PyMethodDef methods[] = {
METHODB(display_name, METH_NOARGS), METHODB(postscript_name, METH_NOARGS),
METHODB(identify_for_debug, METH_NOARGS),
METHODB(extra_data, METH_NOARGS), METHODB(extra_data, METH_NOARGS),
METHODB(get_variable_data, METH_NOARGS), METHODB(get_variable_data, METH_NOARGS),
METHODB(get_best_name, METH_O), METHODB(get_best_name, METH_O),