From 859033415bee142a5808bd6ad4cc6dbd4ccbbb85 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Apr 2020 13:24:55 +0530 Subject: [PATCH] macOS: Fix incorrect horizontal positioning of some full-width East Asian characters Fixes #1457 Also render multi-cell PUA characters centered, matching behavior on other platforms --- docs/changelog.rst | 6 ++++++ kitty/core_text.m | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c37756de2..ad74c9060 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -25,6 +25,12 @@ To update |kitty|, :doc:`follow the instructions `. - Fix specifying options for layouts in the startup session file not working (:iss:`2520`) +- macOS: Fix incorrect horizontal positioning of some full-width East Asian characters + (:iss:`1457`) + +- macOS: Render multi-cell PUA characters centered, matching behavior on other + platforms + 0.17.2 [2020-03-29] -------------------- diff --git a/kitty/core_text.m b/kitty/core_text.m index 15d58c460..9e25a42da 100644 --- a/kitty/core_text.m +++ b/kitty/core_text.m @@ -505,10 +505,10 @@ do_render(CTFontRef ct_font, bool bold, bool italic, hb_glyph_info_t *info, hb_g Region src = {.bottom=cell_height, .right=canvas_width}, dest = {.bottom=cell_height, .right=canvas_width}; render_alpha_mask(render_buf, canvas, &src, &dest, canvas_width, canvas_width); } - if (num_cells > 1) { - // center glyphs - CGFloat delta = canvas_width - br.size.width; - if (delta > 1) right_shift_canvas(canvas, canvas_width, cell_height, (unsigned)(delta / 2.f)); + if (num_cells && (center_glyph || (num_cells == 2 && *was_colored))) { + // center glyphs (two cell emoji and PUA glyphs) + CGFloat delta = (((CGFloat)canvas_width - br.size.width) / 2.f) - br.origin.x; + if (delta >= 1.f) right_shift_canvas(canvas, canvas_width, cell_height, (unsigned)(delta)); } return true; }