1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

Use *font for Xft font names for Lucid menus and dialogs.

* doc/emacs/xresources.texi (X Resources): Remove *faceName and replace it with
*font for Lucid.

* lwlib/lwlib-Xaw.c (make_dialog): Use *font even for Xft fonts.  Try
XLoadQueryFont first and then Xft fonts.

* lwlib/xlwmenu.c (xlwmenu_default_font): Remove, does not work for
multi-display.
(xlwMenuResources): Remove XtNfaceName and XtNdefaultFace.
Make XtNFont a String resource.
(make_windows_if_needed): Call XFlush so later changes are seen by the
X server.
(remap_menubar): Use XtMoveWidget and then
XtResizeWidget/XtResizeWindow after XtPopup.  Works better with
Compiz.
(make_drawing_gcs): Check if mw->menu.font is set.
(getDefaultXftFont): New function.
(openXftFont): faceName is now fontName.  Try XLoadQueryFont first
and then XftFontOpenName.
(XlwMenuInitialize): Initialize mw->menu.font with XLoadQueryFont.
(XlwMenuClassInitialize): Remove initialization of
xlwmenu_default_font.
(fontname_changed): Renamed from facename_changed.
(XlwMenuSetValues): Use facename_changed.

* lwlib/xlwmenu.h: Remove Xt[CN]faceName and Xt[NC]defaultFace.

* lwlib/xlwmenuP.h (_XlwMenu_part): Remove faceName.  Add fontName.

* src/xmenu.c (apply_systemfont_to_dialog): Apply to *dialog.font.
(apply_systemfont_to_menu): Set resources *menubar*font and
*popup*font.  Remove defflt.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu before lw_create_widget.

* src/xrdb.c (x_load_resources): For LUCID and XFT, don't put a
resource that specifies helvetica for menus and dialogs.
This commit is contained in:
Jan Djärv 2011-02-14 18:21:10 +01:00
parent 4bb81cc2ba
commit 3928f2b67e
11 changed files with 140 additions and 96 deletions

View File

@ -1,3 +1,8 @@
2011-02-14 Jan Djärv <jan.h.d@swipnet.se>
* xresources.texi (X Resources): Remove *faceName and replace it with
*font for Lucid.
2011-02-05 Chong Yidong <cyd@stupidchicken.com>
* rmail.texi (Rmail Display): Document Rmail MIME support more

View File

@ -428,30 +428,21 @@ and has its own resources. The resource specifications start with
@end iftex
@example
Emacs.pane.menubar.faceName: Courier-12
Emacs.pane.menubar.font: Courier-12
@end example
@noindent
To specify a font, use fontconfig font names as values to the @code{faceName}
resource.
If Emacs is not built with the Xft library, Lucid menus and dialogs
can only display old style fonts. If Emacs is built with Xft and you
prefer the old fonts, you have to specify @samp{none} to
@code{faceName}:
@example
Emacs.pane.menubar.faceName: none
Emacs.pane.dialog.faceName: none
@end example
@noindent
To specify a non-Xft font, use @code{font}. For example:
To specify a font, use fontconfig font names as values to the @code{font}
resource, or old style names:
@example
Emacs.pane.menubar.font: lucidasanstypewriter-10
@end example
@noindent
Emacs first tries to open the font as an old style font, and if that fails
as an fontconfig font. In rare cases, Emacs might do the wrong thing.
@noindent
The Lucid menus can display multilingual text in your locale with old style
fonts. For more information about fontsets see the man page for
@ -480,7 +471,7 @@ Emacs.menu*.font: 8x16
For dialog boxes, use @samp{dialog*}:
@example
Emacs.dialog*.faceName: Sans-12
Emacs.dialog*.font: Sans-12
@end example
@noindent
@ -495,8 +486,6 @@ approach should work on both kinds of systems.
Here is a list of the specific resources for menu bars and pop-up menus:
@table @code
@item faceName
Xft font for menu item text.
@item font
Font for menu item text.
@item fontSet

View File

@ -137,9 +137,8 @@ theme when Emacs is built with GTK.
off by customizing x-gtk-use-system-tooltips.
** Lucid menus and dialogs can display antialiased fonts if Emacs is built
with Xft. To change font, use X resource faceName, for example:
Emacs.pane.menubar.faceName: Courier-12
Set faceName to none and use font to use the old X fonts.
with Xft. To change font, use the X resource font, for example:
Emacs.pane.menubar.font: Courier-12
+++
** Enhanced support for characters that have no glyphs in available fonts

View File

@ -1,3 +1,31 @@
2011-02-14 Jan Djärv <jan.h.d@swipnet.se>
* xlwmenu.h: Remove Xt[CN]faceName and Xt[NC]defaultFace.
* xlwmenuP.h (_XlwMenu_part): Remove faceName. Add fontName.
* xlwmenu.c (xlwmenu_default_font): Remove, does not work for
multi-display.
(xlwMenuResources): Remove XtNfaceName and XtNdefaultFace.
Make XtNFont a String resource.
(make_windows_if_needed): Call XFlush so later changes are seen by the
X server.
(remap_menubar): Use XtMoveWidget and then
XtResizeWidget/XtResizeWindow after XtPopup. Works better with
Compiz.
(make_drawing_gcs): Check if mw->menu.font is set.
(getDefaultXftFont): New function.
(openXftFont): faceName is now fontName. Try XLoadQueryFont first
and then XftFontOpenName.
(XlwMenuInitialize): Initialize mw->menu.font with XLoadQueryFont.
(XlwMenuClassInitialize): Remove initialization of
xlwmenu_default_font.
(fontname_changed): Renamed from facename_changed.
(XlwMenuSetValues): Use facename_changed.
* lwlib-Xaw.c (make_dialog): Use *font even for Xft fonts. Try
XLoadQueryFont first and then Xft fonts.
2011-02-13 Glenn Morris <rgm@gnu.org>
* lwlib-utils.c (index, rindex): Don't undef (neither used in lwlib/,

View File

@ -577,13 +577,20 @@ make_dialog (char* name,
if (w)
{
XtResource rec[] =
{ { "faceName", "FaceName", XtRString, sizeof(String), 0, XtRString,
(XtPointer)"Sans-14" }};
char *faceName;
XtVaGetSubresources (dialog, &faceName, "Dialog", "dialog",
{ { "font", "Font", XtRString, sizeof(String), 0, XtRString,
(XtPointer)"Sans-10" }};
char *fontName = NULL;
XtVaGetSubresources (dialog, &fontName, "Dialog", "dialog",
rec, 1, (String)NULL);
if (strcmp ("none", faceName) != 0)
xft_font = openFont (dialog, faceName);
if (fontName)
{
XFontStruct *xfn = XLoadQueryFont (XtDisplay (dialog), fontName);
if (!xfn)
xft_font = openFont (dialog, fontName);
else
XFreeFont (XtDisplay (dialog), xfn);
}
if (xft_font)
{
instance->nr_xft_data = left_buttons + right_buttons + 1;

View File

@ -71,8 +71,6 @@ extern char *gray_bitmap_bits;
static int pointer_grabbed;
static XEvent menu_post_event;
static XFontStruct *xlwmenu_default_font;
static char
xlwMenuTranslations [] =
"<BtnDown>: start()\n\
@ -131,14 +129,12 @@ xlwMenuResources[] =
offset(menu.fontSet), XtRFontSet, NULL},
#endif
#ifdef HAVE_XFT
#define DEFAULT_FACENAME "Sans-10"
{XtNfaceName, XtCFaceName, XtRString, sizeof(String),
offset(menu.faceName), XtRString, DEFAULT_FACENAME},
{XtNdefaultFace, XtCDefaultFace, XtRInt, sizeof(int),
offset(menu.default_face), XtRImmediate, (XtPointer)1},
#define DEFAULT_FONTNAME "Sans-10"
#else
#define DEFAULT_FONTNAME "XtDefaultFont"
#endif
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
offset(menu.font), XtRString, "XtDefaultFont"},
{XtNfont, XtCFont, XtRString, sizeof(String),
offset(menu.fontName), XtRString, DEFAULT_FONTNAME },
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
offset(menu.foreground), XtRString, "XtDefaultForeground"},
{XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel),
@ -1352,6 +1348,7 @@ make_windows_if_needed (XlwMenuWidget mw, int n)
#endif
set_window_type (windows [i].w, mw);
}
XFlush (XtDisplay (mw));
}
/* Value is non-zero if WINDOW is part of menu bar widget W. */
@ -1534,10 +1531,12 @@ remap_menubar (XlwMenuWidget mw)
fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1);
XtVaSetValues (ws->w, XtNwidth, ws->width, XtNheight, ws->height,
XtNx, ws->x, XtNy, ws->y, NULL);
create_pixmap_for_menu (ws, mw);
XtMoveWidget (ws->w, ws->x, ws->y);
XtPopup (ws->w, XtGrabNone);
XtResizeWidget (ws->w, ws->width, ws->height,
mw->core.border_width);
XtResizeWindow (ws->w);
display_menu (mw, i, False, &selection_position, NULL, NULL);
}
@ -1613,14 +1612,17 @@ make_drawing_gcs (XlwMenuWidget mw)
XtGCMask mask = GCForeground | GCBackground;
#ifdef HAVE_X_I18N
if (!mw->menu.fontSet)
if (!mw->menu.fontSet && mw->menu.font)
{
xgcv.font = mw->menu.font->fid;
mask |= GCFont;
}
#else
xgcv.font = mw->menu.font->fid;
mask |= GCFont;
if (mw->menu.font)
{
xgcv.font = mw->menu.font->fid;
mask |= GCFont;
}
#endif
xgcv.foreground = mw->menu.foreground;
xgcv.background = mw->core.background_pixel;
@ -1847,13 +1849,20 @@ release_shadow_gcs (XlwMenuWidget mw)
}
#ifdef HAVE_XFT
static XftFont *
getDefaultXftFont (XlwMenuWidget mw)
{
int screen = XScreenNumberOfScreen (mw->core.screen);
return XftFontOpenName (XtDisplay (mw), screen, DEFAULT_FONTNAME);
}
static int
openXftFont (XlwMenuWidget mw)
{
char *fname = mw->menu.faceName;
char *fname = mw->menu.fontName;
mw->menu.xft_font = 0;
mw->menu.default_face = fname && strcmp (fname, DEFAULT_FACENAME) == 0;
mw->menu.default_face = fname && strcmp (fname, DEFAULT_FONTNAME) == 0;
if (fname && strcmp (fname, "none") != 0)
{
@ -1864,20 +1873,23 @@ openXftFont (XlwMenuWidget mw)
--i;
if (fname[i] == ' ')
{
fname = xstrdup (mw->menu.faceName);
fname = xstrdup (mw->menu.fontName);
fname[i] = '-';
}
mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
if (!mw->menu.xft_font)
mw->menu.font = XLoadQueryFont (XtDisplay (mw), fname);
if (!mw->menu.font)
{
fprintf (stderr, "Can't find font '%s'\n", fname);
mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen,
DEFAULT_FACENAME);
mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
if (!mw->menu.xft_font)
{
fprintf (stderr, "Can't find font '%s'\n", fname);
mw->menu.xft_font = getDefaultXftFont (mw);
}
}
}
if (fname != mw->menu.faceName) free (fname);
if (fname != mw->menu.fontName) free (fname);
return mw->menu.xft_font != 0;
}
@ -1913,19 +1925,19 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
;
else
#endif
if (!mw->menu.font)
{
if (!xlwmenu_default_font)
xlwmenu_default_font = XLoadQueryFont (display, "fixed");
mw->menu.font = xlwmenu_default_font;
if (!mw->menu.font)
mw->menu.font = XLoadQueryFont (display, mw->menu.fontName);
if (!mw->menu.font)
{
fprintf (stderr, "Menu font fixed not found, can't continue.\n");
abort ();
mw->menu.font = XLoadQueryFont (display, "fixed");
if (!mw->menu.font)
{
fprintf (stderr, "Menu font fixed not found, can't continue.\n");
abort ();
}
}
}
#ifdef HAVE_X_I18N
if (mw->menu.fontSet)
mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet);
@ -1966,7 +1978,6 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
static void
XlwMenuClassInitialize (void)
{
xlwmenu_default_font = 0;
}
static void
@ -2126,13 +2137,13 @@ XlwMenuDestroy (Widget w)
#ifdef HAVE_XFT
static int
facename_changed (XlwMenuWidget newmw,
fontname_changed (XlwMenuWidget newmw,
XlwMenuWidget oldmw)
{
/* This will fore a new XftFont even if the same string is set.
/* This will force a new XftFont even if the same string is set.
This is good, as rendering parameters may have changed and
we just want to do a redisplay. */
return newmw->menu.faceName != oldmw->menu.faceName;
return newmw->menu.fontName != oldmw->menu.fontName;
}
#endif
@ -2158,7 +2169,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
if (newmw->core.background_pixel != oldmw->core.background_pixel
|| newmw->menu.foreground != oldmw->menu.foreground
#ifdef HAVE_XFT
|| facename_changed (newmw, oldmw)
|| fontname_changed (newmw, oldmw)
#endif
#ifdef HAVE_X_I18N
|| newmw->menu.fontSet != oldmw->menu.fontSet
@ -2193,7 +2204,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
}
#ifdef HAVE_XFT
if (facename_changed (newmw, oldmw))
if (fontname_changed (newmw, oldmw))
{
int i;
int screen = XScreenNumberOfScreen (newmw->core.screen);

View File

@ -58,10 +58,6 @@ Boston, MA 02110-1301, USA. */
#define XtCResizeToPreferred "ResizeToPreferred"
#define XtNallowResize "allowResize"
#define XtCAllowResize "AllowResize"
#define XtNfaceName "faceName"
#define XtCFaceName "FaceName"
#define XtNdefaultFace "defaultFace"
#define XtCDefaultFace "DefaultFace"
/* Motif-compatible resource names */
#define XmNshadowThickness "shadowThickness"

View File

@ -59,11 +59,11 @@ typedef struct _XlwMenu_part
XFontSetExtents *font_extents;
#endif
#ifdef HAVE_XFT
String faceName;
int default_face;
XftFont* xft_font;
XftColor xft_fg, xft_bg, xft_disabled_fg;
#endif
String fontName;
XFontStruct* font;
Pixel foreground;
Pixel disabled_foreground;

View File

@ -1,3 +1,14 @@
2011-02-14 Jan Djärv <jan.h.d@swipnet.se>
* xrdb.c (x_load_resources): For LUCID and XFT, don't put a
resource that specifies helvetica for menus and dialogs.
* xmenu.c (apply_systemfont_to_dialog): Apply to *dialog.font.
(apply_systemfont_to_menu): Set resources *menubar*font and
*popup*font. Remove defflt.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu before lw_create_widget.
2011-02-14 Tom Tromey <tromey@redhat.com>
* keyboard.h: Remove obsolete comment.

View File

@ -887,31 +887,26 @@ apply_systemfont_to_dialog (Widget w)
{
XrmDatabase db = XtDatabase (XtDisplay (w));
if (db)
XrmPutStringResource (&db, "*dialog.faceName", fn);
XrmPutStringResource (&db, "*dialog.font", fn);
}
}
static void
apply_systemfont_to_menu (Widget w)
apply_systemfont_to_menu (struct frame *f, Widget w)
{
const char *fn = xsettings_get_system_normal_font ();
int defflt;
if (!fn) return;
if (XtIsShell (w)) /* popup menu */
if (fn)
{
Widget *childs = NULL;
XtVaGetValues (w, XtNchildren, &childs, NULL);
if (*childs) w = *childs;
XrmDatabase db = XtDatabase (XtDisplay (w));
if (db)
{
XrmPutStringResource (&db, "*menubar*font", fn);
XrmPutStringResource (&db, "*popup*font", fn);
}
}
/* Only use system font if the default is used for the menu. */
XtVaGetValues (w, XtNdefaultFace, &defflt, NULL);
if (defflt)
XtVaSetValues (w, XtNfaceName, fn, NULL);
}
#endif
/* Set the contents of the menubar widgets of frame F.
@ -1210,7 +1205,11 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
char menuOverride[] = "Ctrl<KeyPress>g: MenuGadgetEscape()";
XtTranslations override = XtParseTranslationTable (menuOverride);
menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv,
#ifdef USE_LUCID
apply_systemfont_to_menu (f, f->output_data.x->column_widget);
#endif
menubar_widget = lw_create_widget ("menubar", "menubar", id,
first_wv,
f->output_data.x->column_widget,
0,
popup_activate_callback,
@ -1221,9 +1220,6 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
/* Make menu pop down on C-g. */
XtOverrideTranslations (menubar_widget, override);
#ifdef USE_LUCID
apply_systemfont_to_menu (menubar_widget);
#endif
}
{
@ -1542,6 +1538,10 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
if (! FRAME_X_P (f))
abort ();
#ifdef USE_LUCID
apply_systemfont_to_menu (f, f->output_data.x->widget);
#endif
menu_id = widget_id_tick++;
menu = lw_create_widget ("popup", first_wv->name, menu_id, first_wv,
f->output_data.x->widget, 1, 0,
@ -1549,10 +1549,6 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
popup_deactivate_callback,
menu_highlight_callback);
#ifdef USE_LUCID
apply_systemfont_to_menu (menu);
#endif
dummy.type = ButtonPress;
dummy.serial = 0;
dummy.send_event = 0;

View File

@ -546,12 +546,14 @@ x_load_resources (Display *display, const char *xrm_string,
#else /* not USE_MOTIF */
sprintf (line, "Emacs.dialog*.font: %s", helv);
XrmPutLineResource (&rdb, line);
sprintf (line, "Emacs.dialog*.background: grey75");
XrmPutLineResource (&rdb, line);
#if !defined (HAVE_XFT) || !defined (USE_LUCID)
sprintf (line, "Emacs.dialog*.font: %s", helv);
XrmPutLineResource (&rdb, line);
sprintf (line, "*XlwMenu*font: %s", helv);
XrmPutLineResource (&rdb, line);
#endif
sprintf (line, "*XlwMenu*background: grey75");
XrmPutLineResource (&rdb, line);
sprintf (line, "Emacs*verticalScrollBar.background: grey75");