Skip to content

Commit 6edeaf3

Browse files
committed
patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Problem: MS-Windows GUI: dialog font size is incorrect. Solution: Pass flag to indicate 'encoding' or active codepage. (Yasuhiro Matsomoto, closes #2160)
1 parent a8fc0d3 commit 6edeaf3

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/gui_w32.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4384,7 +4384,7 @@ add_dialog_element(
43844384
WORD clss,
43854385
const char *caption);
43864386
static LPWORD lpwAlign(LPWORD);
4387-
static int nCopyAnsiToWideChar(LPWORD, LPSTR);
4387+
static int nCopyAnsiToWideChar(LPWORD, LPSTR, BOOL);
43884388
#if defined(FEAT_MENU) && defined(FEAT_TEAROFF)
43894389
static void gui_mch_tearoff(char_u *title, vimmenu_T *menu, int initX, int initY);
43904390
#endif
@@ -7284,9 +7284,8 @@ gui_mch_dialog(
72847284
add_word(0); // Class
72857285

72867286
/* copy the title of the dialog */
7287-
nchar = nCopyAnsiToWideChar(p, (title ?
7288-
(LPSTR)title :
7289-
(LPSTR)("Vim "VIM_VERSION_MEDIUM)));
7287+
nchar = nCopyAnsiToWideChar(p, (title ? (LPSTR)title
7288+
: (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE);
72907289
p += nchar;
72917290

72927291
if (s_usenewlook)
@@ -7298,13 +7297,13 @@ gui_mch_dialog(
72987297
/* point size */
72997298
*p++ = -MulDiv(lfSysmenu.lfHeight, 72,
73007299
GetDeviceCaps(hdc, LOGPIXELSY));
7301-
nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
7300+
nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE);
73027301
}
73037302
else
73047303
#endif
73057304
{
73067305
*p++ = DLG_FONT_POINT_SIZE; // point size
7307-
nchar = nCopyAnsiToWideChar(p, TEXT(DLG_FONT_NAME));
7306+
nchar = nCopyAnsiToWideChar(p, DLG_FONT_NAME, FALSE);
73087307
}
73097308
p += nchar;
73107309
}
@@ -7485,7 +7484,7 @@ add_dialog_element(
74857484
*p++ = (WORD)0xffff;
74867485
*p++ = clss; //2 more here
74877486

7488-
nchar = nCopyAnsiToWideChar(p, (LPSTR)caption); //strlen(caption)+1
7487+
nchar = nCopyAnsiToWideChar(p, (LPSTR)caption, TRUE); //strlen(caption)+1
74897488
p += nchar;
74907489

74917490
*p++ = 0; // advance pointer over nExtraStuff WORD - 2 more
@@ -7517,19 +7516,21 @@ lpwAlign(
75177516
* parameter as wide character (16-bits / char) string, and returns integer
75187517
* number of wide characters (words) in string (including the trailing wide
75197518
* char NULL). Partly taken from the Win32SDK samples.
7520-
*/
7519+
* If "use_enc" is TRUE, 'encoding' is used for "lpAnsiIn". If FALSE, current
7520+
* ACP is used for "lpAnsiIn". */
75217521
static int
75227522
nCopyAnsiToWideChar(
75237523
LPWORD lpWCStr,
7524-
LPSTR lpAnsiIn)
7524+
LPSTR lpAnsiIn,
7525+
BOOL use_enc)
75257526
{
75267527
int nChar = 0;
75277528
#ifdef FEAT_MBYTE
75287529
int len = lstrlen(lpAnsiIn) + 1; /* include NUL character */
75297530
int i;
75307531
WCHAR *wn;
75317532

7532-
if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
7533+
if (use_enc && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
75337534
{
75347535
/* Not a codepage, use our own conversion function. */
75357536
wn = enc_to_utf16((char_u *)lpAnsiIn, NULL);
@@ -7852,8 +7853,8 @@ gui_mch_tearoff(
78527853

78537854
/* copy the title of the dialog */
78547855
nchar = nCopyAnsiToWideChar(p, ((*title)
7855-
? (LPSTR)title
7856-
: (LPSTR)("Vim "VIM_VERSION_MEDIUM)));
7856+
? (LPSTR)title
7857+
: (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE);
78577858
p += nchar;
78587859

78597860
if (s_usenewlook)
@@ -7865,13 +7866,13 @@ gui_mch_tearoff(
78657866
/* point size */
78667867
*p++ = -MulDiv(lfSysmenu.lfHeight, 72,
78677868
GetDeviceCaps(hdc, LOGPIXELSY));
7868-
nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
7869+
nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE);
78697870
}
78707871
else
78717872
#endif
78727873
{
78737874
*p++ = DLG_FONT_POINT_SIZE; // point size
7874-
nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME));
7875+
nchar = nCopyAnsiToWideChar(p, DLG_FONT_NAME, FALSE);
78757876
}
78767877
p += nchar;
78777878
}

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+
1150,
764766
/**/
765767
1149,
766768
/**/

0 commit comments

Comments
 (0)