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

234 views
Skip to first unread message

dusanx

unread,
Sep 23, 2021, 7:50:44 AM9/23/21
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 AM9/23/21
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 AM9/23/21
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 AM9/23/21
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 AM10/9/21
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.

Micah Lindstrom

unread,
Oct 5, 2024, 4:43:54 PM10/5/24
to vim/vim, Subscribed

See related request at https://stackoverflow.com/q/66141410/6047827.

I would like the addition of guifontbold and guifontitalic as well. That would let me use set guifont=Source_Code_Pro_Semibold:h9 in my vimrc to set my default font; I cannot do that currently as it breaks the bold syntax highlighting which does not realize there are bolder variants available. So instead I have to use set guifont=Source_Code_Pro:h9. It's a little light, but better than having no bolded syntax highlighting at all.

Even better would be if I could use a Variable Font (VF) like Source Code Variable. For example you can download the VF *.zip file at https://github.com/adobe-fonts/source-code-pro/releases. That lets just two font files supply the full range of weights in both italic and roman (aka upright) styles. The Source Code Pro Variable weight axis supports anything between 200 and 900, as shown with a slider on Adobe's website at https://fonts.adobe.com/fonts/source-code-variable.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8905/2395192381@github.com>

froggie

unread,
Nov 18, 2024, 5:32:31 AM11/18/24
to vim/vim, Subscribed

Any news on this at all?

abc def
bar
bar baz
| Fira Code Retina | Fira Code SemiBold | |:---:|:---:| | Screenshot.2024-11-18.at.05.14.17.png (view on web) | Screenshot.2024-11-18.at.05.13.48.png (view on web) | | ![image](https://github.com/user-attachments/assets/48675d2d-b32d-4a0d-bd4c-0a4690303b5b) | ![image](https://github.com/user-attachments/assets/fa96947e-c3e8-4cec-b7a9-0551ab3e3edc) | | Bold highlight group for the mode statuslight |
Fira Code Medium Fira Code Bold
Screenshot.2024-11-18.at.05.14.23.png (view on web) Screenshot.2024-11-18.at.05.14.31.png (view on web)
image.png (view on web) image.png (view on web)

| Fira


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8905/2482624578@github.com>

Reply all
Reply to author
Forward
0 new messages