Mercurial > vim
comparison src/gui_w32.c @ 16152:8f4eccaaf2c0 v8.1.1081
patch 8.1.1081: MS-Windows: cannot use some fonts
commit https://github.com/vim/vim/commit/433a5eb9de861dd01ea3b3dfa3b8fe23527cab54
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 30 16:24:16 2019 +0100
patch 8.1.1081: MS-Windows: cannot use some fonts
Problem: MS-Windows: cannot use fonts whose name cannot be represented in
the current code page.
Solution: Use wide font functions. (Ken Takata, closes #4000)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 30 Mar 2019 16:30:04 +0100 |
parents | a246b020984c |
children | cd5c83115ec6 |
comparison
equal
deleted
inserted
replaced
16151:6285d4ff3255 | 16152:8f4eccaaf2c0 |
---|---|
251 typedef int HANDLE; | 251 typedef int HANDLE; |
252 typedef int HBITMAP; | 252 typedef int HBITMAP; |
253 typedef int HBRUSH; | 253 typedef int HBRUSH; |
254 typedef int HDROP; | 254 typedef int HDROP; |
255 typedef int INT; | 255 typedef int INT; |
256 typedef int LOGFONT[]; | 256 typedef int LOGFONTW[]; |
257 typedef int LPARAM; | 257 typedef int LPARAM; |
258 typedef int LPCREATESTRUCT; | 258 typedef int LPCREATESTRUCT; |
259 typedef int LPCSTR; | 259 typedef int LPCSTR; |
260 typedef int LPCTSTR; | 260 typedef int LPCTSTR; |
261 typedef int LPRECT; | 261 typedef int LPRECT; |
499 #endif | 499 #endif |
500 | 500 |
501 /* | 501 /* |
502 * For control IME. | 502 * For control IME. |
503 * | 503 * |
504 * These LOGFONT used for IME. | 504 * These LOGFONTW used for IME. |
505 */ | 505 */ |
506 #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME) | 506 #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME) |
507 /* holds LOGFONT for 'guifontwide' if available, otherwise 'guifont' */ | 507 /* holds LOGFONTW for 'guifontwide' if available, otherwise 'guifont' */ |
508 static LOGFONT norm_logfont; | 508 static LOGFONTW norm_logfont; |
509 #endif | 509 #endif |
510 #ifdef FEAT_MBYTE_IME | 510 #ifdef FEAT_MBYTE_IME |
511 /* holds LOGFONT for 'guifont' always. */ | 511 /* holds LOGFONTW for 'guifont' always. */ |
512 static LOGFONT sub_logfont; | 512 static LOGFONTW sub_logfont; |
513 #endif | 513 #endif |
514 | 514 |
515 #ifdef FEAT_MBYTE_IME | 515 #ifdef FEAT_MBYTE_IME |
516 static LRESULT _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData); | 516 static LRESULT _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData); |
517 #endif | 517 #endif |
1518 GetFontSize(gui.norm_font); | 1518 GetFontSize(gui.norm_font); |
1519 return OK; | 1519 return OK; |
1520 } | 1520 } |
1521 | 1521 |
1522 static GuiFont | 1522 static GuiFont |
1523 get_font_handle(LOGFONT *lf) | 1523 get_font_handle(LOGFONTW *lf) |
1524 { | 1524 { |
1525 HFONT font = NULL; | 1525 HFONT font = NULL; |
1526 | 1526 |
1527 /* Load the font */ | 1527 /* Load the font */ |
1528 font = CreateFontIndirect(lf); | 1528 font = CreateFontIndirectW(lf); |
1529 | 1529 |
1530 if (font == NULL) | 1530 if (font == NULL) |
1531 return NOFONT; | 1531 return NOFONT; |
1532 | 1532 |
1533 return (GuiFont)font; | 1533 return (GuiFont)font; |
1554 GuiFont | 1554 GuiFont |
1555 gui_mch_get_font( | 1555 gui_mch_get_font( |
1556 char_u *name, | 1556 char_u *name, |
1557 int giveErrorIfMissing) | 1557 int giveErrorIfMissing) |
1558 { | 1558 { |
1559 LOGFONT lf; | 1559 LOGFONTW lf; |
1560 GuiFont font = NOFONT; | 1560 GuiFont font = NOFONT; |
1561 | 1561 |
1562 if (get_logfont(&lf, name, NULL, giveErrorIfMissing) == OK) | 1562 if (get_logfont(&lf, name, NULL, giveErrorIfMissing) == OK) |
1563 font = get_font_handle(&lf); | 1563 font = get_font_handle(&lf); |
1564 if (font == NOFONT && giveErrorIfMissing) | 1564 if (font == NOFONT && giveErrorIfMissing) |
3199 global_ime_end(); | 3199 global_ime_end(); |
3200 #endif | 3200 #endif |
3201 } | 3201 } |
3202 | 3202 |
3203 static char_u * | 3203 static char_u * |
3204 logfont2name(LOGFONT lf) | 3204 logfont2name(LOGFONTW lf) |
3205 { | 3205 { |
3206 char *p; | 3206 char *p; |
3207 char *res; | 3207 char *res; |
3208 char *charset_name; | 3208 char *charset_name; |
3209 char *quality_name; | 3209 char *quality_name; |
3210 char *font_name = lf.lfFaceName; | 3210 char *font_name; |
3211 | 3211 |
3212 font_name = (char *)utf16_to_enc(lf.lfFaceName, NULL); | |
3213 if (font_name == NULL) | |
3214 return NULL; | |
3212 charset_name = charset_id2name((int)lf.lfCharSet); | 3215 charset_name = charset_id2name((int)lf.lfCharSet); |
3213 /* Convert a font name from the current codepage to 'encoding'. | |
3214 * TODO: Use Wide APIs (including LOGFONTW) instead of ANSI APIs. */ | |
3215 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | |
3216 { | |
3217 int len; | |
3218 acp_to_enc((char_u *)lf.lfFaceName, (int)strlen(lf.lfFaceName), | |
3219 (char_u **)&font_name, &len); | |
3220 } | |
3221 quality_name = quality_id2name((int)lf.lfQuality); | 3216 quality_name = quality_id2name((int)lf.lfQuality); |
3222 | 3217 |
3223 res = (char *)alloc((unsigned)(strlen(font_name) + 20 | 3218 res = (char *)alloc((unsigned)(strlen(font_name) + 20 |
3224 + (charset_name == NULL ? 0 : strlen(charset_name) + 2))); | 3219 + (charset_name == NULL ? 0 : strlen(charset_name) + 2))); |
3225 if (res != NULL) | 3220 if (res != NULL) |
3252 STRCAT(p, ":q"); | 3247 STRCAT(p, ":q"); |
3253 STRCAT(p, quality_name); | 3248 STRCAT(p, quality_name); |
3254 } | 3249 } |
3255 } | 3250 } |
3256 | 3251 |
3257 if (font_name != lf.lfFaceName) | 3252 vim_free(font_name); |
3258 vim_free(font_name); | |
3259 return (char_u *)res; | 3253 return (char_u *)res; |
3260 } | 3254 } |
3261 | 3255 |
3262 | 3256 |
3263 #ifdef FEAT_MBYTE_IME | 3257 #ifdef FEAT_MBYTE_IME |
3264 /* | 3258 /* |
3265 * Set correct LOGFONT to IME. Use 'guifontwide' if available, otherwise use | 3259 * Set correct LOGFONTW to IME. Use 'guifontwide' if available, otherwise use |
3266 * 'guifont' | 3260 * 'guifont' |
3267 */ | 3261 */ |
3268 static void | 3262 static void |
3269 update_im_font(void) | 3263 update_im_font(void) |
3270 { | 3264 { |
3271 LOGFONT lf_wide; | 3265 LOGFONTW lf_wide; |
3272 | 3266 |
3273 if (p_guifontwide != NULL && *p_guifontwide != NUL | 3267 if (p_guifontwide != NULL && *p_guifontwide != NUL |
3274 && gui.wide_font != NOFONT | 3268 && gui.wide_font != NOFONT |
3275 && GetObject((HFONT)gui.wide_font, sizeof(lf_wide), &lf_wide)) | 3269 && GetObjectW((HFONT)gui.wide_font, sizeof(lf_wide), &lf_wide)) |
3276 norm_logfont = lf_wide; | 3270 norm_logfont = lf_wide; |
3277 else | 3271 else |
3278 norm_logfont = sub_logfont; | 3272 norm_logfont = sub_logfont; |
3279 im_set_font(&norm_logfont); | 3273 im_set_font(&norm_logfont); |
3280 } | 3274 } |
3284 * Handler of gui.wide_font (p_guifontwide) changed notification. | 3278 * Handler of gui.wide_font (p_guifontwide) changed notification. |
3285 */ | 3279 */ |
3286 void | 3280 void |
3287 gui_mch_wide_font_changed(void) | 3281 gui_mch_wide_font_changed(void) |
3288 { | 3282 { |
3289 LOGFONT lf; | 3283 LOGFONTW lf; |
3290 | 3284 |
3291 #ifdef FEAT_MBYTE_IME | 3285 #ifdef FEAT_MBYTE_IME |
3292 update_im_font(); | 3286 update_im_font(); |
3293 #endif | 3287 #endif |
3294 | 3288 |
3298 gui.wide_bold_font = NOFONT; | 3292 gui.wide_bold_font = NOFONT; |
3299 gui_mch_free_font(gui.wide_boldital_font); | 3293 gui_mch_free_font(gui.wide_boldital_font); |
3300 gui.wide_boldital_font = NOFONT; | 3294 gui.wide_boldital_font = NOFONT; |
3301 | 3295 |
3302 if (gui.wide_font | 3296 if (gui.wide_font |
3303 && GetObject((HFONT)gui.wide_font, sizeof(lf), &lf)) | 3297 && GetObjectW((HFONT)gui.wide_font, sizeof(lf), &lf)) |
3304 { | 3298 { |
3305 if (!lf.lfItalic) | 3299 if (!lf.lfItalic) |
3306 { | 3300 { |
3307 lf.lfItalic = TRUE; | 3301 lf.lfItalic = TRUE; |
3308 gui.wide_ital_font = get_font_handle(&lf); | 3302 gui.wide_ital_font = get_font_handle(&lf); |
3326 * Return FAIL if the font could not be loaded, OK otherwise. | 3320 * Return FAIL if the font could not be loaded, OK otherwise. |
3327 */ | 3321 */ |
3328 int | 3322 int |
3329 gui_mch_init_font(char_u *font_name, int fontset UNUSED) | 3323 gui_mch_init_font(char_u *font_name, int fontset UNUSED) |
3330 { | 3324 { |
3331 LOGFONT lf; | 3325 LOGFONTW lf; |
3332 GuiFont font = NOFONT; | 3326 GuiFont font = NOFONT; |
3333 char_u *p; | 3327 char_u *p; |
3334 | 3328 |
3335 /* Load the font */ | 3329 /* Load the font */ |
3336 if (get_logfont(&lf, font_name, NULL, TRUE) == OK) | 3330 if (get_logfont(&lf, font_name, NULL, TRUE) == OK) |
4223 static HIMC (WINAPI *pImmGetContext)(HWND); | 4217 static HIMC (WINAPI *pImmGetContext)(HWND); |
4224 static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC); | 4218 static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC); |
4225 static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC); | 4219 static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC); |
4226 static BOOL (WINAPI *pImmGetOpenStatus)(HIMC); | 4220 static BOOL (WINAPI *pImmGetOpenStatus)(HIMC); |
4227 static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL); | 4221 static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL); |
4228 static BOOL (WINAPI *pImmGetCompositionFont)(HIMC, LPLOGFONTA); | 4222 static BOOL (WINAPI *pImmGetCompositionFontW)(HIMC, LPLOGFONTW); |
4229 static BOOL (WINAPI *pImmSetCompositionFont)(HIMC, LPLOGFONTA); | 4223 static BOOL (WINAPI *pImmSetCompositionFontW)(HIMC, LPLOGFONTW); |
4230 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM); | 4224 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM); |
4231 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD); | 4225 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD); |
4232 static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD); | 4226 static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD); |
4233 static void dyn_imm_load(void); | 4227 static void dyn_imm_load(void); |
4234 #else | 4228 #else |
4237 # define pImmGetContext ImmGetContext | 4231 # define pImmGetContext ImmGetContext |
4238 # define pImmAssociateContext ImmAssociateContext | 4232 # define pImmAssociateContext ImmAssociateContext |
4239 # define pImmReleaseContext ImmReleaseContext | 4233 # define pImmReleaseContext ImmReleaseContext |
4240 # define pImmGetOpenStatus ImmGetOpenStatus | 4234 # define pImmGetOpenStatus ImmGetOpenStatus |
4241 # define pImmSetOpenStatus ImmSetOpenStatus | 4235 # define pImmSetOpenStatus ImmSetOpenStatus |
4242 # define pImmGetCompositionFont ImmGetCompositionFontA | 4236 # define pImmGetCompositionFontW ImmGetCompositionFontW |
4243 # define pImmSetCompositionFont ImmSetCompositionFontA | 4237 # define pImmSetCompositionFontW ImmSetCompositionFontW |
4244 # define pImmSetCompositionWindow ImmSetCompositionWindow | 4238 # define pImmSetCompositionWindow ImmSetCompositionWindow |
4245 # define pImmGetConversionStatus ImmGetConversionStatus | 4239 # define pImmGetConversionStatus ImmGetConversionStatus |
4246 # define pImmSetConversionStatus ImmSetConversionStatus | 4240 # define pImmSetConversionStatus ImmSetConversionStatus |
4247 #endif | 4241 #endif |
4248 | 4242 |
4377 /* | 4371 /* |
4378 * Get Menu Font. | 4372 * Get Menu Font. |
4379 * Return OK or FAIL. | 4373 * Return OK or FAIL. |
4380 */ | 4374 */ |
4381 static int | 4375 static int |
4382 gui_w32_get_menu_font(LOGFONT *lf) | 4376 gui_w32_get_menu_font(LOGFONTW *lf) |
4383 { | 4377 { |
4384 NONCLIENTMETRICS nm; | 4378 NONCLIENTMETRICSW nm; |
4385 | 4379 |
4386 nm.cbSize = sizeof(NONCLIENTMETRICS); | 4380 nm.cbSize = sizeof(NONCLIENTMETRICSW); |
4387 if (!SystemParametersInfo( | 4381 if (!SystemParametersInfoW( |
4388 SPI_GETNONCLIENTMETRICS, | 4382 SPI_GETNONCLIENTMETRICS, |
4389 sizeof(NONCLIENTMETRICS), | 4383 sizeof(NONCLIENTMETRICSW), |
4390 &nm, | 4384 &nm, |
4391 0)) | 4385 0)) |
4392 return FAIL; | 4386 return FAIL; |
4393 *lf = nm.lfMenuFont; | 4387 *lf = nm.lfMenuFont; |
4394 return OK; | 4388 return OK; |
4401 * Set the GUI tabline font to the system menu font | 4395 * Set the GUI tabline font to the system menu font |
4402 */ | 4396 */ |
4403 static void | 4397 static void |
4404 set_tabline_font(void) | 4398 set_tabline_font(void) |
4405 { | 4399 { |
4406 LOGFONT lfSysmenu; | 4400 LOGFONTW lfSysmenu; |
4407 HFONT font; | 4401 HFONT font; |
4408 HWND hwnd; | 4402 HWND hwnd; |
4409 HDC hdc; | 4403 HDC hdc; |
4410 HFONT hfntOld; | 4404 HFONT hfntOld; |
4411 TEXTMETRIC tm; | 4405 TEXTMETRIC tm; |
4412 | 4406 |
4413 if (gui_w32_get_menu_font(&lfSysmenu) != OK) | 4407 if (gui_w32_get_menu_font(&lfSysmenu) != OK) |
4414 return; | 4408 return; |
4415 | 4409 |
4416 font = CreateFontIndirect(&lfSysmenu); | 4410 font = CreateFontIndirectW(&lfSysmenu); |
4417 | 4411 |
4418 SendMessage(s_tabhwnd, WM_SETFONT, (WPARAM)font, TRUE); | 4412 SendMessage(s_tabhwnd, WM_SETFONT, (WPARAM)font, TRUE); |
4419 | 4413 |
4420 /* | 4414 /* |
4421 * Compute the height of the font used for the tab text | 4415 * Compute the height of the font used for the tab text |
5560 switch (dwCommand) | 5554 switch (dwCommand) |
5561 { | 5555 { |
5562 case IMN_SETOPENSTATUS: | 5556 case IMN_SETOPENSTATUS: |
5563 if (pImmGetOpenStatus(hImc)) | 5557 if (pImmGetOpenStatus(hImc)) |
5564 { | 5558 { |
5565 pImmSetCompositionFont(hImc, &norm_logfont); | 5559 pImmSetCompositionFontW(hImc, &norm_logfont); |
5566 im_set_position(gui.row, gui.col); | 5560 im_set_position(gui.row, gui.col); |
5567 | 5561 |
5568 /* Disable langmap */ | 5562 /* Disable langmap */ |
5569 State &= ~LANGMAP; | 5563 State &= ~LANGMAP; |
5570 if (State & INSERT) | 5564 if (State & INSERT) |
5701 | 5695 |
5702 /* | 5696 /* |
5703 * set font to IM. | 5697 * set font to IM. |
5704 */ | 5698 */ |
5705 void | 5699 void |
5706 im_set_font(LOGFONT *lf) | 5700 im_set_font(LOGFONTW *lf) |
5707 { | 5701 { |
5708 HIMC hImc; | 5702 HIMC hImc; |
5709 | 5703 |
5710 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0) | 5704 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0) |
5711 { | 5705 { |
5712 pImmSetCompositionFont(hImc, lf); | 5706 pImmSetCompositionFontW(hImc, lf); |
5713 pImmReleaseContext(s_hwnd, hImc); | 5707 pImmReleaseContext(s_hwnd, hImc); |
5714 } | 5708 } |
5715 } | 5709 } |
5716 | 5710 |
5717 /* | 5711 /* |
6827 int scroll_flag = 0; | 6821 int scroll_flag = 0; |
6828 int vertical; | 6822 int vertical; |
6829 int dlgPaddingX; | 6823 int dlgPaddingX; |
6830 int dlgPaddingY; | 6824 int dlgPaddingY; |
6831 #ifdef USE_SYSMENU_FONT | 6825 #ifdef USE_SYSMENU_FONT |
6832 LOGFONT lfSysmenu; | 6826 LOGFONTW lfSysmenu; |
6833 int use_lfSysmenu = FALSE; | 6827 int use_lfSysmenu = FALSE; |
6834 #endif | 6828 #endif |
6835 garray_T ga; | 6829 garray_T ga; |
6836 int l; | 6830 int l; |
6837 | 6831 |
6892 hwnd = GetDesktopWindow(); | 6886 hwnd = GetDesktopWindow(); |
6893 hdc = GetWindowDC(hwnd); | 6887 hdc = GetWindowDC(hwnd); |
6894 #ifdef USE_SYSMENU_FONT | 6888 #ifdef USE_SYSMENU_FONT |
6895 if (gui_w32_get_menu_font(&lfSysmenu) == OK) | 6889 if (gui_w32_get_menu_font(&lfSysmenu) == OK) |
6896 { | 6890 { |
6897 font = CreateFontIndirect(&lfSysmenu); | 6891 font = CreateFontIndirectW(&lfSysmenu); |
6898 use_lfSysmenu = TRUE; | 6892 use_lfSysmenu = TRUE; |
6899 } | 6893 } |
6900 else | 6894 else |
6901 #endif | 6895 #endif |
6902 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 6896 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
7121 if (use_lfSysmenu) | 7115 if (use_lfSysmenu) |
7122 { | 7116 { |
7123 /* point size */ | 7117 /* point size */ |
7124 *p++ = -MulDiv(lfSysmenu.lfHeight, 72, | 7118 *p++ = -MulDiv(lfSysmenu.lfHeight, 72, |
7125 GetDeviceCaps(hdc, LOGPIXELSY)); | 7119 GetDeviceCaps(hdc, LOGPIXELSY)); |
7126 nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE); | 7120 wcscpy(p, lfSysmenu.lfFaceName); |
7121 nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1; | |
7127 } | 7122 } |
7128 else | 7123 else |
7129 #endif | 7124 #endif |
7130 { | 7125 { |
7131 *p++ = DLG_FONT_POINT_SIZE; // point size | 7126 *p++ = DLG_FONT_POINT_SIZE; // point size |
7486 HDC hdc; | 7481 HDC hdc; |
7487 HFONT hfontTools = 0; | 7482 HFONT hfontTools = 0; |
7488 DWORD dlgFontSize; | 7483 DWORD dlgFontSize; |
7489 SIZE size; | 7484 SIZE size; |
7490 #ifdef USE_SYSMENU_FONT | 7485 #ifdef USE_SYSMENU_FONT |
7491 LOGFONT lfSysmenu; | 7486 LOGFONTW lfSysmenu; |
7492 #endif | 7487 #endif |
7493 | 7488 |
7494 s_usenewlook = FALSE; | 7489 s_usenewlook = FALSE; |
7495 | 7490 |
7496 #ifdef USE_SYSMENU_FONT | 7491 #ifdef USE_SYSMENU_FONT |
7497 if (gui_w32_get_menu_font(&lfSysmenu) == OK) | 7492 if (gui_w32_get_menu_font(&lfSysmenu) == OK) |
7498 hfontTools = CreateFontIndirect(&lfSysmenu); | 7493 hfontTools = CreateFontIndirectW(&lfSysmenu); |
7499 else | 7494 else |
7500 #endif | 7495 #endif |
7501 hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, | 7496 hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, |
7502 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME); | 7497 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME); |
7503 | 7498 |
7561 int padding0, padding1, padding2 = 0; | 7556 int padding0, padding1, padding2 = 0; |
7562 int sepPadding=0; | 7557 int sepPadding=0; |
7563 int x; | 7558 int x; |
7564 int y; | 7559 int y; |
7565 #ifdef USE_SYSMENU_FONT | 7560 #ifdef USE_SYSMENU_FONT |
7566 LOGFONT lfSysmenu; | 7561 LOGFONTW lfSysmenu; |
7567 int use_lfSysmenu = FALSE; | 7562 int use_lfSysmenu = FALSE; |
7568 #endif | 7563 #endif |
7569 | 7564 |
7570 /* | 7565 /* |
7571 * If this menu is already torn off, move it to the mouse position. | 7566 * If this menu is already torn off, move it to the mouse position. |
7597 hwnd = GetDesktopWindow(); | 7592 hwnd = GetDesktopWindow(); |
7598 hdc = GetWindowDC(hwnd); | 7593 hdc = GetWindowDC(hwnd); |
7599 #ifdef USE_SYSMENU_FONT | 7594 #ifdef USE_SYSMENU_FONT |
7600 if (gui_w32_get_menu_font(&lfSysmenu) == OK) | 7595 if (gui_w32_get_menu_font(&lfSysmenu) == OK) |
7601 { | 7596 { |
7602 font = CreateFontIndirect(&lfSysmenu); | 7597 font = CreateFontIndirectW(&lfSysmenu); |
7603 use_lfSysmenu = TRUE; | 7598 use_lfSysmenu = TRUE; |
7604 } | 7599 } |
7605 else | 7600 else |
7606 #endif | 7601 #endif |
7607 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 7602 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
7706 if (use_lfSysmenu) | 7701 if (use_lfSysmenu) |
7707 { | 7702 { |
7708 /* point size */ | 7703 /* point size */ |
7709 *p++ = -MulDiv(lfSysmenu.lfHeight, 72, | 7704 *p++ = -MulDiv(lfSysmenu.lfHeight, 72, |
7710 GetDeviceCaps(hdc, LOGPIXELSY)); | 7705 GetDeviceCaps(hdc, LOGPIXELSY)); |
7711 nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE); | 7706 wcscpy(p, lfSysmenu.lfFaceName); |
7707 nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1; | |
7712 } | 7708 } |
7713 else | 7709 else |
7714 #endif | 7710 #endif |
7715 { | 7711 { |
7716 *p++ = DLG_FONT_POINT_SIZE; // point size | 7712 *p++ = DLG_FONT_POINT_SIZE; // point size |
8134 = (void *)GetProcAddress(hLibImm, "ImmReleaseContext"); | 8130 = (void *)GetProcAddress(hLibImm, "ImmReleaseContext"); |
8135 pImmGetOpenStatus | 8131 pImmGetOpenStatus |
8136 = (void *)GetProcAddress(hLibImm, "ImmGetOpenStatus"); | 8132 = (void *)GetProcAddress(hLibImm, "ImmGetOpenStatus"); |
8137 pImmSetOpenStatus | 8133 pImmSetOpenStatus |
8138 = (void *)GetProcAddress(hLibImm, "ImmSetOpenStatus"); | 8134 = (void *)GetProcAddress(hLibImm, "ImmSetOpenStatus"); |
8139 pImmGetCompositionFont | 8135 pImmGetCompositionFontW |
8140 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionFontA"); | 8136 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionFontW"); |
8141 pImmSetCompositionFont | 8137 pImmSetCompositionFontW |
8142 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontA"); | 8138 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontW"); |
8143 pImmSetCompositionWindow | 8139 pImmSetCompositionWindow |
8144 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow"); | 8140 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow"); |
8145 pImmGetConversionStatus | 8141 pImmGetConversionStatus |
8146 = (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus"); | 8142 = (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus"); |
8147 pImmSetConversionStatus | 8143 pImmSetConversionStatus |
8152 || pImmGetContext == NULL | 8148 || pImmGetContext == NULL |
8153 || pImmAssociateContext == NULL | 8149 || pImmAssociateContext == NULL |
8154 || pImmReleaseContext == NULL | 8150 || pImmReleaseContext == NULL |
8155 || pImmGetOpenStatus == NULL | 8151 || pImmGetOpenStatus == NULL |
8156 || pImmSetOpenStatus == NULL | 8152 || pImmSetOpenStatus == NULL |
8157 || pImmGetCompositionFont == NULL | 8153 || pImmGetCompositionFontW == NULL |
8158 || pImmSetCompositionFont == NULL | 8154 || pImmSetCompositionFontW == NULL |
8159 || pImmSetCompositionWindow == NULL | 8155 || pImmSetCompositionWindow == NULL |
8160 || pImmGetConversionStatus == NULL | 8156 || pImmGetConversionStatus == NULL |
8161 || pImmSetConversionStatus == NULL) | 8157 || pImmSetConversionStatus == NULL) |
8162 { | 8158 { |
8163 FreeLibrary(hLibImm); | 8159 FreeLibrary(hLibImm); |