Control of font via syntax highlighting

265 views
Skip to first unread message

Suresh Govindachar

unread,
Oct 20, 2013, 10:22:00 PM10/20/13
to vim...@googlegroups.com

Hello,

Syntax highlighting allows controlling not only the color of the font
but also whether it is bold, italicized, or underlined (to see this, set
file type to html and write lines bracketed by no tag, <b>tag</b>,
<i>tag</i>, and <u>tag</u>).

Based on the last para of ":help highlight-font", I think it is not
possible to use different font sizes in different parts of the document,
but I thought I would ask anyway:

Question: is it possible to use different sized fonts in different
parts of the document?

Thanks,

--Suresh

Christian Brabandt

unread,
Oct 21, 2013, 6:18:15 AM10/21/13
to vim...@googlegroups.com
It is possible, but it looks awkward and Vim might behave confusing.

regards,
Christian

Tony Mechelynck

unread,
Oct 21, 2013, 8:09:34 AM10/21/13
to vim...@googlegroups.com
No, it is not possible, or at least, it is strongly discouraged. This is
the last paragraph under ":help highligh-font":

> All fonts used, except for Menu and Tooltip, should be of the same
> character size as the default font! Otherwise redrawing problems will
> occur.

The "Menu" and "Tooltip" highlight groups are only supported by the
Motif and Athena GUIs.

In GTK2, what I see is the following:
- Setting the font= attribute for the Normal group sets 'guifont' and
vice-versa, this setting the font for _all_ edit text;
- Setting a font= attribute in any other group has no effect.

I'm less sure of how other GUI flavours react to it, but anyway (with
the exception of Menu and Tooltip in Motif and Athena) I think the
conclusion is that you shouldn't do it.

Best regards,
Tony.
--
Experience is what you get when you were expecting something else.

Suresh Govindachar

unread,
Oct 21, 2013, 9:44:52 PM10/21/13
to vim...@googlegroups.com

Responding to both Christian Brabandt and Tony Mechelynck:

On 10/21/2013 5:09 AM, Tony Mechelynck wrote:
> On 21/10/13 12:18, Christian Brabandt wrote:
>> On Mon, October 21, 2013 04:22, Suresh Govindachar wrote:
>>>
>>> Hello,
>>>
>>> Syntax highlighting allows controlling not only the color of the
>>> font but also whether it is bold, italicized, or underlined (to
>>> see this, set file type to html and write lines bracketed by no
>>> tag, <b>tag</b>, <i>tag</i>, and <u>tag</u>).
>>>
>>> Based on the last para of ":help highlight-font", I think it is
>>> not possible to use different font sizes in different parts of
>>> the document, but I thought I would ask anyway:
>>>
>>> Question: is it possible to use different sized fonts in
>>> different parts of the document?
>>
>> It is possible, but it looks awkward and Vim might behave
>> confusing.

Good that it is possible -- but how exactly (I am on Windows)? The
awkwardness and other issues might be OK for my purposes.

> No, it is not possible, or at least, it is strongly discouraged.
> This is the last paragraph under ":help highligh-font":
>
>> All fonts used, except for Menu and Tooltip, should be of the
>> same character size as the default font! Otherwise redrawing
>> problems will occur.
>
> The "Menu" and "Tooltip" highlight groups are only supported by
> the Motif and Athena GUIs.
>
> In GTK2, what I see is the following:
> - Setting the font= attribute for the Normal group sets 'guifont'
> and vice-versa, this setting the font for _all_ edit text;
> - Setting a font= attribute in any other group has no effect.
>
> I'm less sure of how other GUI flavours react to it, but anyway
> (with the exception of Menu and Tooltip in Motif and Athena) I
> think the conclusion is that you shouldn't do it.

Does the conclusion assume that one wants to continue using Vim
as an editor while using different sized fonts? My purpose is just
to have Vim create a display, with different parts of the display
being of different font sizes.

--Suresh






Christian Brabandt

unread,
Oct 22, 2013, 8:23:08 AM10/22/13
to vim...@googlegroups.com
On Tue, October 22, 2013 03:44, Suresh Govindachar wrote:
> Good that it is possible -- but how exactly (I am on Windows)? The
> awkwardness and other issues might be OK for my purposes.

hi Normal ... font=Courier_New:h10:cANSI
hi Special ... font=Consolas:h12:cANSI
hi Ignore ... font=Courier_New:h14:cANSI

replace ... by the usual highlighting attributes you need
(e.g. guifg=... ctermfg=..., etc)

> > No, it is not possible,

As I said, it is possible.

> Does the conclusion assume that one wants to continue using Vim
> as an editor while using different sized fonts? My purpose is just
> to have Vim create a display, with different parts of the display
> being of different font sizes.

Depends on what exactly you want. It works more or less ok, if the font
size doesn't vary too much, because otherwise, since the character cells
do not change, the font might look to wide or too narrow.

Best,
Christian

Tony Mechelynck

unread,
Oct 23, 2013, 6:20:14 AM10/23/13
to vim...@googlegroups.com
On 22/10/13 14:23, Christian Brabandt wrote:
> On Tue, October 22, 2013 03:44, Suresh Govindachar wrote:
>> Good that it is possible -- but how exactly (I am on Windows)? The
>> awkwardness and other issues might be OK for my purposes.
>
> hi Normal ... font=Courier_New:h10:cANSI
> hi Special ... font=Consolas:h12:cANSI
> hi Ignore ... font=Courier_New:h14:cANSI
>
> replace ... by the usual highlighting attributes you need
> (e.g. guifg=... ctermfg=..., etc)
>
>> > No, it is not possible,
>
> As I said, it is possible.

Which GUI are you using? I'm on GTK2/GNOME2 and an experiment that I did
showed that font= is ignored anywhere other than for the Normal group,
and that there it is equivalent with 'guifont'. IOW, adding font= either
changes nothing, setting no font, or (for Normal) sets the font everywhere.

>
>> Does the conclusion assume that one wants to continue using Vim
>> as an editor while using different sized fonts? My purpose is just
>> to have Vim create a display, with different parts of the display
>> being of different font sizes.
>
> Depends on what exactly you want. It works more or less ok, if the font
> size doesn't vary too much, because otherwise, since the character cells
> do not change, the font might look to wide or too narrow.
>
> Best,
> Christian
>

Best regards,
Tony.
--
Nowlan's Theory:
He who hesitates is not only lost, but several miles from
the next freeway exit.

Christian Brabandt

unread,
Oct 23, 2013, 7:44:56 AM10/23/13
to vim...@googlegroups.com
On Wed, October 23, 2013 12:20, Tony Mechelynck wrote:
> Which GUI are you using?

Make an educated guess from the font name ;)
(its the same system the OP said he was using).

Best,
Christian

Reply all
Reply to author
Forward
0 new messages