Implement CTFace.__repr__
This commit is contained in:
parent
ef4010b575
commit
f4a6c42b48
@ -187,6 +187,18 @@ end:
|
|||||||
Py_RETURN_NONE;
|
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 {{{
|
// Boilerplate {{{
|
||||||
|
|
||||||
static PyMemberDef members[] = {
|
static PyMemberDef members[] = {
|
||||||
@ -224,6 +236,7 @@ PyTypeObject Face_Type = {
|
|||||||
.tp_methods = methods,
|
.tp_methods = methods,
|
||||||
.tp_members = members,
|
.tp_members = members,
|
||||||
.tp_new = new,
|
.tp_new = new,
|
||||||
|
.tp_repr = (reprfunc)repr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -76,10 +76,7 @@ def develop(family='monospace', sz=288):
|
|||||||
pass
|
pass
|
||||||
set_font_family(family, sz, ignore_dpi_failure=True)
|
set_font_family(family, sz, ignore_dpi_failure=True)
|
||||||
for (bold, italic), face in main_font.items():
|
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))
|
print('bold: {} italic: {} {}'.format(bold, italic, face))
|
||||||
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('cell_width: {}, cell_height: {}, baseline: {}'.format(cell_width, cell_height, baseline))
|
print('cell_width: {}, cell_height: {}, baseline: {}'.format(cell_width, cell_height, baseline))
|
||||||
buf, w, h = render_string()
|
buf, w, h = render_string()
|
||||||
open('/tmp/cell.data', 'wb').write(pickle.dumps((bytearray(buf), w, h)))
|
open('/tmp/cell.data', 'wb').write(pickle.dumps((bytearray(buf), w, h)))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user