From 3c4cb3c35b321e6f556c68c575d9be728367edd0 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 29 Sep 2018 18:56:54 +0200 Subject: [PATCH] get_glyph_width for core text?! --- kitty/core_text.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kitty/core_text.m b/kitty/core_text.m index 28079309f..560f6f83b 100644 --- a/kitty/core_text.m +++ b/kitty/core_text.m @@ -221,6 +221,15 @@ is_glyph_empty(PyObject *s, glyph_index g) { 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 scaled_point_sz(FONTS_DATA_HANDLE fg) { return ((fg->logical_dpi_x + fg->logical_dpi_y) / 144.0) * fg->font_sz_in_pts;