Skip to content

Commit a6ce1cc

Browse files
committed
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)
1 parent b9fce6c commit a6ce1cc

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

src/gui.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,9 +2429,14 @@ gui_outstr_nowrap(
24292429
int cl; /* byte length of current char */
24302430
int comping; /* current char is composing */
24312431
int scol = col; /* screen column */
2432-
int curr_wide; /* use 'guifontwide' */
2432+
int curr_wide = FALSE; /* use 'guifontwide' */
24332433
int prev_wide = FALSE;
24342434
int wide_changed;
2435+
# ifdef WIN3264
2436+
int sep_comp = FALSE; /* Don't separate composing chars. */
2437+
# else
2438+
int sep_comp = TRUE; /* Separate composing chars. */
2439+
# endif
24352440

24362441
/* Break the string at a composing character, it has to be drawn on
24372442
* top of the previous character. */
@@ -2441,17 +2446,20 @@ gui_outstr_nowrap(
24412446
{
24422447
c = utf_ptr2char(s + i);
24432448
cn = utf_char2cells(c);
2444-
if (cn > 1
2445-
# ifdef FEAT_XFONTSET
2446-
&& fontset == NOFONTSET
2447-
# endif
2448-
&& wide_font != NOFONT)
2449-
curr_wide = TRUE;
2450-
else
2451-
curr_wide = FALSE;
24522449
comping = utf_iscomposing(c);
24532450
if (!comping) /* count cells from non-composing chars */
24542451
cells += cn;
2452+
if (!comping || sep_comp)
2453+
{
2454+
if (cn > 1
2455+
# ifdef FEAT_XFONTSET
2456+
&& fontset == NOFONTSET
2457+
# endif
2458+
&& wide_font != NOFONT)
2459+
curr_wide = TRUE;
2460+
else
2461+
curr_wide = FALSE;
2462+
}
24552463
cl = utf_ptr2len(s + i);
24562464
if (cl == 0) /* hit end of string */
24572465
len = i + cl; /* len must be wrong "cannot happen" */
@@ -2460,7 +2468,8 @@ gui_outstr_nowrap(
24602468

24612469
/* Print the string so far if it's the last character or there is
24622470
* a composing character. */
2463-
if (i + cl >= len || (comping && i > start) || wide_changed
2471+
if (i + cl >= len || (comping && sep_comp && i > start)
2472+
|| wide_changed
24642473
# if defined(FEAT_GUI_X11)
24652474
|| (cn > 1
24662475
# ifdef FEAT_XFONTSET
@@ -2472,7 +2481,7 @@ gui_outstr_nowrap(
24722481
# endif
24732482
)
24742483
{
2475-
if (comping || wide_changed)
2484+
if ((comping && sep_comp) || wide_changed)
24762485
thislen = i - start;
24772486
else
24782487
thislen = i - start + cl;
@@ -2490,7 +2499,7 @@ gui_outstr_nowrap(
24902499
cells = 0;
24912500
/* Adjust to not draw a character which width is changed
24922501
* against with last one. */
2493-
if (wide_changed && !comping)
2502+
if (wide_changed && !(comping && sep_comp))
24942503
{
24952504
scol -= cn;
24962505
cl = 0;
@@ -2509,7 +2518,7 @@ gui_outstr_nowrap(
25092518
# endif
25102519
}
25112520
/* Draw a composing char on top of the previous char. */
2512-
if (comping)
2521+
if (comping && sep_comp)
25132522
{
25142523
# if (defined(__APPLE_CC__) || defined(__MRC__)) && TARGET_API_MAC_CARBON
25152524
/* Carbon ATSUI autodraws composing char over previous char */

src/gui_w32.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6295,8 +6295,8 @@ gui_mch_draw_string(
62956295

62966296
if (enc_utf8 && n < len && unicodebuf != NULL)
62976297
{
6298-
/* Output UTF-8 characters. Caller has already separated
6299-
* composing characters. */
6298+
/* Output UTF-8 characters. Composing characters should be
6299+
* handled here. */
63006300
int i;
63016301
int wlen; /* string length in words */
63026302
int clen; /* string length in characters */
@@ -6320,9 +6320,16 @@ gui_mch_draw_string(
63206320
{
63216321
unicodebuf[wlen++] = c;
63226322
}
6323-
cw = utf_char2cells(c);
6324-
if (cw > 2) /* don't use 4 for unprintable char */
6325-
cw = 1;
6323+
6324+
if (utf_iscomposing(c))
6325+
cw = 0;
6326+
else
6327+
{
6328+
cw = utf_char2cells(c);
6329+
if (cw > 2) /* don't use 4 for unprintable char */
6330+
cw = 1;
6331+
}
6332+
63266333
if (unicodepdy != NULL)
63276334
{
63286335
/* Use unicodepdy to make characters fit as we expect, even
@@ -6337,7 +6344,7 @@ gui_mch_draw_string(
63376344
unicodepdy[wlen - 1] = cw * gui.char_width;
63386345
}
63396346
cells += cw;
6340-
i += utfc_ptr2len_len(text + i, len - i);
6347+
i += utf_ptr2len_len(text + i, len - i);
63416348
++clen;
63426349
}
63436350
#if defined(FEAT_DIRECTX)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1234,
764766
/**/
765767
1233,
766768
/**/

0 commit comments

Comments
 (0)