@@ -253,7 +253,7 @@ typedef int HBITMAP;
253253typedef int HBRUSH ;
254254typedef int HDROP ;
255255typedef int INT ;
256- typedef int LOGFONT [];
256+ typedef int LOGFONTW [];
257257typedef int LPARAM ;
258258typedef int LPCREATESTRUCT ;
259259typedef int LPCSTR ;
@@ -501,15 +501,15 @@ static void TrackUserActivity(UINT uMsg);
501501/*
502502 * For control IME.
503503 *
504- * These LOGFONT used for IME.
504+ * These LOGFONTW used for IME.
505505 */
506506#if defined(FEAT_MBYTE_IME ) || defined(GLOBAL_IME )
507- /* holds LOGFONT for 'guifontwide' if available, otherwise 'guifont' */
508- static LOGFONT norm_logfont ;
507+ /* holds LOGFONTW for 'guifontwide' if available, otherwise 'guifont' */
508+ static LOGFONTW norm_logfont ;
509509#endif
510510#ifdef FEAT_MBYTE_IME
511- /* holds LOGFONT for 'guifont' always. */
512- static LOGFONT sub_logfont ;
511+ /* holds LOGFONTW for 'guifont' always. */
512+ static LOGFONTW sub_logfont ;
513513#endif
514514
515515#ifdef FEAT_MBYTE_IME
@@ -1520,12 +1520,12 @@ gui_mch_adjust_charheight(void)
15201520}
15211521
15221522 static GuiFont
1523- get_font_handle (LOGFONT * lf )
1523+ get_font_handle (LOGFONTW * lf )
15241524{
15251525 HFONT font = NULL ;
15261526
15271527 /* Load the font */
1528- font = CreateFontIndirect (lf );
1528+ font = CreateFontIndirectW (lf );
15291529
15301530 if (font == NULL )
15311531 return NOFONT ;
@@ -1556,7 +1556,7 @@ gui_mch_get_font(
15561556 char_u * name ,
15571557 int giveErrorIfMissing )
15581558{
1559- LOGFONT lf ;
1559+ LOGFONTW lf ;
15601560 GuiFont font = NOFONT ;
15611561
15621562 if (get_logfont (& lf , name , NULL , giveErrorIfMissing ) == OK )
@@ -3201,23 +3201,18 @@ gui_mch_exit(int rc UNUSED)
32013201}
32023202
32033203 static char_u *
3204- logfont2name (LOGFONT lf )
3204+ logfont2name (LOGFONTW lf )
32053205{
32063206 char * p ;
32073207 char * res ;
32083208 char * charset_name ;
32093209 char * quality_name ;
3210- char * font_name = lf . lfFaceName ;
3210+ char * font_name ;
32113211
3212+ font_name = (char * )utf16_to_enc (lf .lfFaceName , NULL );
3213+ if (font_name == NULL )
3214+ return NULL ;
32123215 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- }
32213216 quality_name = quality_id2name ((int )lf .lfQuality );
32223217
32233218 res = (char * )alloc ((unsigned )(strlen (font_name ) + 20
@@ -3254,25 +3249,24 @@ logfont2name(LOGFONT lf)
32543249 }
32553250 }
32563251
3257- if (font_name != lf .lfFaceName )
3258- vim_free (font_name );
3252+ vim_free (font_name );
32593253 return (char_u * )res ;
32603254}
32613255
32623256
32633257#ifdef FEAT_MBYTE_IME
32643258/*
3265- * Set correct LOGFONT to IME. Use 'guifontwide' if available, otherwise use
3259+ * Set correct LOGFONTW to IME. Use 'guifontwide' if available, otherwise use
32663260 * 'guifont'
32673261 */
32683262 static void
32693263update_im_font (void )
32703264{
3271- LOGFONT lf_wide ;
3265+ LOGFONTW lf_wide ;
32723266
32733267 if (p_guifontwide != NULL && * p_guifontwide != NUL
32743268 && 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 ))
32763270 norm_logfont = lf_wide ;
32773271 else
32783272 norm_logfont = sub_logfont ;
@@ -3286,7 +3280,7 @@ update_im_font(void)
32863280 void
32873281gui_mch_wide_font_changed (void )
32883282{
3289- LOGFONT lf ;
3283+ LOGFONTW lf ;
32903284
32913285#ifdef FEAT_MBYTE_IME
32923286 update_im_font ();
@@ -3300,7 +3294,7 @@ gui_mch_wide_font_changed(void)
33003294 gui .wide_boldital_font = NOFONT ;
33013295
33023296 if (gui .wide_font
3303- && GetObject ((HFONT )gui .wide_font , sizeof (lf ), & lf ))
3297+ && GetObjectW ((HFONT )gui .wide_font , sizeof (lf ), & lf ))
33043298 {
33053299 if (!lf .lfItalic )
33063300 {
@@ -3328,7 +3322,7 @@ gui_mch_wide_font_changed(void)
33283322 int
33293323gui_mch_init_font (char_u * font_name , int fontset UNUSED )
33303324{
3331- LOGFONT lf ;
3325+ LOGFONTW lf ;
33323326 GuiFont font = NOFONT ;
33333327 char_u * p ;
33343328
@@ -4225,8 +4219,8 @@ static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC);
42254219static BOOL (WINAPI * pImmReleaseContext )(HWND , HIMC );
42264220static BOOL (WINAPI * pImmGetOpenStatus )(HIMC );
42274221static BOOL (WINAPI * pImmSetOpenStatus )(HIMC , BOOL );
4228- static BOOL (WINAPI * pImmGetCompositionFont )(HIMC , LPLOGFONTA );
4229- static BOOL (WINAPI * pImmSetCompositionFont )(HIMC , LPLOGFONTA );
4222+ static BOOL (WINAPI * pImmGetCompositionFontW )(HIMC , LPLOGFONTW );
4223+ static BOOL (WINAPI * pImmSetCompositionFontW )(HIMC , LPLOGFONTW );
42304224static BOOL (WINAPI * pImmSetCompositionWindow )(HIMC , LPCOMPOSITIONFORM );
42314225static BOOL (WINAPI * pImmGetConversionStatus )(HIMC , LPDWORD , LPDWORD );
42324226static BOOL (WINAPI * pImmSetConversionStatus )(HIMC , DWORD , DWORD );
@@ -4239,8 +4233,8 @@ static void dyn_imm_load(void);
42394233# define pImmReleaseContext ImmReleaseContext
42404234# define pImmGetOpenStatus ImmGetOpenStatus
42414235# define pImmSetOpenStatus ImmSetOpenStatus
4242- # define pImmGetCompositionFont ImmGetCompositionFontA
4243- # define pImmSetCompositionFont ImmSetCompositionFontA
4236+ # define pImmGetCompositionFontW ImmGetCompositionFontW
4237+ # define pImmSetCompositionFontW ImmSetCompositionFontW
42444238# define pImmSetCompositionWindow ImmSetCompositionWindow
42454239# define pImmGetConversionStatus ImmGetConversionStatus
42464240# define pImmSetConversionStatus ImmSetConversionStatus
@@ -4379,14 +4373,14 @@ _OnMouseWheel(
43794373 * Return OK or FAIL.
43804374 */
43814375 static int
4382- gui_w32_get_menu_font (LOGFONT * lf )
4376+ gui_w32_get_menu_font (LOGFONTW * lf )
43834377{
4384- NONCLIENTMETRICS nm ;
4378+ NONCLIENTMETRICSW nm ;
43854379
4386- nm .cbSize = sizeof (NONCLIENTMETRICS );
4387- if (!SystemParametersInfo (
4380+ nm .cbSize = sizeof (NONCLIENTMETRICSW );
4381+ if (!SystemParametersInfoW (
43884382 SPI_GETNONCLIENTMETRICS ,
4389- sizeof (NONCLIENTMETRICS ),
4383+ sizeof (NONCLIENTMETRICSW ),
43904384 & nm ,
43914385 0 ))
43924386 return FAIL ;
@@ -4403,7 +4397,7 @@ gui_w32_get_menu_font(LOGFONT *lf)
44034397 static void
44044398set_tabline_font (void )
44054399{
4406- LOGFONT lfSysmenu ;
4400+ LOGFONTW lfSysmenu ;
44074401 HFONT font ;
44084402 HWND hwnd ;
44094403 HDC hdc ;
@@ -4413,7 +4407,7 @@ set_tabline_font(void)
44134407 if (gui_w32_get_menu_font (& lfSysmenu ) != OK )
44144408 return ;
44154409
4416- font = CreateFontIndirect (& lfSysmenu );
4410+ font = CreateFontIndirectW (& lfSysmenu );
44174411
44184412 SendMessage (s_tabhwnd , WM_SETFONT , (WPARAM )font , TRUE);
44194413
@@ -5562,7 +5556,7 @@ _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData UNUSED)
55625556 case IMN_SETOPENSTATUS :
55635557 if (pImmGetOpenStatus (hImc ))
55645558 {
5565- pImmSetCompositionFont (hImc , & norm_logfont );
5559+ pImmSetCompositionFontW (hImc , & norm_logfont );
55665560 im_set_position (gui .row , gui .col );
55675561
55685562 /* Disable langmap */
@@ -5703,13 +5697,13 @@ GetResultStr(HWND hwnd, int GCS, int *lenp)
57035697 * set font to IM.
57045698 */
57055699 void
5706- im_set_font (LOGFONT * lf )
5700+ im_set_font (LOGFONTW * lf )
57075701{
57085702 HIMC hImc ;
57095703
57105704 if (pImmGetContext && (hImc = pImmGetContext (s_hwnd )) != (HIMC )0 )
57115705 {
5712- pImmSetCompositionFont (hImc , lf );
5706+ pImmSetCompositionFontW (hImc , lf );
57135707 pImmReleaseContext (s_hwnd , hImc );
57145708 }
57155709}
@@ -6829,7 +6823,7 @@ gui_mch_dialog(
68296823 int dlgPaddingX ;
68306824 int dlgPaddingY ;
68316825#ifdef USE_SYSMENU_FONT
6832- LOGFONT lfSysmenu ;
6826+ LOGFONTW lfSysmenu ;
68336827 int use_lfSysmenu = FALSE;
68346828#endif
68356829 garray_T ga ;
@@ -6894,7 +6888,7 @@ gui_mch_dialog(
68946888#ifdef USE_SYSMENU_FONT
68956889 if (gui_w32_get_menu_font (& lfSysmenu ) == OK )
68966890 {
6897- font = CreateFontIndirect (& lfSysmenu );
6891+ font = CreateFontIndirectW (& lfSysmenu );
68986892 use_lfSysmenu = TRUE;
68996893 }
69006894 else
@@ -7123,7 +7117,8 @@ gui_mch_dialog(
71237117 /* point size */
71247118 * p ++ = - MulDiv (lfSysmenu .lfHeight , 72 ,
71257119 GetDeviceCaps (hdc , LOGPIXELSY ));
7126- nchar = nCopyAnsiToWideChar (p , lfSysmenu .lfFaceName , FALSE);
7120+ wcscpy (p , lfSysmenu .lfFaceName );
7121+ nchar = (int )wcslen (lfSysmenu .lfFaceName ) + 1 ;
71277122 }
71287123 else
71297124#endif
@@ -7488,14 +7483,14 @@ get_dialog_font_metrics(void)
74887483 DWORD dlgFontSize ;
74897484 SIZE size ;
74907485#ifdef USE_SYSMENU_FONT
7491- LOGFONT lfSysmenu ;
7486+ LOGFONTW lfSysmenu ;
74927487#endif
74937488
74947489 s_usenewlook = FALSE;
74957490
74967491#ifdef USE_SYSMENU_FONT
74977492 if (gui_w32_get_menu_font (& lfSysmenu ) == OK )
7498- hfontTools = CreateFontIndirect (& lfSysmenu );
7493+ hfontTools = CreateFontIndirectW (& lfSysmenu );
74997494 else
75007495#endif
75017496 hfontTools = CreateFont (- DLG_FONT_POINT_SIZE , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
@@ -7563,7 +7558,7 @@ gui_mch_tearoff(
75637558 int x ;
75647559 int y ;
75657560#ifdef USE_SYSMENU_FONT
7566- LOGFONT lfSysmenu ;
7561+ LOGFONTW lfSysmenu ;
75677562 int use_lfSysmenu = FALSE;
75687563#endif
75697564
@@ -7599,7 +7594,7 @@ gui_mch_tearoff(
75997594#ifdef USE_SYSMENU_FONT
76007595 if (gui_w32_get_menu_font (& lfSysmenu ) == OK )
76017596 {
7602- font = CreateFontIndirect (& lfSysmenu );
7597+ font = CreateFontIndirectW (& lfSysmenu );
76037598 use_lfSysmenu = TRUE;
76047599 }
76057600 else
@@ -7708,7 +7703,8 @@ gui_mch_tearoff(
77087703 /* point size */
77097704 * p ++ = - MulDiv (lfSysmenu .lfHeight , 72 ,
77107705 GetDeviceCaps (hdc , LOGPIXELSY ));
7711- nchar = nCopyAnsiToWideChar (p , lfSysmenu .lfFaceName , FALSE);
7706+ wcscpy (p , lfSysmenu .lfFaceName );
7707+ nchar = (int )wcslen (lfSysmenu .lfFaceName ) + 1 ;
77127708 }
77137709 else
77147710#endif
@@ -8136,10 +8132,10 @@ dyn_imm_load(void)
81368132 = (void * )GetProcAddress (hLibImm , "ImmGetOpenStatus" );
81378133 pImmSetOpenStatus
81388134 = (void * )GetProcAddress (hLibImm , "ImmSetOpenStatus" );
8139- pImmGetCompositionFont
8140- = (void * )GetProcAddress (hLibImm , "ImmGetCompositionFontA " );
8141- pImmSetCompositionFont
8142- = (void * )GetProcAddress (hLibImm , "ImmSetCompositionFontA " );
8135+ pImmGetCompositionFontW
8136+ = (void * )GetProcAddress (hLibImm , "ImmGetCompositionFontW " );
8137+ pImmSetCompositionFontW
8138+ = (void * )GetProcAddress (hLibImm , "ImmSetCompositionFontW " );
81438139 pImmSetCompositionWindow
81448140 = (void * )GetProcAddress (hLibImm , "ImmSetCompositionWindow" );
81458141 pImmGetConversionStatus
@@ -8154,8 +8150,8 @@ dyn_imm_load(void)
81548150 || pImmReleaseContext == NULL
81558151 || pImmGetOpenStatus == NULL
81568152 || pImmSetOpenStatus == NULL
8157- || pImmGetCompositionFont == NULL
8158- || pImmSetCompositionFont == NULL
8153+ || pImmGetCompositionFontW == NULL
8154+ || pImmSetCompositionFontW == NULL
81598155 || pImmSetCompositionWindow == NULL
81608156 || pImmGetConversionStatus == NULL
81618157 || pImmSetConversionStatus == NULL )
0 commit comments