Skip to content

Commit 49f48d0

Browse files
committed
updated for version 7.3.1220
Problem: MS-Windows: When using wide font italic and bold are not included. Solution: Support wide-bold, wide-italic and wide-bold-italic. (Ken Takata, Taro Muraoka)
1 parent 5487c2f commit 49f48d0

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

src/gui.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,14 @@ gui_init_check()
410410
gui.fontset = NOFONTSET;
411411
# endif
412412
#endif
413+
#ifdef FEAT_MBYTE
414+
gui.wide_font = NOFONT;
415+
# ifndef FEAT_GUI_GTK
416+
gui.wide_bold_font = NOFONT;
417+
gui.wide_ital_font = NOFONT;
418+
gui.wide_boldital_font = NOFONT;
419+
# endif
420+
#endif
413421

414422
#ifdef FEAT_MENU
415423
# ifndef FEAT_GUI_GTK
@@ -1012,6 +1020,11 @@ gui_get_wide_font()
10121020
gui.wide_font = font;
10131021
# ifdef FEAT_GUI_MSWIN
10141022
gui_mch_wide_font_changed();
1023+
# else
1024+
/*
1025+
* TODO: setup wide_bold_font, wide_ital_font and wide_boldital_font to
1026+
* support those fonts for 'guifontwide'.
1027+
*/
10151028
# endif
10161029
return OK;
10171030
}
@@ -2180,6 +2193,9 @@ gui_outstr_nowrap(s, len, flags, fg, bg, back)
21802193
guicolor_T sp_color;
21812194
#if !defined(MSWIN16_FASTTEXT) && !defined(FEAT_GUI_GTK)
21822195
GuiFont font = NOFONT;
2196+
# ifdef FEAT_MBYTE
2197+
GuiFont wide_font = NOFONT;
2198+
# endif
21832199
# ifdef FEAT_XFONTSET
21842200
GuiFontset fontset = NOFONTSET;
21852201
# endif
@@ -2269,6 +2285,23 @@ gui_outstr_nowrap(s, len, flags, fg, bg, back)
22692285
}
22702286
else
22712287
font = gui.norm_font;
2288+
2289+
# ifdef FEAT_MBYTE
2290+
/*
2291+
* Choose correct wide_font by font. wide_font should be set with font
2292+
* at same time in above block. But it will make many "ifdef" nasty
2293+
* blocks. So we do it here.
2294+
*/
2295+
if (font == gui.boldital_font && gui.wide_boldital_font)
2296+
wide_font = gui.wide_boldital_font;
2297+
else if (font == gui.bold_font && gui.wide_bold_font)
2298+
wide_font = gui.wide_bold_font;
2299+
else if (font == gui.ital_font && gui.wide_ital_font)
2300+
wide_font = gui.wide_ital_font;
2301+
else if (font == gui.norm_font && gui.wide_font)
2302+
wide_font = gui.wide_font;
2303+
# endif
2304+
22722305
}
22732306
# ifdef FEAT_XFONTSET
22742307
if (fontset != NOFONTSET)
@@ -2407,7 +2440,7 @@ gui_outstr_nowrap(s, len, flags, fg, bg, back)
24072440
# ifdef FEAT_XFONTSET
24082441
&& fontset == NOFONTSET
24092442
# endif
2410-
&& gui.wide_font != NOFONT)
2443+
&& wide_font != NOFONT)
24112444
curr_wide = TRUE;
24122445
else
24132446
curr_wide = FALSE;
@@ -2441,7 +2474,7 @@ gui_outstr_nowrap(s, len, flags, fg, bg, back)
24412474
if (thislen > 0)
24422475
{
24432476
if (prev_wide)
2444-
gui_mch_set_font(gui.wide_font);
2477+
gui_mch_set_font(wide_font);
24452478
gui_mch_draw_string(gui.row, scol, s + start, thislen,
24462479
draw_flags);
24472480
if (prev_wide)

src/gui.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,12 @@ typedef struct Gui
311311
# endif
312312
#endif
313313
#ifdef FEAT_MBYTE
314-
GuiFont wide_font; /* 'guifontwide' font */
314+
GuiFont wide_font; /* Normal 'guifontwide' font */
315+
# ifndef FEAT_GUI_GTK
316+
GuiFont wide_bold_font; /* Bold 'guifontwide' font */
317+
GuiFont wide_ital_font; /* Italic 'guifontwide' font */
318+
GuiFont wide_boldital_font; /* Bold-Italic 'guifontwide' font */
319+
# endif
315320
#endif
316321
#ifdef FEAT_XFONTSET
317322
GuiFontset fontset; /* set of fonts for multi-byte chars */

src/gui_w48.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,9 +3123,43 @@ update_im_font()
31233123
void
31243124
gui_mch_wide_font_changed()
31253125
{
3126+
# ifndef MSWIN16_FASTTEXT
3127+
LOGFONT lf;
3128+
# endif
3129+
31263130
# ifdef FEAT_MBYTE_IME
31273131
update_im_font();
31283132
# endif
3133+
3134+
# ifndef MSWIN16_FASTTEXT
3135+
gui_mch_free_font(gui.wide_ital_font);
3136+
gui.wide_ital_font = NOFONT;
3137+
gui_mch_free_font(gui.wide_bold_font);
3138+
gui.wide_bold_font = NOFONT;
3139+
gui_mch_free_font(gui.wide_boldital_font);
3140+
gui.wide_boldital_font = NOFONT;
3141+
3142+
if (gui.wide_font
3143+
&& GetObject((HFONT)gui.wide_font, sizeof(lf), &lf))
3144+
{
3145+
if (!lf.lfItalic)
3146+
{
3147+
lf.lfItalic = TRUE;
3148+
gui.wide_ital_font = get_font_handle(&lf);
3149+
lf.lfItalic = FALSE;
3150+
}
3151+
if (lf.lfWeight < FW_BOLD)
3152+
{
3153+
lf.lfWeight = FW_BOLD;
3154+
gui.wide_bold_font = get_font_handle(&lf);
3155+
if (!lf.lfItalic)
3156+
{
3157+
lf.lfItalic = TRUE;
3158+
gui.wide_boldital_font = get_font_handle(&lf);
3159+
}
3160+
}
3161+
}
3162+
# endif
31293163
}
31303164
#endif
31313165

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,8 @@ static char *(features[]) =
728728

729729
static int included_patches[] =
730730
{ /* Add new patch number below this line */
731+
/**/
732+
1220,
731733
/**/
732734
1219,
733735
/**/

0 commit comments

Comments
 (0)