mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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)
This commit is contained in:
106
src/gui_w32.c
106
src/gui_w32.c
@@ -253,7 +253,7 @@ typedef int HBITMAP;
|
|||||||
typedef int HBRUSH;
|
typedef int HBRUSH;
|
||||||
typedef int HDROP;
|
typedef int HDROP;
|
||||||
typedef int INT;
|
typedef int INT;
|
||||||
typedef int LOGFONT[];
|
typedef int LOGFONTW[];
|
||||||
typedef int LPARAM;
|
typedef int LPARAM;
|
||||||
typedef int LPCREATESTRUCT;
|
typedef int LPCREATESTRUCT;
|
||||||
typedef int LPCSTR;
|
typedef int LPCSTR;
|
||||||
@@ -501,15 +501,15 @@ static void TrackUserActivity(UINT uMsg);
|
|||||||
/*
|
/*
|
||||||
* For control IME.
|
* For control IME.
|
||||||
*
|
*
|
||||||
* These LOGFONT used for IME.
|
* These LOGFONTW used for IME.
|
||||||
*/
|
*/
|
||||||
#if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
|
#if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
|
||||||
/* holds LOGFONT for 'guifontwide' if available, otherwise 'guifont' */
|
/* holds LOGFONTW for 'guifontwide' if available, otherwise 'guifont' */
|
||||||
static LOGFONT norm_logfont;
|
static LOGFONTW norm_logfont;
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_MBYTE_IME
|
#ifdef FEAT_MBYTE_IME
|
||||||
/* holds LOGFONT for 'guifont' always. */
|
/* holds LOGFONTW for 'guifont' always. */
|
||||||
static LOGFONT sub_logfont;
|
static LOGFONTW sub_logfont;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_MBYTE_IME
|
#ifdef FEAT_MBYTE_IME
|
||||||
@@ -1520,12 +1520,12 @@ gui_mch_adjust_charheight(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GuiFont
|
static GuiFont
|
||||||
get_font_handle(LOGFONT *lf)
|
get_font_handle(LOGFONTW *lf)
|
||||||
{
|
{
|
||||||
HFONT font = NULL;
|
HFONT font = NULL;
|
||||||
|
|
||||||
/* Load the font */
|
/* Load the font */
|
||||||
font = CreateFontIndirect(lf);
|
font = CreateFontIndirectW(lf);
|
||||||
|
|
||||||
if (font == NULL)
|
if (font == NULL)
|
||||||
return NOFONT;
|
return NOFONT;
|
||||||
@@ -1556,7 +1556,7 @@ gui_mch_get_font(
|
|||||||
char_u *name,
|
char_u *name,
|
||||||
int giveErrorIfMissing)
|
int giveErrorIfMissing)
|
||||||
{
|
{
|
||||||
LOGFONT lf;
|
LOGFONTW lf;
|
||||||
GuiFont font = NOFONT;
|
GuiFont font = NOFONT;
|
||||||
|
|
||||||
if (get_logfont(&lf, name, NULL, giveErrorIfMissing) == OK)
|
if (get_logfont(&lf, name, NULL, giveErrorIfMissing) == OK)
|
||||||
@@ -3201,23 +3201,18 @@ gui_mch_exit(int rc UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char_u *
|
static char_u *
|
||||||
logfont2name(LOGFONT lf)
|
logfont2name(LOGFONTW lf)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char *res;
|
char *res;
|
||||||
char *charset_name;
|
char *charset_name;
|
||||||
char *quality_name;
|
char *quality_name;
|
||||||
char *font_name = lf.lfFaceName;
|
char *font_name;
|
||||||
|
|
||||||
|
font_name = (char *)utf16_to_enc(lf.lfFaceName, NULL);
|
||||||
|
if (font_name == NULL)
|
||||||
|
return NULL;
|
||||||
charset_name = charset_id2name((int)lf.lfCharSet);
|
charset_name = charset_id2name((int)lf.lfCharSet);
|
||||||
/* Convert a font name from the current codepage to 'encoding'.
|
|
||||||
* TODO: Use Wide APIs (including LOGFONTW) instead of ANSI APIs. */
|
|
||||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
acp_to_enc((char_u *)lf.lfFaceName, (int)strlen(lf.lfFaceName),
|
|
||||||
(char_u **)&font_name, &len);
|
|
||||||
}
|
|
||||||
quality_name = quality_id2name((int)lf.lfQuality);
|
quality_name = quality_id2name((int)lf.lfQuality);
|
||||||
|
|
||||||
res = (char *)alloc((unsigned)(strlen(font_name) + 20
|
res = (char *)alloc((unsigned)(strlen(font_name) + 20
|
||||||
@@ -3254,25 +3249,24 @@ logfont2name(LOGFONT lf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font_name != lf.lfFaceName)
|
vim_free(font_name);
|
||||||
vim_free(font_name);
|
|
||||||
return (char_u *)res;
|
return (char_u *)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef FEAT_MBYTE_IME
|
#ifdef FEAT_MBYTE_IME
|
||||||
/*
|
/*
|
||||||
* Set correct LOGFONT to IME. Use 'guifontwide' if available, otherwise use
|
* Set correct LOGFONTW to IME. Use 'guifontwide' if available, otherwise use
|
||||||
* 'guifont'
|
* 'guifont'
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
update_im_font(void)
|
update_im_font(void)
|
||||||
{
|
{
|
||||||
LOGFONT lf_wide;
|
LOGFONTW lf_wide;
|
||||||
|
|
||||||
if (p_guifontwide != NULL && *p_guifontwide != NUL
|
if (p_guifontwide != NULL && *p_guifontwide != NUL
|
||||||
&& gui.wide_font != NOFONT
|
&& gui.wide_font != NOFONT
|
||||||
&& GetObject((HFONT)gui.wide_font, sizeof(lf_wide), &lf_wide))
|
&& GetObjectW((HFONT)gui.wide_font, sizeof(lf_wide), &lf_wide))
|
||||||
norm_logfont = lf_wide;
|
norm_logfont = lf_wide;
|
||||||
else
|
else
|
||||||
norm_logfont = sub_logfont;
|
norm_logfont = sub_logfont;
|
||||||
@@ -3286,7 +3280,7 @@ update_im_font(void)
|
|||||||
void
|
void
|
||||||
gui_mch_wide_font_changed(void)
|
gui_mch_wide_font_changed(void)
|
||||||
{
|
{
|
||||||
LOGFONT lf;
|
LOGFONTW lf;
|
||||||
|
|
||||||
#ifdef FEAT_MBYTE_IME
|
#ifdef FEAT_MBYTE_IME
|
||||||
update_im_font();
|
update_im_font();
|
||||||
@@ -3300,7 +3294,7 @@ gui_mch_wide_font_changed(void)
|
|||||||
gui.wide_boldital_font = NOFONT;
|
gui.wide_boldital_font = NOFONT;
|
||||||
|
|
||||||
if (gui.wide_font
|
if (gui.wide_font
|
||||||
&& GetObject((HFONT)gui.wide_font, sizeof(lf), &lf))
|
&& GetObjectW((HFONT)gui.wide_font, sizeof(lf), &lf))
|
||||||
{
|
{
|
||||||
if (!lf.lfItalic)
|
if (!lf.lfItalic)
|
||||||
{
|
{
|
||||||
@@ -3328,7 +3322,7 @@ gui_mch_wide_font_changed(void)
|
|||||||
int
|
int
|
||||||
gui_mch_init_font(char_u *font_name, int fontset UNUSED)
|
gui_mch_init_font(char_u *font_name, int fontset UNUSED)
|
||||||
{
|
{
|
||||||
LOGFONT lf;
|
LOGFONTW lf;
|
||||||
GuiFont font = NOFONT;
|
GuiFont font = NOFONT;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
@@ -4225,8 +4219,8 @@ static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC);
|
|||||||
static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC);
|
static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC);
|
||||||
static BOOL (WINAPI *pImmGetOpenStatus)(HIMC);
|
static BOOL (WINAPI *pImmGetOpenStatus)(HIMC);
|
||||||
static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL);
|
static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL);
|
||||||
static BOOL (WINAPI *pImmGetCompositionFont)(HIMC, LPLOGFONTA);
|
static BOOL (WINAPI *pImmGetCompositionFontW)(HIMC, LPLOGFONTW);
|
||||||
static BOOL (WINAPI *pImmSetCompositionFont)(HIMC, LPLOGFONTA);
|
static BOOL (WINAPI *pImmSetCompositionFontW)(HIMC, LPLOGFONTW);
|
||||||
static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
|
static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
|
||||||
static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
|
static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
|
||||||
static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD);
|
static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD);
|
||||||
@@ -4239,8 +4233,8 @@ static void dyn_imm_load(void);
|
|||||||
# define pImmReleaseContext ImmReleaseContext
|
# define pImmReleaseContext ImmReleaseContext
|
||||||
# define pImmGetOpenStatus ImmGetOpenStatus
|
# define pImmGetOpenStatus ImmGetOpenStatus
|
||||||
# define pImmSetOpenStatus ImmSetOpenStatus
|
# define pImmSetOpenStatus ImmSetOpenStatus
|
||||||
# define pImmGetCompositionFont ImmGetCompositionFontA
|
# define pImmGetCompositionFontW ImmGetCompositionFontW
|
||||||
# define pImmSetCompositionFont ImmSetCompositionFontA
|
# define pImmSetCompositionFontW ImmSetCompositionFontW
|
||||||
# define pImmSetCompositionWindow ImmSetCompositionWindow
|
# define pImmSetCompositionWindow ImmSetCompositionWindow
|
||||||
# define pImmGetConversionStatus ImmGetConversionStatus
|
# define pImmGetConversionStatus ImmGetConversionStatus
|
||||||
# define pImmSetConversionStatus ImmSetConversionStatus
|
# define pImmSetConversionStatus ImmSetConversionStatus
|
||||||
@@ -4379,14 +4373,14 @@ _OnMouseWheel(
|
|||||||
* Return OK or FAIL.
|
* Return OK or FAIL.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
gui_w32_get_menu_font(LOGFONT *lf)
|
gui_w32_get_menu_font(LOGFONTW *lf)
|
||||||
{
|
{
|
||||||
NONCLIENTMETRICS nm;
|
NONCLIENTMETRICSW nm;
|
||||||
|
|
||||||
nm.cbSize = sizeof(NONCLIENTMETRICS);
|
nm.cbSize = sizeof(NONCLIENTMETRICSW);
|
||||||
if (!SystemParametersInfo(
|
if (!SystemParametersInfoW(
|
||||||
SPI_GETNONCLIENTMETRICS,
|
SPI_GETNONCLIENTMETRICS,
|
||||||
sizeof(NONCLIENTMETRICS),
|
sizeof(NONCLIENTMETRICSW),
|
||||||
&nm,
|
&nm,
|
||||||
0))
|
0))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -4403,7 +4397,7 @@ gui_w32_get_menu_font(LOGFONT *lf)
|
|||||||
static void
|
static void
|
||||||
set_tabline_font(void)
|
set_tabline_font(void)
|
||||||
{
|
{
|
||||||
LOGFONT lfSysmenu;
|
LOGFONTW lfSysmenu;
|
||||||
HFONT font;
|
HFONT font;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
@@ -4413,7 +4407,7 @@ set_tabline_font(void)
|
|||||||
if (gui_w32_get_menu_font(&lfSysmenu) != OK)
|
if (gui_w32_get_menu_font(&lfSysmenu) != OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
font = CreateFontIndirect(&lfSysmenu);
|
font = CreateFontIndirectW(&lfSysmenu);
|
||||||
|
|
||||||
SendMessage(s_tabhwnd, WM_SETFONT, (WPARAM)font, TRUE);
|
SendMessage(s_tabhwnd, WM_SETFONT, (WPARAM)font, TRUE);
|
||||||
|
|
||||||
@@ -5562,7 +5556,7 @@ _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData UNUSED)
|
|||||||
case IMN_SETOPENSTATUS:
|
case IMN_SETOPENSTATUS:
|
||||||
if (pImmGetOpenStatus(hImc))
|
if (pImmGetOpenStatus(hImc))
|
||||||
{
|
{
|
||||||
pImmSetCompositionFont(hImc, &norm_logfont);
|
pImmSetCompositionFontW(hImc, &norm_logfont);
|
||||||
im_set_position(gui.row, gui.col);
|
im_set_position(gui.row, gui.col);
|
||||||
|
|
||||||
/* Disable langmap */
|
/* Disable langmap */
|
||||||
@@ -5703,13 +5697,13 @@ GetResultStr(HWND hwnd, int GCS, int *lenp)
|
|||||||
* set font to IM.
|
* set font to IM.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
im_set_font(LOGFONT *lf)
|
im_set_font(LOGFONTW *lf)
|
||||||
{
|
{
|
||||||
HIMC hImc;
|
HIMC hImc;
|
||||||
|
|
||||||
if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
|
if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
|
||||||
{
|
{
|
||||||
pImmSetCompositionFont(hImc, lf);
|
pImmSetCompositionFontW(hImc, lf);
|
||||||
pImmReleaseContext(s_hwnd, hImc);
|
pImmReleaseContext(s_hwnd, hImc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6829,7 +6823,7 @@ gui_mch_dialog(
|
|||||||
int dlgPaddingX;
|
int dlgPaddingX;
|
||||||
int dlgPaddingY;
|
int dlgPaddingY;
|
||||||
#ifdef USE_SYSMENU_FONT
|
#ifdef USE_SYSMENU_FONT
|
||||||
LOGFONT lfSysmenu;
|
LOGFONTW lfSysmenu;
|
||||||
int use_lfSysmenu = FALSE;
|
int use_lfSysmenu = FALSE;
|
||||||
#endif
|
#endif
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
@@ -6894,7 +6888,7 @@ gui_mch_dialog(
|
|||||||
#ifdef USE_SYSMENU_FONT
|
#ifdef USE_SYSMENU_FONT
|
||||||
if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
||||||
{
|
{
|
||||||
font = CreateFontIndirect(&lfSysmenu);
|
font = CreateFontIndirectW(&lfSysmenu);
|
||||||
use_lfSysmenu = TRUE;
|
use_lfSysmenu = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -7123,7 +7117,8 @@ gui_mch_dialog(
|
|||||||
/* point size */
|
/* point size */
|
||||||
*p++ = -MulDiv(lfSysmenu.lfHeight, 72,
|
*p++ = -MulDiv(lfSysmenu.lfHeight, 72,
|
||||||
GetDeviceCaps(hdc, LOGPIXELSY));
|
GetDeviceCaps(hdc, LOGPIXELSY));
|
||||||
nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE);
|
wcscpy(p, lfSysmenu.lfFaceName);
|
||||||
|
nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -7488,14 +7483,14 @@ get_dialog_font_metrics(void)
|
|||||||
DWORD dlgFontSize;
|
DWORD dlgFontSize;
|
||||||
SIZE size;
|
SIZE size;
|
||||||
#ifdef USE_SYSMENU_FONT
|
#ifdef USE_SYSMENU_FONT
|
||||||
LOGFONT lfSysmenu;
|
LOGFONTW lfSysmenu;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_usenewlook = FALSE;
|
s_usenewlook = FALSE;
|
||||||
|
|
||||||
#ifdef USE_SYSMENU_FONT
|
#ifdef USE_SYSMENU_FONT
|
||||||
if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
||||||
hfontTools = CreateFontIndirect(&lfSysmenu);
|
hfontTools = CreateFontIndirectW(&lfSysmenu);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
|
hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
|
||||||
@@ -7563,7 +7558,7 @@ gui_mch_tearoff(
|
|||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
#ifdef USE_SYSMENU_FONT
|
#ifdef USE_SYSMENU_FONT
|
||||||
LOGFONT lfSysmenu;
|
LOGFONTW lfSysmenu;
|
||||||
int use_lfSysmenu = FALSE;
|
int use_lfSysmenu = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -7599,7 +7594,7 @@ gui_mch_tearoff(
|
|||||||
#ifdef USE_SYSMENU_FONT
|
#ifdef USE_SYSMENU_FONT
|
||||||
if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
||||||
{
|
{
|
||||||
font = CreateFontIndirect(&lfSysmenu);
|
font = CreateFontIndirectW(&lfSysmenu);
|
||||||
use_lfSysmenu = TRUE;
|
use_lfSysmenu = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -7708,7 +7703,8 @@ gui_mch_tearoff(
|
|||||||
/* point size */
|
/* point size */
|
||||||
*p++ = -MulDiv(lfSysmenu.lfHeight, 72,
|
*p++ = -MulDiv(lfSysmenu.lfHeight, 72,
|
||||||
GetDeviceCaps(hdc, LOGPIXELSY));
|
GetDeviceCaps(hdc, LOGPIXELSY));
|
||||||
nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE);
|
wcscpy(p, lfSysmenu.lfFaceName);
|
||||||
|
nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -8136,10 +8132,10 @@ dyn_imm_load(void)
|
|||||||
= (void *)GetProcAddress(hLibImm, "ImmGetOpenStatus");
|
= (void *)GetProcAddress(hLibImm, "ImmGetOpenStatus");
|
||||||
pImmSetOpenStatus
|
pImmSetOpenStatus
|
||||||
= (void *)GetProcAddress(hLibImm, "ImmSetOpenStatus");
|
= (void *)GetProcAddress(hLibImm, "ImmSetOpenStatus");
|
||||||
pImmGetCompositionFont
|
pImmGetCompositionFontW
|
||||||
= (void *)GetProcAddress(hLibImm, "ImmGetCompositionFontA");
|
= (void *)GetProcAddress(hLibImm, "ImmGetCompositionFontW");
|
||||||
pImmSetCompositionFont
|
pImmSetCompositionFontW
|
||||||
= (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontA");
|
= (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontW");
|
||||||
pImmSetCompositionWindow
|
pImmSetCompositionWindow
|
||||||
= (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow");
|
= (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow");
|
||||||
pImmGetConversionStatus
|
pImmGetConversionStatus
|
||||||
@@ -8154,8 +8150,8 @@ dyn_imm_load(void)
|
|||||||
|| pImmReleaseContext == NULL
|
|| pImmReleaseContext == NULL
|
||||||
|| pImmGetOpenStatus == NULL
|
|| pImmGetOpenStatus == NULL
|
||||||
|| pImmSetOpenStatus == NULL
|
|| pImmSetOpenStatus == NULL
|
||||||
|| pImmGetCompositionFont == NULL
|
|| pImmGetCompositionFontW == NULL
|
||||||
|| pImmSetCompositionFont == NULL
|
|| pImmSetCompositionFontW == NULL
|
||||||
|| pImmSetCompositionWindow == NULL
|
|| pImmSetCompositionWindow == NULL
|
||||||
|| pImmGetConversionStatus == NULL
|
|| pImmGetConversionStatus == NULL
|
||||||
|| pImmSetConversionStatus == NULL)
|
|| pImmSetConversionStatus == NULL)
|
||||||
|
140
src/os_mswin.c
140
src/os_mswin.c
@@ -85,7 +85,7 @@ typedef int COLORREF;
|
|||||||
typedef int CONSOLE_CURSOR_INFO;
|
typedef int CONSOLE_CURSOR_INFO;
|
||||||
typedef int COORD;
|
typedef int COORD;
|
||||||
typedef int DWORD;
|
typedef int DWORD;
|
||||||
typedef int ENUMLOGFONT;
|
typedef int ENUMLOGFONTW;
|
||||||
typedef int HANDLE;
|
typedef int HANDLE;
|
||||||
typedef int HDC;
|
typedef int HDC;
|
||||||
typedef int HFONT;
|
typedef int HFONT;
|
||||||
@@ -93,7 +93,7 @@ typedef int HICON;
|
|||||||
typedef int HWND;
|
typedef int HWND;
|
||||||
typedef int INPUT_RECORD;
|
typedef int INPUT_RECORD;
|
||||||
typedef int KEY_EVENT_RECORD;
|
typedef int KEY_EVENT_RECORD;
|
||||||
typedef int LOGFONT;
|
typedef int LOGFONTW;
|
||||||
typedef int LPARAM;
|
typedef int LPARAM;
|
||||||
typedef int LPBOOL;
|
typedef int LPBOOL;
|
||||||
typedef int LPCSTR;
|
typedef int LPCSTR;
|
||||||
@@ -103,7 +103,7 @@ typedef int LPTSTR;
|
|||||||
typedef int LPWSTR;
|
typedef int LPWSTR;
|
||||||
typedef int LRESULT;
|
typedef int LRESULT;
|
||||||
typedef int MOUSE_EVENT_RECORD;
|
typedef int MOUSE_EVENT_RECORD;
|
||||||
typedef int NEWTEXTMETRIC;
|
typedef int NEWTEXTMETRICW;
|
||||||
typedef int PACL;
|
typedef int PACL;
|
||||||
typedef int PRINTDLG;
|
typedef int PRINTDLG;
|
||||||
typedef int PSECURITY_DESCRIPTOR;
|
typedef int PSECURITY_DESCRIPTOR;
|
||||||
@@ -1420,7 +1420,7 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
|
|||||||
static int stored_nCopies = 1;
|
static int stored_nCopies = 1;
|
||||||
static int stored_nFlags = 0;
|
static int stored_nFlags = 0;
|
||||||
|
|
||||||
LOGFONT fLogFont;
|
LOGFONTW fLogFont;
|
||||||
int pifItalic;
|
int pifItalic;
|
||||||
int pifBold;
|
int pifBold;
|
||||||
int pifUnderline;
|
int pifUnderline;
|
||||||
@@ -1577,7 +1577,7 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
|
|||||||
fLogFont.lfItalic = pifItalic;
|
fLogFont.lfItalic = pifItalic;
|
||||||
fLogFont.lfUnderline = pifUnderline;
|
fLogFont.lfUnderline = pifUnderline;
|
||||||
prt_font_handles[pifBold][pifItalic][pifUnderline]
|
prt_font_handles[pifBold][pifItalic][pifUnderline]
|
||||||
= CreateFontIndirect(&fLogFont);
|
= CreateFontIndirectW(&fLogFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetBkMode(prt_dlg.hDC, OPAQUE);
|
SetBkMode(prt_dlg.hDC, OPAQUE);
|
||||||
@@ -2915,12 +2915,12 @@ quality_id2name(DWORD id)
|
|||||||
return qp->name;
|
return qp->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const LOGFONT s_lfDefault =
|
static const LOGFONTW s_lfDefault =
|
||||||
{
|
{
|
||||||
-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
-12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
||||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||||
PROOF_QUALITY, FIXED_PITCH | FF_DONTCARE,
|
PROOF_QUALITY, FIXED_PITCH | FF_DONTCARE,
|
||||||
"Fixedsys" /* see _ReadVimIni */
|
L"Fixedsys" /* see _ReadVimIni */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Initialise the "current height" to -12 (same as s_lfDefault) just
|
/* Initialise the "current height" to -12 (same as s_lfDefault) just
|
||||||
@@ -2937,7 +2937,7 @@ int current_font_height = -12; /* also used in gui_w48.c */
|
|||||||
* calculation is for a vertical (height) size or a horizontal (width) one.
|
* calculation is for a vertical (height) size or a horizontal (width) one.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
points_to_pixels(char_u *str, char_u **end, int vertical, long_i pprinter_dc)
|
points_to_pixels(WCHAR *str, WCHAR **end, int vertical, long_i pprinter_dc)
|
||||||
{
|
{
|
||||||
int pixels;
|
int pixels;
|
||||||
int points = 0;
|
int points = 0;
|
||||||
@@ -2948,7 +2948,7 @@ points_to_pixels(char_u *str, char_u **end, int vertical, long_i pprinter_dc)
|
|||||||
|
|
||||||
while (*str != NUL)
|
while (*str != NUL)
|
||||||
{
|
{
|
||||||
if (*str == '.' && divisor == 0)
|
if (*str == L'.' && divisor == 0)
|
||||||
{
|
{
|
||||||
/* Start keeping a divisor, for later */
|
/* Start keeping a divisor, for later */
|
||||||
divisor = 1;
|
divisor = 1;
|
||||||
@@ -2959,7 +2959,7 @@ points_to_pixels(char_u *str, char_u **end, int vertical, long_i pprinter_dc)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
points *= 10;
|
points *= 10;
|
||||||
points += *str - '0';
|
points += *str - L'0';
|
||||||
divisor *= 10;
|
divisor *= 10;
|
||||||
}
|
}
|
||||||
++str;
|
++str;
|
||||||
@@ -2989,15 +2989,15 @@ points_to_pixels(char_u *str, char_u **end, int vertical, long_i pprinter_dc)
|
|||||||
|
|
||||||
static int CALLBACK
|
static int CALLBACK
|
||||||
font_enumproc(
|
font_enumproc(
|
||||||
ENUMLOGFONT *elf,
|
ENUMLOGFONTW *elf,
|
||||||
NEWTEXTMETRIC *ntm UNUSED,
|
NEWTEXTMETRICW *ntm UNUSED,
|
||||||
int type UNUSED,
|
DWORD type UNUSED,
|
||||||
LPARAM lparam)
|
LPARAM lparam)
|
||||||
{
|
{
|
||||||
/* Return value:
|
/* Return value:
|
||||||
* 0 = terminate now (monospace & ANSI)
|
* 0 = terminate now (monospace & ANSI)
|
||||||
* 1 = continue, still no luck...
|
* 1 = continue, still no luck...
|
||||||
* 2 = continue, but we have an acceptable LOGFONT
|
* 2 = continue, but we have an acceptable LOGFONTW
|
||||||
* (monospace, not ANSI)
|
* (monospace, not ANSI)
|
||||||
* We use these values, as EnumFontFamilies returns 1 if the
|
* We use these values, as EnumFontFamilies returns 1 if the
|
||||||
* callback function is never called. So, we check the return as
|
* callback function is never called. So, we check the return as
|
||||||
@@ -3005,7 +3005,7 @@ font_enumproc(
|
|||||||
* It's not pretty, but it works!
|
* It's not pretty, but it works!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LOGFONT *lf = (LOGFONT *)(lparam);
|
LOGFONTW *lf = (LOGFONTW *)(lparam);
|
||||||
|
|
||||||
#ifndef FEAT_PROPORTIONAL_FONTS
|
#ifndef FEAT_PROPORTIONAL_FONTS
|
||||||
/* Ignore non-monospace fonts without further ado */
|
/* Ignore non-monospace fonts without further ado */
|
||||||
@@ -3013,7 +3013,7 @@ font_enumproc(
|
|||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Remember this LOGFONT as a "possible" */
|
/* Remember this LOGFONTW as a "possible" */
|
||||||
*lf = elf->elfLogFont;
|
*lf = elf->elfLogFont;
|
||||||
|
|
||||||
/* Terminate the scan as soon as we find an ANSI font */
|
/* Terminate the scan as soon as we find an ANSI font */
|
||||||
@@ -3027,15 +3027,15 @@ font_enumproc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
init_logfont(LOGFONT *lf)
|
init_logfont(LOGFONTW *lf)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
HWND hwnd = GetDesktopWindow();
|
HWND hwnd = GetDesktopWindow();
|
||||||
HDC hdc = GetWindowDC(hwnd);
|
HDC hdc = GetWindowDC(hwnd);
|
||||||
|
|
||||||
n = EnumFontFamilies(hdc,
|
n = EnumFontFamiliesW(hdc,
|
||||||
(LPCSTR)lf->lfFaceName,
|
lf->lfFaceName,
|
||||||
(FONTENUMPROC)font_enumproc,
|
(FONTENUMPROCW)font_enumproc,
|
||||||
(LPARAM)lf);
|
(LPARAM)lf);
|
||||||
|
|
||||||
ReleaseDC(hwnd, hdc);
|
ReleaseDC(hwnd, hdc);
|
||||||
@@ -3044,7 +3044,7 @@ init_logfont(LOGFONT *lf)
|
|||||||
if (n == 1)
|
if (n == 1)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
/* Tidy up the rest of the LOGFONT structure. We set to a basic
|
/* Tidy up the rest of the LOGFONTW structure. We set to a basic
|
||||||
* font - get_logfont() sets bold, italic, etc based on the user's
|
* font - get_logfont() sets bold, italic, etc based on the user's
|
||||||
* input.
|
* input.
|
||||||
*/
|
*/
|
||||||
@@ -3059,40 +3059,52 @@ init_logfont(LOGFONT *lf)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare a UTF-16 string and an ASCII string literally.
|
||||||
|
* Only works all the code points are inside ASCII range.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
utf16ascncmp(const WCHAR *w, const char *p, size_t n)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
if (w[i] == 0 || w[i] != p[i])
|
||||||
|
return w[i] - p[i];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get font info from "name" into logfont "lf".
|
* Get font info from "name" into logfont "lf".
|
||||||
* Return OK for a valid name, FAIL otherwise.
|
* Return OK for a valid name, FAIL otherwise.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_logfont(
|
get_logfont(
|
||||||
LOGFONT *lf,
|
LOGFONTW *lf,
|
||||||
char_u *name,
|
char_u *name,
|
||||||
HDC printer_dc,
|
HDC printer_dc,
|
||||||
int verbose)
|
int verbose)
|
||||||
{
|
{
|
||||||
char_u *p;
|
WCHAR *p;
|
||||||
int i;
|
int i;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
static LOGFONT *lastlf = NULL;
|
static LOGFONTW *lastlf = NULL;
|
||||||
char_u *acpname = NULL;
|
WCHAR *wname;
|
||||||
|
|
||||||
*lf = s_lfDefault;
|
*lf = s_lfDefault;
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
/* Convert 'name' from 'encoding' to the current codepage, because
|
wname = enc_to_utf16(name, NULL);
|
||||||
* lf->lfFaceName uses the current codepage.
|
if (wname == NULL)
|
||||||
* TODO: Use Wide APIs instead of ANSI APIs. */
|
return FAIL;
|
||||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
|
||||||
{
|
if (wcscmp(wname, L"*") == 0)
|
||||||
int len;
|
|
||||||
enc_to_acp(name, (int)STRLEN(name), &acpname, &len);
|
|
||||||
name = acpname;
|
|
||||||
}
|
|
||||||
if (STRCMP(name, "*") == 0)
|
|
||||||
{
|
{
|
||||||
#if defined(FEAT_GUI_MSWIN)
|
#if defined(FEAT_GUI_MSWIN)
|
||||||
CHOOSEFONT cf;
|
CHOOSEFONTW cf;
|
||||||
/* if name is "*", bring up std font dialog: */
|
/* if name is "*", bring up std font dialog: */
|
||||||
vim_memset(&cf, 0, sizeof(cf));
|
vim_memset(&cf, 0, sizeof(cf));
|
||||||
cf.lStructSize = sizeof(cf);
|
cf.lStructSize = sizeof(cf);
|
||||||
@@ -3102,7 +3114,7 @@ get_logfont(
|
|||||||
*lf = *lastlf;
|
*lf = *lastlf;
|
||||||
cf.lpLogFont = lf;
|
cf.lpLogFont = lf;
|
||||||
cf.nFontType = 0 ; //REGULAR_FONTTYPE;
|
cf.nFontType = 0 ; //REGULAR_FONTTYPE;
|
||||||
if (ChooseFont(&cf))
|
if (ChooseFontW(&cf))
|
||||||
ret = OK;
|
ret = OK;
|
||||||
#endif
|
#endif
|
||||||
goto theend;
|
goto theend;
|
||||||
@@ -3111,14 +3123,14 @@ get_logfont(
|
|||||||
/*
|
/*
|
||||||
* Split name up, it could be <name>:h<height>:w<width> etc.
|
* Split name up, it could be <name>:h<height>:w<width> etc.
|
||||||
*/
|
*/
|
||||||
for (p = name; *p && *p != ':'; p++)
|
for (p = wname; *p && *p != L':'; p++)
|
||||||
{
|
{
|
||||||
if (p - name + 1 >= LF_FACESIZE)
|
if (p - wname + 1 >= LF_FACESIZE)
|
||||||
goto theend; /* Name too long */
|
goto theend; /* Name too long */
|
||||||
lf->lfFaceName[p - name] = *p;
|
lf->lfFaceName[p - wname] = *p;
|
||||||
}
|
}
|
||||||
if (p != name)
|
if (p != wname)
|
||||||
lf->lfFaceName[p - name] = NUL;
|
lf->lfFaceName[p - wname] = NUL;
|
||||||
|
|
||||||
/* First set defaults */
|
/* First set defaults */
|
||||||
lf->lfHeight = -12;
|
lf->lfHeight = -12;
|
||||||
@@ -3136,18 +3148,16 @@ get_logfont(
|
|||||||
int did_replace = FALSE;
|
int did_replace = FALSE;
|
||||||
|
|
||||||
for (i = 0; lf->lfFaceName[i]; ++i)
|
for (i = 0; lf->lfFaceName[i]; ++i)
|
||||||
if (IsDBCSLeadByte(lf->lfFaceName[i]))
|
if (lf->lfFaceName[i] == L'_')
|
||||||
++i;
|
|
||||||
else if (lf->lfFaceName[i] == '_')
|
|
||||||
{
|
{
|
||||||
lf->lfFaceName[i] = ' ';
|
lf->lfFaceName[i] = L' ';
|
||||||
did_replace = TRUE;
|
did_replace = TRUE;
|
||||||
}
|
}
|
||||||
if (!did_replace || init_logfont(lf) == FAIL)
|
if (!did_replace || init_logfont(lf) == FAIL)
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*p == ':')
|
while (*p == L':')
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
/* Set the values found after ':' */
|
/* Set the values found after ':' */
|
||||||
@@ -3155,30 +3165,30 @@ get_logfont(
|
|||||||
{
|
{
|
||||||
switch (*p++)
|
switch (*p++)
|
||||||
{
|
{
|
||||||
case 'h':
|
case L'h':
|
||||||
lf->lfHeight = - points_to_pixels(p, &p, TRUE, (long_i)printer_dc);
|
lf->lfHeight = - points_to_pixels(p, &p, TRUE, (long_i)printer_dc);
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case L'w':
|
||||||
lf->lfWidth = points_to_pixels(p, &p, FALSE, (long_i)printer_dc);
|
lf->lfWidth = points_to_pixels(p, &p, FALSE, (long_i)printer_dc);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case L'b':
|
||||||
lf->lfWeight = FW_BOLD;
|
lf->lfWeight = FW_BOLD;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case L'i':
|
||||||
lf->lfItalic = TRUE;
|
lf->lfItalic = TRUE;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case L'u':
|
||||||
lf->lfUnderline = TRUE;
|
lf->lfUnderline = TRUE;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case L's':
|
||||||
lf->lfStrikeOut = TRUE;
|
lf->lfStrikeOut = TRUE;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case L'c':
|
||||||
{
|
{
|
||||||
struct charset_pair *cp;
|
struct charset_pair *cp;
|
||||||
|
|
||||||
for (cp = charset_pairs; cp->name != NULL; ++cp)
|
for (cp = charset_pairs; cp->name != NULL; ++cp)
|
||||||
if (STRNCMP(p, cp->name, strlen(cp->name)) == 0)
|
if (utf16ascncmp(p, cp->name, strlen(cp->name)) == 0)
|
||||||
{
|
{
|
||||||
lf->lfCharSet = cp->charset;
|
lf->lfCharSet = cp->charset;
|
||||||
p += strlen(cp->name);
|
p += strlen(cp->name);
|
||||||
@@ -3186,17 +3196,19 @@ get_logfont(
|
|||||||
}
|
}
|
||||||
if (cp->name == NULL && verbose)
|
if (cp->name == NULL && verbose)
|
||||||
{
|
{
|
||||||
semsg(_("E244: Illegal charset name \"%s\" in font name \"%s\""), p, name);
|
char_u *s = utf16_to_enc(p, NULL);
|
||||||
|
semsg(_("E244: Illegal charset name \"%s\" in font name \"%s\""), s, name);
|
||||||
|
vim_free(s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'q':
|
case L'q':
|
||||||
{
|
{
|
||||||
struct quality_pair *qp;
|
struct quality_pair *qp;
|
||||||
|
|
||||||
for (qp = quality_pairs; qp->name != NULL; ++qp)
|
for (qp = quality_pairs; qp->name != NULL; ++qp)
|
||||||
if (STRNCMP(p, qp->name, strlen(qp->name)) == 0)
|
if (utf16ascncmp(p, qp->name, strlen(qp->name)) == 0)
|
||||||
{
|
{
|
||||||
lf->lfQuality = qp->quality;
|
lf->lfQuality = qp->quality;
|
||||||
p += strlen(qp->name);
|
p += strlen(qp->name);
|
||||||
@@ -3204,7 +3216,9 @@ get_logfont(
|
|||||||
}
|
}
|
||||||
if (qp->name == NULL && verbose)
|
if (qp->name == NULL && verbose)
|
||||||
{
|
{
|
||||||
semsg(_("E244: Illegal quality name \"%s\" in font name \"%s\""), p, name);
|
char_u *s = utf16_to_enc(p, NULL);
|
||||||
|
semsg(_("E244: Illegal quality name \"%s\" in font name \"%s\""), s, name);
|
||||||
|
vim_free(s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3214,7 +3228,7 @@ get_logfont(
|
|||||||
semsg(_("E245: Illegal char '%c' in font name \"%s\""), p[-1], name);
|
semsg(_("E245: Illegal char '%c' in font name \"%s\""), p[-1], name);
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
while (*p == ':')
|
while (*p == L':')
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
ret = OK;
|
ret = OK;
|
||||||
@@ -3224,11 +3238,11 @@ theend:
|
|||||||
if (ret == OK && printer_dc == NULL)
|
if (ret == OK && printer_dc == NULL)
|
||||||
{
|
{
|
||||||
vim_free(lastlf);
|
vim_free(lastlf);
|
||||||
lastlf = (LOGFONT *)alloc(sizeof(LOGFONT));
|
lastlf = (LOGFONTW *)alloc(sizeof(LOGFONTW));
|
||||||
if (lastlf != NULL)
|
if (lastlf != NULL)
|
||||||
mch_memmove(lastlf, lf, sizeof(LOGFONT));
|
mch_memmove(lastlf, lf, sizeof(LOGFONTW));
|
||||||
}
|
}
|
||||||
vim_free(acpname);
|
vim_free(wname);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -70,7 +70,7 @@ void gui_mch_set_font(GuiFont font);
|
|||||||
void gui_mch_set_fg_color(guicolor_T color);
|
void gui_mch_set_fg_color(guicolor_T color);
|
||||||
void gui_mch_set_bg_color(guicolor_T color);
|
void gui_mch_set_bg_color(guicolor_T color);
|
||||||
void gui_mch_set_sp_color(guicolor_T color);
|
void gui_mch_set_sp_color(guicolor_T color);
|
||||||
void im_set_font(LOGFONT *lf);
|
void im_set_font(LOGFONTW *lf);
|
||||||
void im_set_position(int row, int col);
|
void im_set_position(int row, int col);
|
||||||
void im_set_active(int active);
|
void im_set_active(int active);
|
||||||
int im_get_status(void);
|
int im_get_status(void);
|
||||||
|
@@ -49,6 +49,6 @@ char_u *serverGetReply(HWND server, int *expr_res, int remove, int wait, int tim
|
|||||||
void serverProcessPendingMessages(void);
|
void serverProcessPendingMessages(void);
|
||||||
char *charset_id2name(int id);
|
char *charset_id2name(int id);
|
||||||
char *quality_id2name(DWORD id);
|
char *quality_id2name(DWORD id);
|
||||||
int get_logfont(LOGFONT *lf, char_u *name, HDC printer_dc, int verbose);
|
int get_logfont(LOGFONTW *lf, char_u *name, HDC printer_dc, int verbose);
|
||||||
void channel_init_winsock(void);
|
void channel_init_winsock(void);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@@ -775,6 +775,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1081,
|
||||||
/**/
|
/**/
|
||||||
1080,
|
1080,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user