summaryrefslogtreecommitdiff
path: root/src/gui_w32.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-04-28 14:02:47 +0200
committerBram Moolenaar <Bram@vim.org>2019-04-28 14:02:47 +0200
commitf720d0a77e393990b2171a77210565bdc82064f2 (patch)
tree06c64d67d8893900e2244a53c09722d697f6a466 /src/gui_w32.c
parent564344ace9ef06b22e4e60a0196c41b410ac27da (diff)
downloadvim-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.
Diffstat (limited to 'src/gui_w32.c')
-rw-r--r--src/gui_w32.c15
1 files changed, 10 insertions, 5 deletions
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");