Possible to use alternative font for charactor that guifont doesn't contain?

2 views
Skip to first unread message

anhnmncb

unread,
Dec 19, 2008, 10:22:14 PM12/19/08
to vim...@googlegroups.com
Hi, list,

As title, sometimes a text maybe has some charactors that guifont foo, which
is set by :set guifont=foo doesn't contain, in this case, I don't know if vim
has mechanism that use another font that has this charactor for displaying?

--
Regards,
anhnmncb

Tony Mechelynck

unread,
Dec 19, 2008, 11:41:08 PM12/19/08
to vim...@googlegroups.com

If you were on Unix/Linux, and using gvim with GTK2, it would do it for
you automagically. Alas, your mail User-Agent string seems to imply
you're on Windows, and the Windows font backend isn't that clever.

If your Windows 'guifont' ends in :cANSI or somesuch, try using
:cDEFAULT instead. This gives gvim more latitude to choose glyphs from
related fonts.

If you edit multilingual pages in several scripts, like my homesite
frontpage http://users.skynet.be/antoine.mechelynck/ then sometimes, try
as you may, you won't find a single font with all the glyphs on the
page. In that case you may have to change the 'guifont' according to
which part of the page you are currently modifying. (For instance, for
that page I use "Lucida Console" or "Bitstream Vera Sans Mono" for
Latin, "Courier New" for Cyrillic and Arabic, "MingLiU" or "FZFangSong"
for Chinese/Japanese. Also I use larger font sizes for Arabic and CJK
than for Latin and Cyrillic.) On Windows the ":set gfn=*" menu works
quite well, but I recommend trimming down the result afterwards (by
using ":set gfn=<Tab>" and editing the command-line) to keep only the
name (you wouldn't remove that ;-) ), plus one size parameter, and
:cDEFAULT as said above -- see
http://vim.wikia.org/wiki/Setting_the_font_in_the_GUI for details.


Best regards,
Tony.
--
I took a course in speed reading and was able to read War and Peace in
twenty minutes. It's about Russia.
-- Woody Allen

anhnmncb

unread,
Dec 20, 2008, 12:44:39 AM12/20/08
to vim...@googlegroups.com

:set guifont can change font, but that's not what I want, because:

1. I have to set it manually;

2. Maybe a font that has the charactor but doesn't have some others;

3. Maybe the font has that charactor but looks ugly, so I want a prefer font
for most text, but another font for just some charactors that my prefer
font doesn't have.

The case I wanted is that: when a charactor needs to be displayed but current
guifont doesn't have, then gvim will try to choose another font for it.

>
>
> Best regards,
> Tony.


--
Regards,
anhnmncb

Tony Mechelynck

unread,
Dec 20, 2008, 1:33:47 AM12/20/08
to vim...@googlegroups.com
On 20/12/08 06:44, anhnmncb wrote:
[...]

> :set guifont can change font, but that's not what I want, because:
>
> 1. I have to set it manually;
>
> 2. Maybe a font that has the charactor but doesn't have some others;

So what? Of the fonts I use, none has both Arabic and Chinese glyphs, so
I change 'guifont' (manually) depending on whether I'm editing the
Arabic text in the page, or the Chinese.

>
> 3. Maybe the font has that charactor but looks ugly, so I want a prefer font
> for most text, but another font for just some charactors that my prefer
> font doesn't have.
>
> The case I wanted is that: when a charactor needs to be displayed but current
> guifont doesn't have, then gvim will try to choose another font for it.

Well, the only solution I know for that requirement is: Move to Linux
and use GTK2.

There's one obscure sentence under ":help 'guifont'" saying that you can
have several comma-separated values in that option, but it seems to
imply that the first of them which is installed will be used globally,
not that the leftmost of them which has a glyph for any given character
will be used for that character. I may have misunderstood, but if the
selection is for each character separately you MUST select fonts which
all have the exact same height, the exact same width, and the baseline
at the exact same distance above the bottom of the character cell (in
all three cases with pixel accuracy).

Regards,
Tony.
--
Democracy is a device that insures we shall be governed no better than
we deserve.
-- George Bernard Shaw

anhnmncb

unread,
Dec 20, 2008, 6:49:30 AM12/20/08
to vim...@googlegroups.com
On 2008-12-20, Tony Mechelynck wrote:
>
> On 20/12/08 06:44, anhnmncb wrote:
> [...]
>> :set guifont can change font, but that's not what I want, because:
>>
>> 1. I have to set it manually;
>>
>> 2. Maybe a font that has the charactor but doesn't have some others;
>
> So what? Of the fonts I use, none has both Arabic and Chinese glyphs, so
> I change 'guifont' (manually) depending on whether I'm editing the
> Arabic text in the page, or the Chinese.
>
>>
>> 3. Maybe the font has that charactor but looks ugly, so I want a prefer font
>> for most text, but another font for just some charactors that my prefer
>> font doesn't have.
>>
>> The case I wanted is that: when a charactor needs to be displayed but current
>> guifont doesn't have, then gvim will try to choose another font for it.
>
> Well, the only solution I know for that requirement is: Move to Linux
> and use GTK2.

Yes, when on BSD, I use it, but saddly my work needs me must be on windows
too.

>
> There's one obscure sentence under ":help 'guifont'" saying that you can
> have several comma-separated values in that option, but it seems to
> imply that the first of them which is installed will be used globally,
> not that the leftmost of them which has a glyph for any given character
> will be used for that character. I may have misunderstood, but if the
> selection is for each character separately you MUST select fonts which
> all have the exact same height, the exact same width, and the baseline
> at the exact same distance above the bottom of the character cell (in
> all three cases with pixel accuracy).

Yes, guifont list is work in this way: the first one in the list found in
system is the global one, others following has no effect at all.

Do you use urxvt? I think it has a very very useful ability is that: you can
give a font list to it, then it will try them one by one when a charactor
can't be displayed by the first one. I miss it, and I miss it in gvim!

>
> Regards,
> Tony.


--
Regards,
anhnmncb

Tony Mechelynck

unread,
Dec 20, 2008, 7:03:51 AM12/20/08
to vim...@googlegroups.com
On 20/12/08 12:49, anhnmncb wrote:
> [...] Do you use urxvt? [...]
Well, no, I don't.

Best regards,
Tony.
--
GUARD #2: It could be carried by an African swallow!
GUARD #1: Oh, yeah, an African swallow maybe, but not a European swallow,
that's my point.
GUARD #2: Oh, yeah, I agree with that...
The Quest for the Holy Grail (Monty
Python)

Matt Wozniski

unread,
Dec 20, 2008, 12:55:38 PM12/20/08
to vim...@googlegroups.com
On Sat, Dec 20, 2008 at 6:49 AM, anhnmncb wrote:
>
> Do you use urxvt? I think it has a very very useful ability is that: you can
> give a font list to it, then it will try them one by one when a charactor
> can't be displayed by the first one. I miss it, and I miss it in gvim!

Well, you can install Cygwin/X and rxvt-unicode - or, for that matter,
a Cygwin GTK2 gvim... apart from that, I don't know of any way to get
this sort of behavior in windows.

~Matt

anhnmncb

unread,
Dec 20, 2008, 7:01:16 PM12/20/08
to vim...@googlegroups.com

cygwin sucks for me, I give up. :)

>
> ~Matt


--
Regards,
anhnmncb

bill lam

unread,
Dec 20, 2008, 10:44:09 PM12/20/08
to vim...@googlegroups.com
On Sat, 20 Dec 2008, Matt Wozniski wrote:
> Well, you can install Cygwin/X and rxvt-unicode - or, for that matter,
> a Cygwin GTK2 gvim... apart from that, I don't know of any way to get

I'm curious, can gtk or x-window server run inside cygwin, or can
anyone share experience of that?

--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩137 劉長卿 新年作
鄉心新歲切 天畔獨潸然 老至居人下 春歸在客先
嶺猿同旦暮 江柳共風煙 已似長沙傅 從今又幾年

Reply all
Reply to author
Forward
0 new messages