From 7dcdb0e458971d218b99fb67f410b019da40c084 Mon Sep 17 00:00:00 2001 From: ichizok Date: Fri, 4 May 2018 16:17:53 +0900 Subject: [PATCH 1/2] Fix Core Text rendering --- src/MacVim/MMCoreTextView.m | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index e53eb6f9ea..a85a043a32 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -1431,7 +1431,7 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGPoint *positions, } CGContextSetRGBStrokeColor(context, RED(sp), GREEN(sp), BLUE(sp), - ALPHA(sp)); + ALPHA(sp)); CGContextStrokePath(context); } @@ -1449,13 +1449,10 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGPoint *positions, CGContextSetFontSize(context, [font pointSize]); // Calculate position of each glyph relative to (x,y). - if (!composing) { - float xrel = 0; - for (unsigned i = 0; i < length; ++i) { - positions[i].x = xrel; - positions[i].y = .0; - xrel += w; - } + float xrel = composing ? .0 : w; + for (unsigned i = 0; i < length; ++i) { + positions[i].x = i * xrel; + positions[i].y = .0; } CTFontRef fontRef = (CTFontRef)(wide ? [fontWide retain] From d06867040b733dc14764b8b998db633507ee3b8c Mon Sep 17 00:00:00 2001 From: ichizok Date: Tue, 8 May 2018 18:34:39 +0900 Subject: [PATCH 2/2] Fix display of 2-cells emoji --- src/screen.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/screen.c b/src/screen.c index 6eebb1fd8b..31d42fb011 100644 --- a/src/screen.c +++ b/src/screen.c @@ -8380,7 +8380,13 @@ screen_char(unsigned off, int row, int col) { char_u buf[MB_MAXBYTES + 1]; - if (utf_ambiguous_width(ScreenLinesUC[off])) + if (utf_ambiguous_width(ScreenLinesUC[off]) +# ifdef FEAT_GUI_MACVIM + /* In the GUI, check if the cell width is actually 1 in order + * to display 2-cells emoji correctly. */ + && (!gui.in_use || utf_char2cells(ScreenLinesUC[off]) == 1) +# endif + ) { if (*p_ambw == 'd' # ifdef FEAT_GUI @@ -8396,9 +8402,9 @@ screen_char(unsigned off, int row, int col) /* not sure where the cursor is after drawing the ambiguous width * character */ # ifdef FEAT_GUI_MACVIM - if (*p_ambw == 'd' || !gui.in_use) + if (*p_ambw == 'd' || !gui.in_use) # endif - screen_cur_col = 9999; + screen_cur_col = 9999; } else if (utf_char2cells(ScreenLinesUC[off]) > 1) ++screen_cur_col;