-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add weight specifier for font specification for Windows. #4309
Conversation
always uses FW_NORMAL (400) as a baseline. Without the ability to specify an explicit weight, the Windows fontmapper will often make Light or ExtraLight variants inaccessible. Using the font chooser does not typically have this problem because the precise font weight is specified in the LOGFONT structure. There is currently no way to get equivalent functionality via the guifont (gfn) setting.
Codecov Report
@@ Coverage Diff @@
## master #4309 +/- ##
==========================================
+ Coverage 79.92% 79.93% +<.01%
==========================================
Files 108 108
Lines 141702 141702
==========================================
+ Hits 113262 113270 +8
+ Misses 28440 28432 -8
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'guifont' part of runtime/doc/options.txt
should be also updated.
get_logfont() always uses FW_NORMAL (400) as a baseline. Without the
ability to specify an explicit weight, the Windows fontmapper will
often make Light or ExtraLight variants inaccessible. Using the font
chooser does not typically have this problem because the precise font
weight is specified in the LOGFONT structure. There is currently no
way to get equivalent functionality via the guifont (gfn) setting.
This fix is intended to address #1723
Looks useful. Please also update the documentation, explaining that
the bold option is a variant of using "W".
…--
You know you use Vim too much when you have this alias in your
~/.bashrc file: alias :e=/bin/vim (Eljay Love-Jensen)
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Good point. Will change to use wcstol() and update documentation
accordingly.
Thanks!
Charlton
…On Sat, Apr 27, 2019 at 4:32 AM K.Takata ***@***.***> wrote:
***@***.**** commented on this pull request.
'guifont' part of runtime/doc/options.txt should be also updated.
------------------------------
In src/os_mswin.c
<#4309 (comment)>:
> @@ -2992,6 +3008,9 @@ get_logfont(
case L'w':
lf->lfWidth = points_to_pixels(p, &p, FALSE, (long_i)printer_dc);
break;
+ case L'W':
+ lf->lfWeight = str_to_int(p, &p);
Can we use wcstol()?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4309 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AL5U26SU53BMBE7BY2F6WODPSQFTPANCNFSM4HI3R4YQ>
.
|
documentation to inform about new weight specification and to clarify that a bold ('b') attribute is equivalent to a 700 weight
Updated to use wcstol and updated documentation accordingly.
Thanks!
Charlton
…On Sat, Apr 27, 2019 at 7:37 AM Bram Moolenaar ***@***.***> wrote:
> get_logfont() always uses FW_NORMAL (400) as a baseline. Without the
> ability to specify an explicit weight, the Windows fontmapper will
> often make Light or ExtraLight variants inaccessible. Using the font
> chooser does not typically have this problem because the precise font
> weight is specified in the LOGFONT structure. There is currently no
> way to get equivalent functionality via the guifont (gfn) setting.
>
> This fix is intended to address #1723
Looks useful. Please also update the documentation, explaining that
the bold option is a variant of using "W".
--
You know you use Vim too much when you have this alias in your
~/.bashrc file: alias :e=/bin/vim (Eljay Love-Jensen)
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4309 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AL5U26QO3WECWSWZ4WVDMDTPSQ3IZANCNFSM4HI3R4YQ>
.
|
Updated to use wcstol and updated documentation accordingly.
+ 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
Do you mean "Bold" instead of "Book"?
…--
`When any government, or any church for that matter, undertakes to say to
its subjects, "This you may not read, this you must not see, this you are
forbidden to know," the end result is tyranny and oppression no matter how
holy the motives' -- Robert A Heinlein, "If this goes on --"
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
No...I actually mean Book (though I suppose it applies to Bold as well).
Typical font weights from font houses are ExtraLight, Light, Book, Medium,
SemiBold, Bold, Black, etc. I believe typographically, Medium is often the
"bold" face for Light weights and Bold is the "bold" face for "Book"
weights. You can see an example here:
https://www.typography.com/fonts/operator/styles/ or
https://fonts.adobe.com/fonts/ff-meta etc.
Cheers,
Charlton
…On Sat, Apr 27, 2019 at 2:41 PM Bram Moolenaar ***@***.***> wrote:
> Updated to use wcstol and updated documentation accordingly.
+ 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
Do you mean "Bold" instead of "Book"?
--
`When any government, or any church for that matter, undertakes to say to
its subjects, "This you may not read, this you must not see, this you are
forbidden to know," the end result is tyranny and oppression no matter how
holy the motives' -- Robert A Heinlein, "If this goes on --"
/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4309 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AL5U26T76AOFCA4HSBQDPNTPSSM7NANCNFSM4HI3R4YQ>
.
|
I think it's better to update also logfont2name() in gui_w32.c. --- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -3125,6 +3125,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)
@@ -3132,15 +3133,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));
+ 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 == ' ')
@@ -3149,7 +3154,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"); |
I struggled with this. I agree that decimal is likely the normative
expectation but I wasn't sure if other formats might be expected in some
cases. Will fix it to base 10.
Thanks,
Charlton
…On Sat, Apr 27, 2019 at 10:22 PM K.Takata ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/os_mswin.c
<#4309 (comment)>:
> @@ -2751,6 +2751,7 @@ static const LOGFONTW s_lfDefault =
*/
int current_font_height = -12; /* also used in gui_w48.c */
+
No need to add this empty line.
------------------------------
In src/os_mswin.c
<#4309 (comment)>:
> @@ -2992,6 +2993,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, 0);
Isn't it better to use 10 for the 3rd argument?
We don't need to support octal or hex numbers here.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4309 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AL5U26SUXIHHWYMBY4OS2ZDPSUC4VANCNFSM4HI3R4YQ>
.
|
is included in the name. Delete extraneous whitespace. Convert call to wcstol to use only base 10 instead of auto-detect.
Thanks for being meticulous. I have implemented your suggested updates.
…On Sat, Apr 27, 2019 at 10:10 PM K.Takata ***@***.***> wrote:
I think it's better to update also logfont2name() in gui_w32.c.
E.g.:
--- a/src/gui_w32.c+++ b/src/gui_w32.c@@ -3125,6 +3125,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)@@ -3132,15 +3133,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));+ 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 == ' ')@@ -3149,7 +3154,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");
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4309 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AL5U26W7MPQJ4XL5BAM536TPSUBSZANCNFSM4HI3R4YQ>
.
|
get_logfont() always uses FW_NORMAL (400) as a baseline. Without the ability to
specify an explicit weight, the Windows fontmapper will often make
Light or ExtraLight variants inaccessible. Using the font chooser
does not typically have this problem because the precise font
weight is specified in the LOGFONT structure. There is currently
no way to get equivalent functionality via the guifont (gfn)
setting. This commit adds the 'W' attribute to a font specifier which
allows for the indication of an explicit font weight.
set guifont=My_Awesome_Font:h13:W275
This fix is intended to address #1723