To: vim-dev@vim.org Subject: Patch 5.6.057 (extra) Fcc: outbox From: Bram Moolenaar ------------ Patch 5.6.057 (extra) Problem: Win32 GUI: Multi-byte characters are wrong in dialogs and tear-off menus. Solution: Use system font instead of a fixed font. (Matsumoto, Muraoka) Files: src/gui_w32.c *** ../vim-5.6.56/src/gui_w32.c Thu Mar 30 18:39:21 2000 --- src/gui_w32.c Wed Apr 5 09:52:04 2000 *************** *** 161,166 **** --- 161,172 ---- #define DLG_FONT_POINT_SIZE 8 #define DLG_MIN_MAX_WIDTH 400 + /* + * Use the system font for dialogs and tear-off menus. Remove this line to + * use DLG_FONT_NAME. + */ + #define USE_SYSMENU_FONT + /* Some parameters for tearoff menus. All in pixels. */ #define TEAROFF_PADDING_X 2 #define TEAROFF_BUTTON_PAD_X 8 *************** *** 4694,4699 **** --- 4700,4727 ---- "IDR_VIM_QUESTION" }; + #ifdef USE_SYSMENU_FONT + /* + * Get Menu Font. + * Return OK or FAIL. + */ + static int + gui_w32_get_menu_font(LOGFONT *lf) + { + NONCLIENTMETRICS nm; + + nm.cbSize = sizeof(NONCLIENTMETRICS); + if (!SystemParametersInfo( + SPI_GETNONCLIENTMETRICS, + sizeof(NONCLIENTMETRICS), + &nm, + 0)) + return FAIL; + *lf = nm.lfMenuFont; + return OK; + } + #endif + int gui_mch_dialog( int type, *************** *** 4724,4729 **** --- 4752,4761 ---- int vertical; int dlgPaddingX; int dlgPaddingY; + #ifdef USE_SYSMENU_FONT + LOGFONT lfSysmenu; + int use_lfSysmenu = FALSE; + #endif #ifndef NO_CONSOLE /* Don't output anything in silent mode ("ex -s") */ *************** *** 4781,4786 **** --- 4813,4826 ---- */ hwnd = GetDesktopWindow(); hdc = GetWindowDC(hwnd); + #ifdef USE_SYSMENU_FONT + if (gui_w32_get_menu_font(&lfSysmenu) == OK) + { + font = CreateFontIndirect(&lfSysmenu); + use_lfSysmenu = TRUE; + } + else + #endif font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME); if (s_usenewlook) *************** *** 4918,4925 **** if (s_usenewlook) { /* do the font, since DS_3DLOOK doesn't work properly */ ! *p++ = DLG_FONT_POINT_SIZE; //point size ! nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME)); p += nchar; } --- 4958,4977 ---- if (s_usenewlook) { /* do the font, since DS_3DLOOK doesn't work properly */ ! #ifdef USE_SYSMENU_FONT ! if (use_lfSysmenu) ! { ! /* 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; } *************** *** 5263,5268 **** --- 5315,5324 ---- char_u *label, *text, *end, *acEnd = NULL; int padding0, padding1, padding2 = 0; int sepPadding=0; + #ifdef USE_SYSMENU_FONT + LOGFONT lfSysmenu; + int use_lfSysmenu = FALSE; + #endif /* * If this menu is already torn off, then don't *************** *** 5296,5301 **** --- 5352,5365 ---- hwnd = GetDesktopWindow(); hdc = GetWindowDC(hwnd); + #ifdef USE_SYSMENU_FONT + if (gui_w32_get_menu_font(&lfSysmenu) == OK) + { + font = CreateFontIndirect(&lfSysmenu); + use_lfSysmenu = TRUE; + } + else + #endif font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME); if (s_usenewlook) *************** *** 5396,5403 **** if (s_usenewlook) { /* do the font, since DS_3DLOOK doesn't work properly */ ! *p++ = DLG_FONT_POINT_SIZE; //point size ! nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME)); p += nchar; } --- 5460,5479 ---- if (s_usenewlook) { /* do the font, since DS_3DLOOK doesn't work properly */ ! #ifdef USE_SYSMENU_FONT ! if (use_lfSysmenu) ! { ! /* 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; } *************** *** 5425,5434 **** { len += STRLEN(menu->actext); acEnd = menu->actext + STRLEN(menu->actext); } - if (menu->actext != NULL) - textWidth = GetTextWidth(hdc, menu->actext, - acEnd - menu->actext); else textWidth = 0; --- 5501,5508 ---- { len += STRLEN(menu->actext); acEnd = menu->actext + STRLEN(menu->actext); + textWidth = GetTextWidth(hdc, menu->actext, acEnd - menu->actext); } else textWidth = 0; *************** *** 5528,5533 **** --- 5602,5610 ---- HFONT hfontTools = 0; DWORD dlgFontSize; SIZE size; + #ifdef USE_SYSMENU_FONT + LOGFONT lfSysmenu; + #endif s_usenewlook = FALSE; *************** *** 5537,5542 **** --- 5614,5624 ---- */ if (!is_winnt_3()) { + #ifdef USE_SYSMENU_FONT + if (gui_w32_get_menu_font(&lfSysmenu) == OK) + hfontTools = CreateFontIndirect(&lfSysmenu); + else + #endif hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME); *** ../vim-5.6.56/src/version.c Tue Apr 4 21:59:06 2000 --- src/version.c Wed Apr 5 10:02:53 2000 *************** *** 420,421 **** --- 420,423 ---- { /* Add new patch number below this line */ + /**/ + 57, /**/ -- ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot. King of all Britons, defeator of the Saxons, sovereign of all England! [Pause] SOLDIER: Get away! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\ \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/