0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.0.1234: MS-Windows: composing chars are not shown properly

Problem:    MS-Windows: composing characters are not shown properly.
Solution:   Pass base character and composing characters to the renderer at
            once. (Ken Takata, closes #2206)
This commit is contained in:
Bram Moolenaar
2017-10-28 19:23:11 +02:00
parent b9fce6cbf7
commit a6ce1ccf5c
3 changed files with 37 additions and 19 deletions

View File

@@ -2429,9 +2429,14 @@ gui_outstr_nowrap(
int cl; /* byte length of current char */ int cl; /* byte length of current char */
int comping; /* current char is composing */ int comping; /* current char is composing */
int scol = col; /* screen column */ int scol = col; /* screen column */
int curr_wide; /* use 'guifontwide' */ int curr_wide = FALSE; /* use 'guifontwide' */
int prev_wide = FALSE; int prev_wide = FALSE;
int wide_changed; int wide_changed;
# ifdef WIN3264
int sep_comp = FALSE; /* Don't separate composing chars. */
# else
int sep_comp = TRUE; /* Separate composing chars. */
# endif
/* Break the string at a composing character, it has to be drawn on /* Break the string at a composing character, it has to be drawn on
* top of the previous character. */ * top of the previous character. */
@@ -2441,6 +2446,11 @@ gui_outstr_nowrap(
{ {
c = utf_ptr2char(s + i); c = utf_ptr2char(s + i);
cn = utf_char2cells(c); cn = utf_char2cells(c);
comping = utf_iscomposing(c);
if (!comping) /* count cells from non-composing chars */
cells += cn;
if (!comping || sep_comp)
{
if (cn > 1 if (cn > 1
# ifdef FEAT_XFONTSET # ifdef FEAT_XFONTSET
&& fontset == NOFONTSET && fontset == NOFONTSET
@@ -2449,9 +2459,7 @@ gui_outstr_nowrap(
curr_wide = TRUE; curr_wide = TRUE;
else else
curr_wide = FALSE; curr_wide = FALSE;
comping = utf_iscomposing(c); }
if (!comping) /* count cells from non-composing chars */
cells += cn;
cl = utf_ptr2len(s + i); cl = utf_ptr2len(s + i);
if (cl == 0) /* hit end of string */ if (cl == 0) /* hit end of string */
len = i + cl; /* len must be wrong "cannot happen" */ len = i + cl; /* len must be wrong "cannot happen" */
@@ -2460,7 +2468,8 @@ gui_outstr_nowrap(
/* Print the string so far if it's the last character or there is /* Print the string so far if it's the last character or there is
* a composing character. */ * a composing character. */
if (i + cl >= len || (comping && i > start) || wide_changed if (i + cl >= len || (comping && sep_comp && i > start)
|| wide_changed
# if defined(FEAT_GUI_X11) # if defined(FEAT_GUI_X11)
|| (cn > 1 || (cn > 1
# ifdef FEAT_XFONTSET # ifdef FEAT_XFONTSET
@@ -2472,7 +2481,7 @@ gui_outstr_nowrap(
# endif # endif
) )
{ {
if (comping || wide_changed) if ((comping && sep_comp) || wide_changed)
thislen = i - start; thislen = i - start;
else else
thislen = i - start + cl; thislen = i - start + cl;
@@ -2490,7 +2499,7 @@ gui_outstr_nowrap(
cells = 0; cells = 0;
/* Adjust to not draw a character which width is changed /* Adjust to not draw a character which width is changed
* against with last one. */ * against with last one. */
if (wide_changed && !comping) if (wide_changed && !(comping && sep_comp))
{ {
scol -= cn; scol -= cn;
cl = 0; cl = 0;
@@ -2509,7 +2518,7 @@ gui_outstr_nowrap(
# endif # endif
} }
/* Draw a composing char on top of the previous char. */ /* Draw a composing char on top of the previous char. */
if (comping) if (comping && sep_comp)
{ {
# if (defined(__APPLE_CC__) || defined(__MRC__)) && TARGET_API_MAC_CARBON # if (defined(__APPLE_CC__) || defined(__MRC__)) && TARGET_API_MAC_CARBON
/* Carbon ATSUI autodraws composing char over previous char */ /* Carbon ATSUI autodraws composing char over previous char */

View File

@@ -6295,8 +6295,8 @@ gui_mch_draw_string(
if (enc_utf8 && n < len && unicodebuf != NULL) if (enc_utf8 && n < len && unicodebuf != NULL)
{ {
/* Output UTF-8 characters. Caller has already separated /* Output UTF-8 characters. Composing characters should be
* composing characters. */ * handled here. */
int i; int i;
int wlen; /* string length in words */ int wlen; /* string length in words */
int clen; /* string length in characters */ int clen; /* string length in characters */
@@ -6320,9 +6320,16 @@ gui_mch_draw_string(
{ {
unicodebuf[wlen++] = c; unicodebuf[wlen++] = c;
} }
if (utf_iscomposing(c))
cw = 0;
else
{
cw = utf_char2cells(c); cw = utf_char2cells(c);
if (cw > 2) /* don't use 4 for unprintable char */ if (cw > 2) /* don't use 4 for unprintable char */
cw = 1; cw = 1;
}
if (unicodepdy != NULL) if (unicodepdy != NULL)
{ {
/* Use unicodepdy to make characters fit as we expect, even /* Use unicodepdy to make characters fit as we expect, even
@@ -6337,7 +6344,7 @@ gui_mch_draw_string(
unicodepdy[wlen - 1] = cw * gui.char_width; unicodepdy[wlen - 1] = cw * gui.char_width;
} }
cells += cw; cells += cw;
i += utfc_ptr2len_len(text + i, len - i); i += utf_ptr2len_len(text + i, len - i);
++clen; ++clen;
} }
#if defined(FEAT_DIRECTX) #if defined(FEAT_DIRECTX)

View File

@@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1234,
/**/ /**/
1233, 1233,
/**/ /**/