[vim/vim] Set specific font for bold and italic text? (#8905)

9 views
Skip to first unread message

dusanx

unread,
Sep 23, 2021, 7:50:44 AMSep 23
to vim/vim, Subscribed

I am using vim in (kitty) terminal where I can set different font for normal, italic, bold and italic-bold text. This is important because (for instance) Cascadia Code has many weights as separate fonts:

Cascadia Code PL
    Cascadia Code PL Bold
    Cascadia Code PL Bold Italic
    Cascadia Code PL ExtraLight
    Cascadia Code PL ExtraLight Italic
    Cascadia Code PL Italic
    Cascadia Code PL Light
    Cascadia Code PL Light Italic
    Cascadia Code PL Regular
    Cascadia Code PL SemiBold
    Cascadia Code PL SemiBold Italic
    Cascadia Code PL SemiLight
    Cascadia Code PL SemiLight Italic

Since I prefer thinner font, setting 'Light' as normal font and 'Regular' as bold works well in terminal.

However, in gvim, setting:

	set guifont=Cascadia\ Code\ PL\ Light\ 10.2
	set guifontwide=Cascadia\ Code\ PL\ Light\ 10.2

produces 'Light' normal font, then for bold segments it falls to 'Bold' since I can't specify bold separately.

Question: Is it possible to specify bold/italic/bold-italic separately in gvim? If not possible please consider this as feature request.

Thanks!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Christian Brabandt

unread,
Sep 23, 2021, 8:01:08 AMSep 23
to vim/vim, Subscribed

I think you can set separate fonts for different highlighting groups. So you can specify an italic font for a highlighting group, that uses italic. However the help mentions this can cause redraw problems.

dusanx

unread,
Sep 23, 2021, 8:53:01 AMSep 23
to vim/vim, Subscribed

That sounds interesting but I am using gruvbox theme which has a lot of groups using bold, Redefining all of them can be tricky and theme specific. I would rather use general bold/italic/bold-italic selector.

I guess redraw problems can happen when different fonts have different widths, so switching any of the programming fonts won't show that issue -- at least should not.

dusanx

unread,
Sep 23, 2021, 9:03:19 AMSep 23
to vim/vim, Subscribed

There must be already point in code where gvim decides what 'other' font to use when bold or italic is requested. I'll dig some trough source code to see if I can force other font. Ideally this can end with PR but can take some time since I am not familiar with gvim code.

Of course any input/help is welcome.

Bram Moolenaar

unread,
Oct 9, 2021, 10:59:23 AM (9 days ago) Oct 9
to vim/vim, Subscribed

The highlighting already supports using bold and italic. The implementation will try to find the right font to use with 'guifont'. To overrule that we could introduce 'guifontbold' and 'guifontitalic'. This then needs to be implemented for each platform. Font names are platform specific anyway.

Reply all
Reply to author
Forward
0 new messages