+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
@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}:
+To specify a font, use fontconfig font names as values to the @code{font}
+resource, or old style names:
@example
-Emacs.pane.menubar.faceName: none
-Emacs.pane.dialog.faceName: none
+Emacs.pane.menubar.font: lucidasanstypewriter-10
@end example
@noindent
-To specify a non-Xft font, use @code{font}. For example:
-
-@example
-Emacs.pane.menubar.font: lucidasanstypewriter-10
-@end example
+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
For dialog boxes, use @samp{dialog*}:
@example
-Emacs.dialog*.faceName: Sans-12
+Emacs.dialog*.font: Sans-12
@end example
@noindent
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
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
+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/,
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;
static int pointer_grabbed;
static XEvent menu_post_event;
-static XFontStruct *xlwmenu_default_font;
-
static char
xlwMenuTranslations [] =
"<BtnDown>: start()\n\
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),
#endif
set_window_type (windows [i].w, mw);
}
+ XFlush (XtDisplay (mw));
}
/* Value is non-zero if WINDOW is part of menu bar widget W. */
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);
}
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;
}
#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)
{
--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;
}
;
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);
static void
XlwMenuClassInitialize (void)
{
- xlwmenu_default_font = 0;
}
static void
#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
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
}
#ifdef HAVE_XFT
- if (facename_changed (newmw, oldmw))
+ if (fontname_changed (newmw, oldmw))
{
int i;
int screen = XScreenNumberOfScreen (newmw->core.screen);
#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"
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;
+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.
{
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.
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,
/* Make menu pop down on C-g. */
XtOverrideTranslations (menubar_widget, override);
-#ifdef USE_LUCID
- apply_systemfont_to_menu (menubar_widget);
-#endif
}
{
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,
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;
#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");