Documentation update: How to set a font

16 views
Skip to first unread message

Tony Mechelynck

unread,
Apr 29, 2023, 11:50:01 AM4/29/23
to Bram Moolenaar, vim_dev
Under *setting-guifont*, in file runtime/doc/gui.txt (or
$VIMRUNTIME/doc/gui.txt) line 1229
there is
if has("gui_gtk2")
there should be
if has("gui_gtk2") || has("gui_gtk3")
otherwise the 'guifont' option will be given a wrong font name
(selected by has("x11")) in gvim with GTK3 GUI.

Best regards,
Tony.

Bram Moolenaar

unread,
Apr 29, 2023, 1:02:08 PM4/29/23
to vim...@googlegroups.com, Tony Mechelynck
It should then be possible to just check for "gui_gtk", that is an "or"
of "gui_gtk2" and "gui_gtk3".

There is a comment just below this:

" Also for GTK 1

I don't think this exists anymore, and we don't need to cover everything
in this example. It's also misleading, since the check for "gui_gtk2"
actually would also catch GTK 1.

--
Mrs Abbott: I'm a paediatrician.
Basil: Feet?
Mrs Abbott: Children.
Sybil: Oh, Basil!
Basil: Well, children have feet, don't they? That's how they move
around, my dear. You must take a look next time, it's most
interesting. (Fawlty Towers)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Tony Mechelynck

unread,
Apr 29, 2023, 2:06:46 PM4/29/23
to Bram Moolenaar, vim...@googlegroups.com
On Sat, Apr 29, 2023 at 7:02 PM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Tony wrote:
>
> > Under *setting-guifont*, in file runtime/doc/gui.txt (or
> > $VIMRUNTIME/doc/gui.txt) line 1229
> > there is
> > if has("gui_gtk2")
> > there should be
> > if has("gui_gtk2") || has("gui_gtk3")
> > otherwise the 'guifont' option will be given a wrong font name
> > (selected by has("x11")) in gvim with GTK3 GUI.
>
> It should then be possible to just check for "gui_gtk", that is an "or"
> of "gui_gtk2" and "gui_gtk3".
>
> There is a comment just below this:
>
> " Also for GTK 1
>
> I don't think this exists anymore, and we don't need to cover everything
> in this example. It's also misleading, since the check for "gui_gtk2"
> actually would also catch GTK 1.

Oh? It used not to.

In the past (quite some years ago), when I used GTK1 on Linux,
• has("gui_gtk") would catch any GTK version
* has("gui_gtk2") would catch only GTK2. The Vim help mentioned it as
experimental but it was less and less so as time passed, and IIRC at
some point that mention was removed.
• GTK3 didn't exist yet.

That's when I wrote a VimTip (the precursor to the *setting-guifont*
help entry) and posted it to vim.org. I didn't use has("gui_gtk")
because GTK1 needed to be treated differently than GTK2 so I tested
for GTK2 first (GTK3 didn't exist yet), then for a few others, then
for has("x11") meaning "other X11 including GTK1" and assumed Windows
in the bottom-most "else" branch. MacVim, when it was later developed,
needed an other …elseif… but I wasn't competent to write it.

Since then has("gui_gtk3") has been added. Its use is very similar to
that of GTK2 but there are differences (e.g. Gnome3 is included in
GTK3 but Gnome2 had to be specified to configure in addition to GTK2;
but the font settings are identical).

AFAIK 'guifont' for Motif still has to be an XLFD so if we can have
the obsolete GTK1 fall into that branch of the if … elseif … elseif …
else … endif, then why not?

Best regards,
Tony.

Bram Moolenaar

unread,
Apr 29, 2023, 5:10:10 PM4/29/23
to vim...@googlegroups.com, Tony Mechelynck

Tony wrote:

> > > Under *setting-guifont*, in file runtime/doc/gui.txt (or
> > > $VIMRUNTIME/doc/gui.txt) line 1229
> > > there is
> > > if has("gui_gtk2")
> > > there should be
> > > if has("gui_gtk2") || has("gui_gtk3")
> > > otherwise the 'guifont' option will be given a wrong font name
> > > (selected by has("x11")) in gvim with GTK3 GUI.
> >
> > It should then be possible to just check for "gui_gtk", that is an "or"
> > of "gui_gtk2" and "gui_gtk3".
> >
> > There is a comment just below this:
> >
> > " Also for GTK 1
> >
> > I don't think this exists anymore, and we don't need to cover everything
> > in this example. It's also misleading, since the check for "gui_gtk2"
> > actually would also catch GTK 1.
>
> Oh? It used not to.
>
> In the past (quite some years ago), when I used GTK1 on Linux,
> • has("gui_gtk") would catch any GTK version
> * has("gui_gtk2") would catch only GTK2. The Vim help mentioned it as
> experimental but it was less and less so as time passed, and IIRC at
> some point that mention was removed.
> • GTK3 didn't exist yet.

There is no GTK 1 version anymore. The code now uses:

{"gui_gtk",
#ifdef FEAT_GUI_GTK
1
#else
0
#endif
},
{"gui_gtk2",
#if defined(FEAT_GUI_GTK) && !defined(USE_GTK3)
1
#else
0
#endif
},
{"gui_gtk3",
#if defined(FEAT_GUI_GTK) && defined(USE_GTK3)
1
#else
0
#endif
},

That means "gui_gtk2" is true for any GTK version except GTK 3.

I haven't heard from anyone that this is not sufficient. As you
mention, the first GTK version only existed long ago (and was not very
usable).

> That's when I wrote a VimTip (the precursor to the *setting-guifont*
> help entry) and posted it to vim.org. I didn't use has("gui_gtk")
> because GTK1 needed to be treated differently than GTK2 so I tested
> for GTK2 first (GTK3 didn't exist yet), then for a few others, then
> for has("x11") meaning "other X11 including GTK1" and assumed Windows
> in the bottom-most "else" branch. MacVim, when it was later developed,
> needed an other …elseif… but I wasn't competent to write it.
>
> Since then has("gui_gtk3") has been added. Its use is very similar to
> that of GTK2 but there are differences (e.g. Gnome3 is included in
> GTK3 but Gnome2 had to be specified to configure in addition to GTK2;
> but the font settings are identical).
>
> AFAIK 'guifont' for Motif still has to be an XLFD so if we can have
> the obsolete GTK1 fall into that branch of the if … elseif … elseif …
> else … endif, then why not?

We don't support GTK 1 anymore, suggesting code in the help for not
implemented functionality doesn't make much sense.

--
Eye have a spelling checker, it came with my PC;
It plainly marks four my revue mistakes I cannot sea.
I've run this poem threw it, I'm sure your please to no,
It's letter perfect in it's weigh, my checker tolled me sew!

Tony Mechelynck

unread,
Apr 30, 2023, 1:10:14 AM4/30/23
to Bram Moolenaar, vim...@googlegroups.com
On Sat, Apr 29, 2023 at 11:10 PM Bram Moolenaar <Br...@moolenaar.net> wrote:
[…]
> We don't support GTK 1 anymore, suggesting code in the help for not
> implemented functionality doesn't make much sense.

OK. Well, in that case we should test for "if has('gui_gtk')" (and not
gtk2) rather high in the list, suppress the comment about GTK1 but not
the "elseif has('x11')" and its XLFD which is for other X11 including
e.g. Motif; these come, of course, after GTK has been taken care of.

gui_kde has long lost any maintainer it ever had. Do we still support
Photon? IIRC, the 'guifont' for that platform resembles the one for
Windows but isn't identical. Yes, there is a whole *photon-fonts*
section in the help (in the os_qnx.txt helpfile).

Best regards,
Tony.

Bram Moolenaar

unread,
Apr 30, 2023, 10:31:13 AM4/30/23
to vim...@googlegroups.com, Tony Mechelynck
As far as I recall the KDE GUI was never in a usable state. The Photon
GUI is for QNX. I have no idea how well it works.

--
BLACK KNIGHT: The Black Knight always triumphs. Have at you!
ARTHUR takes his last leg off. The BLACK KNIGHT's body lands upright.
BLACK KNIGHT: All right, we'll call it a draw.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Reply all
Reply to author
Forward
0 new messages