get_glyph_width for core text?!

This commit is contained in:
Daniel Hahler 2018-09-29 18:56:54 +02:00
parent 12cfe6d1d1
commit 3c4cb3c35b

View File

@ -221,6 +221,15 @@ is_glyph_empty(PyObject *s, glyph_index g) {
return bounds.size.width <= 0; return bounds.size.width <= 0;
} }
int
get_glyph_width(PyObject *s, glyph_index g) {
CTFace *self = (CTFace*)s;
CGGlyph gg = g;
CGRect bounds;
CTFontGetBoundingRectsForGlyphs(self->ct_font, kCTFontOrientationHorizontal, &gg, &bounds, 1);
return bounds.size.width;
}
static inline float static inline float
scaled_point_sz(FONTS_DATA_HANDLE fg) { scaled_point_sz(FONTS_DATA_HANDLE fg) {
return ((fg->logical_dpi_x + fg->logical_dpi_y) / 144.0) * fg->font_sz_in_pts; return ((fg->logical_dpi_x + fg->logical_dpi_y) / 144.0) * fg->font_sz_in_pts;