parent
9f3d6fe0e9
commit
598c5d313b
@ -134,7 +134,12 @@ cell_size(Face *self) {
|
||||
if (w > width) width = w;
|
||||
}
|
||||
}
|
||||
return Py_BuildValue("I", width);
|
||||
// See https://stackoverflow.com/questions/5511830/how-does-line-spacing-work-in-core-text-and-why-is-it-different-from-nslayoutm
|
||||
CGFloat leading = MAX(0, self->leading);
|
||||
leading = floor(leading + 0.5);
|
||||
CGFloat line_height = floor(self->ascent + 0.5) + floor(self->descent + 0.5) + leading;
|
||||
CGFloat ascender_delta = (leading > 0) ? 0 : floor(0.2 * line_height + 0.5);
|
||||
return Py_BuildValue("II", width, (unsigned int)(line_height + ascender_delta));
|
||||
#undef count
|
||||
}
|
||||
|
||||
|
||||
@ -25,8 +25,7 @@ def set_font_family(family, size_in_pts, ignore_dpi_failure=False):
|
||||
for italic in (False, True):
|
||||
main_font[(bold, italic)] = Face(family, bold, italic, True, size_in_pts, dpi)
|
||||
mf = main_font[(False, False)]
|
||||
cell_width = mf.cell_size()
|
||||
cell_height = ceil_int(mf.ascent + mf.descent)
|
||||
cell_width, cell_height = mf.cell_size()
|
||||
CellTexture = ctypes.c_ubyte * (cell_width * cell_height)
|
||||
WideCellTexture = ctypes.c_ubyte * (2 * cell_width * cell_height)
|
||||
baseline = int(round(mf.ascent))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user