To: vim_dev@googlegroups.com Subject: Patch 8.0.1150 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1150 Problem: MS-Windows GUI: dialog font size is incorrect. Solution: Pass flag to indicate 'encoding' or active codepage. (Yasuhiro Matsomoto, closes #2160) Files: src/gui_w32.c *** ../vim-8.0.1149/src/gui_w32.c 2017-09-22 14:35:46.592623416 +0200 --- src/gui_w32.c 2017-09-26 14:45:22.751957065 +0200 *************** *** 4384,4390 **** WORD clss, const char *caption); static LPWORD lpwAlign(LPWORD); ! static int nCopyAnsiToWideChar(LPWORD, LPSTR); #if defined(FEAT_MENU) && defined(FEAT_TEAROFF) static void gui_mch_tearoff(char_u *title, vimmenu_T *menu, int initX, int initY); #endif --- 4384,4390 ---- WORD clss, const char *caption); static LPWORD lpwAlign(LPWORD); ! static int nCopyAnsiToWideChar(LPWORD, LPSTR, BOOL); #if defined(FEAT_MENU) && defined(FEAT_TEAROFF) static void gui_mch_tearoff(char_u *title, vimmenu_T *menu, int initX, int initY); #endif *************** *** 7284,7292 **** add_word(0); // Class /* copy the title of the dialog */ ! nchar = nCopyAnsiToWideChar(p, (title ? ! (LPSTR)title : ! (LPSTR)("Vim "VIM_VERSION_MEDIUM))); p += nchar; if (s_usenewlook) --- 7284,7291 ---- add_word(0); // Class /* copy the title of the dialog */ ! nchar = nCopyAnsiToWideChar(p, (title ? (LPSTR)title ! : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE); p += nchar; if (s_usenewlook) *************** *** 7298,7310 **** /* point size */ *p++ = -MulDiv(lfSysmenu.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); ! nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName)); } else #endif { *p++ = DLG_FONT_POINT_SIZE; // point size ! nchar = nCopyAnsiToWideChar(p, TEXT(DLG_FONT_NAME)); } p += nchar; } --- 7297,7309 ---- /* point size */ *p++ = -MulDiv(lfSysmenu.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); ! nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE); } else #endif { *p++ = DLG_FONT_POINT_SIZE; // point size ! nchar = nCopyAnsiToWideChar(p, DLG_FONT_NAME, FALSE); } p += nchar; } *************** *** 7485,7491 **** *p++ = (WORD)0xffff; *p++ = clss; //2 more here ! nchar = nCopyAnsiToWideChar(p, (LPSTR)caption); //strlen(caption)+1 p += nchar; *p++ = 0; // advance pointer over nExtraStuff WORD - 2 more --- 7484,7490 ---- *p++ = (WORD)0xffff; *p++ = clss; //2 more here ! nchar = nCopyAnsiToWideChar(p, (LPSTR)caption, TRUE); //strlen(caption)+1 p += nchar; *p++ = 0; // advance pointer over nExtraStuff WORD - 2 more *************** *** 7517,7527 **** * parameter as wide character (16-bits / char) string, and returns integer * number of wide characters (words) in string (including the trailing wide * char NULL). Partly taken from the Win32SDK samples. ! */ static int nCopyAnsiToWideChar( LPWORD lpWCStr, ! LPSTR lpAnsiIn) { int nChar = 0; #ifdef FEAT_MBYTE --- 7516,7528 ---- * parameter as wide character (16-bits / char) string, and returns integer * number of wide characters (words) in string (including the trailing wide * char NULL). Partly taken from the Win32SDK samples. ! * If "use_enc" is TRUE, 'encoding' is used for "lpAnsiIn". If FALSE, current ! * ACP is used for "lpAnsiIn". */ static int nCopyAnsiToWideChar( LPWORD lpWCStr, ! LPSTR lpAnsiIn, ! BOOL use_enc) { int nChar = 0; #ifdef FEAT_MBYTE *************** *** 7529,7535 **** int i; WCHAR *wn; ! if (enc_codepage == 0 && (int)GetACP() != enc_codepage) { /* Not a codepage, use our own conversion function. */ wn = enc_to_utf16((char_u *)lpAnsiIn, NULL); --- 7530,7536 ---- int i; WCHAR *wn; ! if (use_enc && enc_codepage >= 0 && (int)GetACP() != enc_codepage) { /* Not a codepage, use our own conversion function. */ wn = enc_to_utf16((char_u *)lpAnsiIn, NULL); *************** *** 7852,7859 **** /* copy the title of the dialog */ nchar = nCopyAnsiToWideChar(p, ((*title) ! ? (LPSTR)title ! : (LPSTR)("Vim "VIM_VERSION_MEDIUM))); p += nchar; if (s_usenewlook) --- 7853,7860 ---- /* copy the title of the dialog */ nchar = nCopyAnsiToWideChar(p, ((*title) ! ? (LPSTR)title ! : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE); p += nchar; if (s_usenewlook) *************** *** 7865,7877 **** /* point size */ *p++ = -MulDiv(lfSysmenu.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); ! nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName)); } else #endif { *p++ = DLG_FONT_POINT_SIZE; // point size ! nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME)); } p += nchar; } --- 7866,7878 ---- /* point size */ *p++ = -MulDiv(lfSysmenu.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); ! nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE); } else #endif { *p++ = DLG_FONT_POINT_SIZE; // point size ! nchar = nCopyAnsiToWideChar(p, DLG_FONT_NAME, FALSE); } p += nchar; } *** ../vim-8.0.1149/src/version.c 2017-09-26 13:59:27.196906599 +0200 --- src/version.c 2017-09-26 14:43:24.336683921 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1150, /**/ -- hundred-and-one symptoms of being an internet addict: 200. You really believe in the concept of a "paperless" office. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///