On 31/08/13 22:51, Rainer M. Canavan wrote:
Tony Mechelynck <[email protected]> wrote:
[...]
If it doesn't work on your first try, you may have to check which XLFDs
are available on your system for the font you want and/or use trial and
error.
Those do actually work. I wasn't aware of the limitation that the GUI fonts
had to be monotype as well, and that they can be set from within vim
instead of the usual Xresources. :hi Menu font= complains with an appropriate
error message if I try e.g. Helvetica. If I'm not mistaken, the fixed_width
requirement is controlled by the do_menu flag in hl_do_font() in src/syntax.c:
HL_TABLE()[idx].sg_fontset = fontset_name2handle(arg, 0
# ifdef FONTSET_ALWAYS
|| do_menu
# endif
# ifdef FEAT_BEVAL_TIP
|| do_tooltip
# endif
);
Can anyone explain why this is done?
regards,
rainer
Well, my guess (but I don't know the insides of Vim code as well as I
know how to use it) would be that there is "something" (maybe the
monospace requirement) that the fontset_name2handle() function handles
differently when setting the Menu or Tooltip highlight (which don't
exist on my gvim for GTK2).
BTW, FONTSET_ALWAYS is defined at gui.h line 82 if FEAT_XFONTSET is defined.
Looks like the "interesting part", including source comments, is longer
than that: e.g. at lines 8314 to 8407:
/*
* Get the font or fontset for one highlight group.
*/
static void
hl_do_font(idx, arg, do_normal, do_menu, do_tooltip, free_font)
int idx;
char_u *arg;
int do_normal; /* set normal font */
int do_menu UNUSED; /* set menu font */
int do_tooltip UNUSED; /* set tooltip font */
int free_font; /* free current font/fontset */
{
# ifdef FEAT_XFONTSET
/* If 'guifontset' is not empty, first try using the name as a
* fontset. If that doesn't work, use it as a font name. */
if (*p_guifontset != NUL
# ifdef FONTSET_ALWAYS
|| do_menu
# endif
# ifdef FEAT_BEVAL_TIP
/* In Athena & Motif, the Tooltip highlight group is always a fontset */
|| do_tooltip
# endif
)
{
if (free_font)
gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset);
HL_TABLE()[idx].sg_fontset = fontset_name2handle(arg, 0
# ifdef FONTSET_ALWAYS
|| do_menu
# endif
# ifdef FEAT_BEVAL_TIP
|| do_tooltip
# endif
);
}
if (HL_TABLE()[idx].sg_fontset != NOFONTSET)
{
/* If it worked and it's the Normal group, use it as the normal
* fontset. Same for the Menu group. */
if (do_normal)
gui_init_font(arg, TRUE);
# if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) &&
defined(FEAT_MENU)
if (do_menu)
{
# ifdef FONTSET_ALWAYS
gui.menu_fontset = HL_TABLE()[idx].sg_fontset;
# else
/* YIKES! This is a bug waiting to crash the program */
gui.menu_font = HL_TABLE()[idx].sg_fontset;
# endif
gui_mch_new_menu_font();
}
# ifdef FEAT_BEVAL
if (do_tooltip)
{
/* The Athena widget set cannot currently handle switching between
* displaying a single font and a fontset.
* If the XtNinternational resource is set to True at widget
* creation, then a fontset is always used, otherwise an
* XFontStruct is used.
*/
gui.tooltip_fontset = (XFontSet)HL_TABLE()[idx].sg_fontset;
gui_mch_new_tooltip_font();
}
# endif
# endif
}
else
# endif
{
if (free_font)
gui_mch_free_font(HL_TABLE()[idx].sg_font);
HL_TABLE()[idx].sg_font = font_name2handle(arg);
/* If it worked and it's the Normal group, use it as the
* normal font. Same for the Menu group. */
if (HL_TABLE()[idx].sg_font != NOFONT)
{
if (do_normal)
gui_init_font(arg, FALSE);
#ifndef FONTSET_ALWAYS
# if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) && defined(FEAT_MENU)
if (do_menu)
{
gui.menu_font = HL_TABLE()[idx].sg_font;
gui_mch_new_menu_font();
}
# endif
#endif
}
}
}
#endif /* FEAT_GUI */
Best regards,
Tony.
--
He who laughs last usually had to have joke explained.
--
--
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.