From 109a856b919e5afbb259a9f4f2db37cc063e971a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 26 Jan 2020 08:00:06 +0530 Subject: [PATCH] Fix #2313 --- kitty/core_text.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kitty/core_text.m b/kitty/core_text.m index 73ad19f06..29036ea2f 100644 --- a/kitty/core_text.m +++ b/kitty/core_text.m @@ -457,11 +457,12 @@ render_simple_text_impl(PyObject *s, const char *text, unsigned int baseline) { CTFontGetGlyphsForCharacters(font, chars, glyphs, num_chars); CTFontGetAdvancesForGlyphs(font, kCTFontOrientationDefault, glyphs, advances, num_chars); CGRect bounding_box = CTFontGetBoundingRectsForGlyphs(font, kCTFontOrientationDefault, glyphs, boxes, num_chars); - StringCanvas ans = { .width = 0, .height = (size_t)(2 * bounding_box.size.height) }; - for (size_t i = 0, y = 0; i < num_chars; i++) { - positions[i] = CGPointMake(ans.width, y); - ans.width += advances[i].width; y += advances[i].height; + CGFloat x = 0, y = 0; + for (size_t i = 0; i < num_chars; i++) { + positions[i] = CGPointMake(x, y); + x += advances[i].width; y += advances[i].height; } + StringCanvas ans = { .width = (size_t)ceil(x), .height = (size_t)(2 * bounding_box.size.height) }; ensure_render_space(ans.width, ans.height); render_glyphs(font, ans.width, ans.height, baseline, num_chars); ans.canvas = malloc(ans.width * ans.height);