Saturday, August 6, 2022

Re: load diffrent font in gvim

'guifont' works only in gvim. If has(gui_running) is false, it will
have no effect. Vim running in a terminal will use whatever font the
terminal is using.

This said, even in gvim it is better to use a monospaced font, because
gvim has fixed-size character cells and uses two cells for "wide" CJK
characters and one cell for everything else except hard tabs and
"unprintable" characters. With a proportional font, small i's and l's
(and other narrow letters) will look too wide apart and small m's (and
other wide letters) will look cramped.

It also doesn't work to set the option twice in different format. You might use:

if has('gui_running')
if has('gui_gtk3') || has('gui_gtk2') " GTK1 (obsolete) uses a
different format
set gfn=Source\ Code\ Pro\ 10
elseif has('win32') || has('macunix') " 'win32' includes win64
set gfn=Source_Code_Pro:h10
endif
endif

(I'm not sure how to format it for other GUIs e.g. Athena, Motif, etc.
but if you do you could add one or more additional :elseif clause
inside the second :if).

If Source Code Pro is not installed on _all_ your systems it won't
always be found; in that case you may have to use different fonts for
GTK2/GTK3 OT1H and for Windows OTOH.

Once gvim has started, you may want to type

:set gfn?

(followed by hitting the Enter key of course) to see which 'guifont' is in use.


Best regards,
Tony.

On Sat, Aug 6, 2022 at 3:42 PM Igor Lerinc <igor.lerinc7@gmail.com> wrote:
>
> I use consolas font in Vim, but when i open it in Gvim, it appears widened (because consolas font is monospaced).
> So i want to use diffrent font for Gvim and diffrent for Vim.
>
> This is what i placed, but it doesn't work
>
> if has('gui_running')
> set guifont=Source\ Code\ Pro\ 10
> set guifont=Source\ Code\ Pro:h10:cANSI
> else
> set guifont=Consolas\ 10
> set guifont=Consolas:h10:cANSI
> endif
>
> Fonts work (loaded) when standalone.
>
> I also tried setting font that i want only in GVim, in .gvimrc in $HOME, i tried disabling setting fonts via .vimrc and it loads that font in GVim, but when i set font i want in .vimrc (so, .gvimrc and .vimrc are separate, instead in one function like above)
> but GVim still loads what is in .vimrc and displays consolas font, making it widened...
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/2778d505-75e6-45ed-8965-57c2952c41ddn%40googlegroups.com.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXvHigsbVQ44pxKDFnvs-JZBByFAmaE2%2BKTMzzEuaKf_8A%40mail.gmail.com.

No comments: