diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-04-28 14:02:47 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-04-28 14:02:47 +0200 |
commit | f720d0a77e393990b2171a77210565bdc82064f2 (patch) | |
tree | 06c64d67d8893900e2244a53c09722d697f6a466 | |
parent | 564344ace9ef06b22e4e60a0196c41b410ac27da (diff) | |
download | vim-git-f720d0a77e393990b2171a77210565bdc82064f2.tar.gz |
patch 8.1.1224: MS-Windows: cannot specify font weightv8.1.1224
Problem: MS-Windows: cannot specify font weight.
Solution: Add the "W" option to 'guifont'. (closes #4309) Move GUI font
explanation out of options.txt.
-rw-r--r-- | runtime/doc/gui.txt | 143 | ||||
-rw-r--r-- | runtime/doc/mbyte.txt | 15 | ||||
-rw-r--r-- | runtime/doc/options.txt | 128 | ||||
-rw-r--r-- | src/gui_w32.c | 15 | ||||
-rw-r--r-- | src/os_mswin.c | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
6 files changed, 172 insertions, 134 deletions
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index 5df8f533b..2a8a70d44 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -1,4 +1,4 @@ -*gui.txt* For Vim version 8.1. Last change: 2019 Jan 06 +*gui.txt* For Vim version 8.1. Last change: 2019 Apr 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -11,8 +11,9 @@ Vim's Graphical User Interface *gui* *GUI* 3. Mouse Control |gui-mouse| 4. Making GUI Selections |gui-selections| 5. Menus |menus| -6. Extras |gui-extras| -7. Shell Commands |gui-shell| +6. Font |gui-font| +7. Extras |gui-extras| +8. Shell Commands |gui-shell| Other GUI documentation: |gui_x11.txt| For specific items of the X11 GUI. @@ -1037,7 +1038,139 @@ make a selection. Note that a menu that starts with ']' will not be displayed. ============================================================================== -6. Extras *gui-extras* +6. Font + +This section describes font related options. + +GUIFONT *gui-font* + +'guifont' is the option that tells Vim what font to use. In its simplest form +the value is just one font name. It can also be a list of font names +separated with commas. The first valid font is used. When no valid font can +be found you will get an error message. + +On systems where 'guifontset' is supported (X11) and 'guifontset' is not +empty, then 'guifont' is not used. See |xfontset|. + +Note: As to the GTK GUIs, no error is given against any invalid names, and the +first element of the list is always picked up and made use of. This is +because, instead of identifying a given name with a font, the GTK GUIs use it +to construct a pattern and try to look up a font which best matches the +pattern among available fonts, and this way, the matching never fails. An +invalid name doesn't matter because a number of font properties other than +name will do to get the matching done. + +Spaces after a comma are ignored. To include a comma in a font name precede +it with a backslash. Setting an option requires an extra backslash before a +space and a backslash. See also |option-backslash|. For example: > + :set guifont=Screen15,\ 7x13,font\\,with\\,commas +will make Vim try to use the font "Screen15" first, and if it fails it will +try to use "7x13" and then "font,with,commas" instead. + +If none of the fonts can be loaded, Vim will keep the current setting. If an +empty font list is given, Vim will try using other resource settings (for X, +it will use the Vim.font resource), and finally it will try some builtin +default which should always be there ("7x13" in the case of X). The font +names given should be "normal" fonts. Vim will try to find the related bold +and italic fonts. + +For Win32, GTK, Motif, Mac OS and Photon: > + :set guifont=* +will bring up a font requester, where you can pick the font you want. + +The font name depends on the GUI used. See |setting-guifont| for a way to set +'guifont' for various systems. + +For the GTK+ 2 and 3 GUIs, the font name looks like this: > + :set guifont=Andale\ Mono\ 11 +That's all. XLFDs are not used. For Chinese this is reported to work well: > + if has("gui_gtk2") + set guifont=Bitstream\ Vera\ Sans\ Mono\ 12,Fixed\ 12 + set guifontwide=Microsoft\ Yahei\ 12,WenQuanYi\ Zen\ Hei\ 12 + endif +< +(Replace gui_gtk2 with gui_gtk3 for the GTK+ 3 GUI) + +For Mac OSX you can use something like this: > + :set guifont=Monaco:h10 +Also see 'macatsui', it can help fix display problems. + *E236* +Note that the fonts must be mono-spaced (all characters have the same width). +An exception is GTK: all fonts are accepted, but mono-spaced fonts look best. + +To preview a font on X11, you might be able to use the "xfontsel" program. +The "xlsfonts" program gives a list of all available fonts. + +For the Win32 GUI *E244* *E245* +- Takes these options in the font name (use a ':' to separate the options): + hXX - height is XX (points, can be floating-point) + wXX - width is XX (points, can be floating-point) + WXX - weight is XX (see Note on Weights below) + b - bold. This is equivalent to setting the weight to 700. + i - italic + u - underline + s - strikeout + cXX - character set XX. Valid charsets are: ANSI, ARABIC, BALTIC, + CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK, HANGEUL, + HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS, SYMBOL, THAI, + TURKISH, VIETNAMESE ANSI and BALTIC. Normally you would use + "cDEFAULT". + qXX - quality XX. Valid quality names are: PROOF, DRAFT, ANTIALIASED, + NONANTIALIASED, CLEARTYPE, DEFAULT. Normally you would use + "qDEFAULT". + Some quality values are not supported in legacy OSs. +- A '_' can be used in the place of a space, so you don't need to use + backslashes to escape the spaces. +Examples: > + :set guifont=courier_new:h12:w5:b:cRUSSIAN + :set guifont=Andale_Mono:h7.5:w4.5 + +See also |font-sizes|. + +Note on Weights: Fonts often come with a variety of weights. "Normal" weights +in Windows have a value of 400 and, left unspecified, this is the value that +will be used when attempting to find fonts. Windows will often match fonts +based on their weight with higher priority than the font name which means a +Book or Medium variant of a font might be used despite specifying a Light or +ExtraLight variant. If you are experiencing heavier weight substitution, then +explicitly setting a lower weight value may mitigate against this unwanted +substitution. + + +GUIFONTWIDE *gui-fontwide* + +When not empty, 'guifontwide' specifies a comma-separated list of fonts to be +used for double-width characters. The first font that can be loaded is +used. + +Note: The size of these fonts must be exactly twice as wide as the one +specified with 'guifont' and the same height. If there is a mismatch then +the text will not be drawn correctly. + +All GUI versions but GTK+: + +'guifontwide' is only used when 'encoding' is set to "utf-8" and +'guifontset' is empty or invalid. +When 'guifont' is set and a valid font is found in it and +'guifontwide' is empty Vim will attempt to find a matching +double-width font and set 'guifontwide' to it. + +GTK+ GUI only: *guifontwide_gtk* + +If set and valid, 'guifontwide' is always used for double width +characters, even if 'encoding' is not set to "utf-8". +Vim does not attempt to find an appropriate value for 'guifontwide' +automatically. If 'guifontwide' is empty Pango/Xft will choose the +font for characters not available in 'guifont'. Thus you do not need +to set 'guifontwide' at all unless you want to override the choice +made by Pango/Xft. + +Windows +multibyte only: *guifontwide_win_mbyte* + +If set and valid, 'guifontwide' is used for IME instead of 'guifont'. + +============================================================================== +7. Extras *gui-extras* This section describes other features which are related to the GUI. @@ -1081,7 +1214,7 @@ A recommended Japanese font is MS Mincho. You can find info here: http://www.lexikan.com/mincho.htm ============================================================================== -7. Shell Commands *gui-shell* +8. Shell Commands *gui-shell* For the X11 GUI the external commands are executed inside the gvim window. See |gui-pty|. diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt index a645cab12..15198f6b6 100644 --- a/runtime/doc/mbyte.txt +++ b/runtime/doc/mbyte.txt @@ -620,6 +620,21 @@ windows maintains a table of which groups of characters are required for a locale. You have to specify all the fonts that a locale requires in the 'guifontset' option. +Setting the 'guifontset' option also means that all font names will be handled +as a fontset name. Also the ones used for the "font" argument of the +|:highlight| command. + +Note the difference between 'guifont' and 'guifontset': In 'guifont' +the comma-separated names are alternative names, one of which will be +used. In 'guifontset' the whole string is one fontset name, +including the commas. It is not possible to specify alternative +fontset names. +This example works on many X11 systems: > + :set guifontset=-*-*-medium-r-normal--16-*-*-*-c-*-*-* +< +The fonts must match with the current locale. If fonts for the character sets +that the current locale uses are not included, setting 'guifontset' will fail. + NOTE: The fontset always uses the current locale, even though 'encoding' may be set to use a different charset. In that situation you might want to use 'guifont' and 'guifontwide' instead of 'guifontset'. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 1502fc7e4..4e0bedda1 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3727,91 +3727,8 @@ A jump table for the options with a short description can be found at |Q_op|. {not in Vi} {only available when compiled with GUI enabled} This is a list of fonts which will be used for the GUI version of Vim. - In its simplest form the value is just one font name. When - the font cannot be found you will get an error message. To try other - font names a list can be specified, font names separated with commas. - The first valid font is used. - - On systems where 'guifontset' is supported (X11) and 'guifontset' is - not empty, then 'guifont' is not used. - - Note: As to the GTK GUIs, no error is given against any invalid names, - and the first element of the list is always picked up and made use of. - This is because, instead of identifying a given name with a font, the - GTK GUIs use it to construct a pattern and try to look up a font which - best matches the pattern among available fonts, and this way, the - matching never fails. An invalid name doesn't matter because a number - of font properties other than name will do to get the matching done. - - Spaces after a comma are ignored. To include a comma in a font name - precede it with a backslash. Setting an option requires an extra - backslash before a space and a backslash. See also - |option-backslash|. For example: > - :set guifont=Screen15,\ 7x13,font\\,with\\,commas -< will make Vim try to use the font "Screen15" first, and if it fails it - will try to use "7x13" and then "font,with,commas" instead. - - If none of the fonts can be loaded, Vim will keep the current setting. - If an empty font list is given, Vim will try using other resource - settings (for X, it will use the Vim.font resource), and finally it - will try some builtin default which should always be there ("7x13" in - the case of X). The font names given should be "normal" fonts. Vim - will try to find the related bold and italic fonts. - - For Win32, GTK, Motif, Mac OS and Photon: > - :set guifont=* -< will bring up a font requester, where you can pick the font you want. - - The font name depends on the GUI used. See |setting-guifont| for a - way to set 'guifont' for various systems. - - For the GTK+ 2 and 3 GUIs, the font name looks like this: > - :set guifont=Andale\ Mono\ 11 -< That's all. XLFDs are not used. For Chinese this is reported to work - well: > - if has("gui_gtk2") - set guifont=Bitstream\ Vera\ Sans\ Mono\ 12,Fixed\ 12 - set guifontwide=Microsoft\ Yahei\ 12,WenQuanYi\ Zen\ Hei\ 12 - endif -< - (Replace gui_gtk2 with gui_gtk3 for the GTK+ 3 GUI) - - For Mac OSX you can use something like this: > - :set guifont=Monaco:h10 -< Also see 'macatsui', it can help fix display problems. - *E236* - Note that the fonts must be mono-spaced (all characters have the same - width). An exception is GTK: all fonts are accepted, but mono-spaced - fonts look best. - - To preview a font on X11, you might be able to use the "xfontsel" - program. The "xlsfonts" program gives a list of all available fonts. - - For the Win32 GUI *E244* *E245* - - takes these options in the font name: - hXX - height is XX (points, can be floating-point) - wXX - width is XX (points, can be floating-point) - b - bold - i - italic - u - underline - s - strikeout - cXX - character set XX. Valid charsets are: ANSI, ARABIC, - BALTIC, CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK, - HANGEUL, HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS, - SYMBOL, THAI, TURKISH, VIETNAMESE ANSI and BALTIC. - Normally you would use "cDEFAULT". - qXX - quality XX. Valid quality names are: PROOF, DRAFT, - ANTIALIASED, NONANTIALIASED, CLEARTYPE, DEFAULT. - Normally you would use "qDEFAULT". - Some quality values are not supported in legacy OSs. - - Use a ':' to separate the options. - - A '_' can be used in the place of a space, so you don't need to use - backslashes to escape the spaces. - - Examples: > - :set guifont=courier_new:h12:w5:b:cRUSSIAN - :set guifont=Andale_Mono:h7.5:w4.5 -< See also |font-sizes|. + In its simplest form the value is just one font name. + See |gui-font| for the details. *'guifontset'* *'gfs'* *E250* *E252* *E234* *E597* *E598* @@ -3824,20 +3741,7 @@ A jump table for the options with a short description can be found at |Q_op|. When not empty, specifies two (or more) fonts to be used. The first one for normal English, the second one for your special language. See |xfontset|. - Setting this option also means that all font names will be handled as - a fontset name. Also the ones used for the "font" argument of the - |:highlight| command. - The fonts must match with the current locale. If fonts for the - character sets that the current locale uses are not included, setting - 'guifontset' will fail. - Note the difference between 'guifont' and 'guifontset': In 'guifont' - the comma-separated names are alternative names, one of which will be - used. In 'guifontset' the whole string is one fontset name, - including the commas. It is not possible to specify alternative - fontset names. - This example works on many X11 systems: > - :set guifontset=-*-*-medium-r-normal--16-*-*-*-c-*-*-* -< + *'guifontwide'* *'gfw'* *E231* *E533* *E534* 'guifontwide' 'gfw' string (default "") global @@ -3845,31 +3749,7 @@ A jump table for the options with a short description can be found at |Q_op|. {only available when compiled with GUI enabled} When not empty, specifies a comma-separated list of fonts to be used for double-width characters. The first font that can be loaded is - used. - Note: The size of these fonts must be exactly twice as wide as the one - specified with 'guifont' and the same height. - - All GUI versions but GTK+: - - 'guifontwide' is only used when 'encoding' is set to "utf-8" and - 'guifontset' is empty or invalid. - When 'guifont' is set and a valid font is found in it and - 'guifontwide' is empty Vim will attempt to find a matching - double-width font and set 'guifontwide' to it. - - GTK+ GUI only: *guifontwide_gtk* - - If set and valid, 'guifontwide' is always used for double width - characters, even if 'encoding' is not set to "utf-8". - Vim does not attempt to find an appropriate value for 'guifontwide' - automatically. If 'guifontwide' is empty Pango/Xft will choose the - font for characters not available in 'guifont'. Thus you do not need - to set 'guifontwide' at all unless you want to override the choice - made by Pango/Xft. - - Windows +multibyte only: *guifontwide_win_mbyte* - - If set and valid, 'guifontwide' is used for IME instead of 'guifont'. + used. See |gui-fontwide|. *'guiheadroom'* *'ghr'* 'guiheadroom' 'ghr' number (default 50) diff --git a/src/gui_w32.c b/src/gui_w32.c index dbc8d95a4..aac1398b3 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -3119,6 +3119,7 @@ logfont2name(LOGFONTW lf) char *charset_name; char *quality_name; char *font_name; + int points; font_name = (char *)utf16_to_enc(lf.lfFaceName, NULL); if (font_name == NULL) @@ -3126,15 +3127,19 @@ logfont2name(LOGFONTW lf) charset_name = charset_id2name((int)lf.lfCharSet); quality_name = quality_id2name((int)lf.lfQuality); - res = (char *)alloc((unsigned)(strlen(font_name) + 20 + res = (char *)alloc((unsigned)(strlen(font_name) + 30 + (charset_name == NULL ? 0 : strlen(charset_name) + 2) + (quality_name == NULL ? 0 : strlen(quality_name) + 2))); if (res != NULL) { p = res; - /* make a normal font string out of the lf thing:*/ - sprintf((char *)p, "%s:h%d", font_name, pixels_to_points( - lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE)); + // make a normal font string out of the lf thing: + points = pixels_to_points( + lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE); + if (lf.lfWeight == FW_NORMAL || lf.lfWeight == FW_BOLD) + sprintf((char *)p, "%s:h%d", font_name, points); + else + sprintf((char *)p, "%s:h%d:W%d", font_name, points, lf.lfWeight); while (*p) { if (*p == ' ') @@ -3143,7 +3148,7 @@ logfont2name(LOGFONTW lf) } if (lf.lfItalic) STRCAT(p, ":i"); - if (lf.lfWeight >= FW_BOLD) + if (lf.lfWeight == FW_BOLD) STRCAT(p, ":b"); if (lf.lfUnderline) STRCAT(p, ":u"); diff --git a/src/os_mswin.c b/src/os_mswin.c index 48be0de52..503d3d7d7 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -2992,6 +2992,9 @@ get_logfont( case L'w': lf->lfWidth = points_to_pixels(p, &p, FALSE, (long_i)printer_dc); break; + case L'W': + lf->lfWeight = wcstol(p, &p, 10); + break; case L'b': lf->lfWeight = FW_BOLD; break; diff --git a/src/version.c b/src/version.c index fdbb9a63b..ae93dc3a4 100644 --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1224, +/**/ 1223, /**/ 1222, |