1
0
forked from aniani/vim

patch 8.1.1224: MS-Windows: cannot specify font weight

Problem:    MS-Windows: cannot specify font weight.
Solution:   Add the "W" option to 'guifont'. (closes #4309)  Move GUI font
            explanation out of options.txt.
This commit is contained in:
Bram Moolenaar
2019-04-28 14:02:47 +02:00
parent 564344ace9
commit f720d0a77e
6 changed files with 172 additions and 134 deletions

View File

@@ -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");