diff --git a/kitty/core_text.m b/kitty/core_text.m index 0704f6e3d..5057fc225 100644 --- a/kitty/core_text.m +++ b/kitty/core_text.m @@ -187,6 +187,18 @@ end: Py_RETURN_NONE; } +static PyObject * +repr(Face *self) { + char buf[400] = {0}; + snprintf(buf, sizeof(buf)/sizeof(buf[0]), "ascent=%.1f, descent=%.1f, leading=%.1f, point_sz=%.1f, scaled_point_sz=%.1f, underline_position=%.1f underline_thickness=%.1f", + (self->ascent), (self->descent), (self->leading), (self->point_sz), (self->scaled_point_sz), (self->underline_position), (self->underline_thickness)); + return PyUnicode_FromFormat( + "Face(family=%U, full_name=%U, postscript_name=%U, units_per_em=%u, %s)", + self->family_name, self->full_name, self->postscript_name, self->units_per_em, buf + ); +} + + // Boilerplate {{{ static PyMemberDef members[] = { @@ -224,6 +236,7 @@ PyTypeObject Face_Type = { .tp_methods = methods, .tp_members = members, .tp_new = new, + .tp_repr = (reprfunc)repr, }; diff --git a/kitty/fonts/core_text.py b/kitty/fonts/core_text.py index 14c37cfc3..c3751a3b9 100644 --- a/kitty/fonts/core_text.py +++ b/kitty/fonts/core_text.py @@ -76,10 +76,7 @@ def develop(family='monospace', sz=288): pass set_font_family(family, sz, ignore_dpi_failure=True) for (bold, italic), face in main_font.items(): - print('bold: {} italic: {} family:{} full name: {} postscript_name: {}'.format(bold, italic, face.family_name, face.full_name, face.postscript_name)) - f = main_font[(False, False)] - for attr in 'units_per_em ascent descent leading underline_position underline_thickness scaled_point_sz'.split(): - print(attr, getattr(f, attr)) + print('bold: {} italic: {} {}'.format(bold, italic, face)) print('cell_width: {}, cell_height: {}, baseline: {}'.format(cell_width, cell_height, baseline)) buf, w, h = render_string() open('/tmp/cell.data', 'wb').write(pickle.dumps((bytearray(buf), w, h)))