Ensure underline_thickness is not zero
This commit is contained in:
parent
3437433ed4
commit
b603d7abb7
@ -22,7 +22,7 @@ typedef struct {
|
|||||||
FT_Face face;
|
FT_Face face;
|
||||||
unsigned int units_per_EM;
|
unsigned int units_per_EM;
|
||||||
int ascender, descender, height, max_advance_width, max_advance_height, underline_position, underline_thickness;
|
int ascender, descender, height, max_advance_width, max_advance_height, underline_position, underline_thickness;
|
||||||
int hinting, hintstyle;
|
int hinting, hintstyle, index;
|
||||||
bool is_scalable;
|
bool is_scalable;
|
||||||
float size_in_pts;
|
float size_in_pts;
|
||||||
FT_F26Dot6 char_width, char_height;
|
FT_F26Dot6 char_width, char_height;
|
||||||
@ -125,6 +125,7 @@ init_ft_face(Face *self, PyObject *path, int hinting, int hintstyle, float size_
|
|||||||
|
|
||||||
self->path = path;
|
self->path = path;
|
||||||
Py_INCREF(self->path);
|
Py_INCREF(self->path);
|
||||||
|
self->index = self->face->face_index & 0xFFFF;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,8 +202,8 @@ dealloc(Face* self) {
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
repr(Face *self) {
|
repr(Face *self) {
|
||||||
return PyUnicode_FromFormat(
|
return PyUnicode_FromFormat(
|
||||||
"Face(path=%S, is_scalable=%S, units_per_EM=%u, ascender=%i, descender=%i, height=%i, max_advance_width=%i max_advance_height=%i, underline_position=%i, underline_thickness=%i)",
|
"Face(path=%S, index=%d, is_scalable=%S, units_per_EM=%u, ascender=%i, descender=%i, height=%i, max_advance_width=%i max_advance_height=%i, underline_position=%i, underline_thickness=%i)",
|
||||||
self->path, self->is_scalable ? Py_True : Py_False,
|
self->path, self->index, self->is_scalable ? Py_True : Py_False,
|
||||||
self->ascender, self->descender, self->height, self->max_advance_width, self->max_advance_height, self->underline_position, self->underline_thickness
|
self->ascender, self->descender, self->height, self->max_advance_width, self->max_advance_height, self->underline_position, self->underline_thickness
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -239,14 +240,14 @@ cell_metrics(PyObject *s, unsigned int* cell_width, unsigned int* cell_height, u
|
|||||||
*cell_width = calc_cell_width(self);
|
*cell_width = calc_cell_width(self);
|
||||||
*cell_height = font_units_to_pixels(self, self->height);
|
*cell_height = font_units_to_pixels(self, self->height);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
if (self->apple_leading <= 0) {
|
|
||||||
// See https://stackoverflow.com/questions/5511830/how-does-line-spacing-work-in-core-text-and-why-is-it-different-from-nslayoutm
|
// See https://stackoverflow.com/questions/5511830/how-does-line-spacing-work-in-core-text-and-why-is-it-different-from-nslayoutm
|
||||||
|
if (self->apple_leading <= 0) {
|
||||||
*cell_height += floor(0.2 * (double)(*cell_height) + 0.5);
|
*cell_height += floor(0.2 * (double)(*cell_height) + 0.5);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*baseline = font_units_to_pixels(self, self->ascender);
|
*baseline = font_units_to_pixels(self, self->ascender);
|
||||||
*underline_position = MIN(*cell_height - 1, (unsigned int)font_units_to_pixels(self, MAX(0, self->ascender - self->underline_position)));
|
*underline_position = MIN(*cell_height - 1, (unsigned int)font_units_to_pixels(self, MAX(0, self->ascender - self->underline_position)));
|
||||||
*underline_thickness = font_units_to_pixels(self, self->underline_thickness);
|
*underline_thickness = MAX(1, font_units_to_pixels(self, self->underline_thickness));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -372,6 +373,11 @@ display_name(Face *self) {
|
|||||||
return self->path;
|
return self->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
extra_data(Face *self) {
|
||||||
|
return PyLong_FromVoidPtr(self->extra_data);
|
||||||
|
}
|
||||||
|
|
||||||
// Boilerplate {{{
|
// Boilerplate {{{
|
||||||
|
|
||||||
static PyMemberDef members[] = {
|
static PyMemberDef members[] = {
|
||||||
@ -391,6 +397,7 @@ static PyMemberDef members[] = {
|
|||||||
|
|
||||||
static PyMethodDef methods[] = {
|
static PyMethodDef methods[] = {
|
||||||
METHODB(display_name, METH_NOARGS),
|
METHODB(display_name, METH_NOARGS),
|
||||||
|
METHODB(extra_data, METH_NOARGS),
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user