[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r103275: Use *font for Xft font names
From: |
Jan D. |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r103275: Use *font for Xft font names for Lucid menus and dialogs. |
Date: |
Mon, 14 Feb 2011 18:21:10 +0100 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 103275
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Mon 2011-02-14 18:21:10 +0100
message:
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.
modified:
doc/emacs/ChangeLog
doc/emacs/xresources.texi
etc/NEWS
lwlib/ChangeLog
lwlib/lwlib-Xaw.c
lwlib/xlwmenu.c
lwlib/xlwmenu.h
lwlib/xlwmenuP.h
src/ChangeLog
src/xmenu.c
src/xrdb.c
=== modified file 'doc/emacs/ChangeLog'
--- a/doc/emacs/ChangeLog 2011-02-05 22:30:14 +0000
+++ b/doc/emacs/ChangeLog 2011-02-14 17:21:10 +0000
@@ -1,3 +1,8 @@
+2011-02-14 Jan Djärv <address@hidden>
+
+ * xresources.texi (X Resources): Remove *faceName and replace it with
+ *font for Lucid.
+
2011-02-05 Chong Yidong <address@hidden>
* rmail.texi (Rmail Display): Document Rmail MIME support more
=== modified file 'doc/emacs/xresources.texi'
--- a/doc/emacs/xresources.texi 2011-01-25 04:08:28 +0000
+++ b/doc/emacs/xresources.texi 2011-02-14 17:21:10 +0000
@@ -428,31 +428,22 @@
@end iftex
@example
-Emacs.pane.menubar.faceName: Courier-12
address@hidden example
-
address@hidden
-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
address@hidden:
-
address@hidden
-Emacs.pane.menubar.faceName: none
-Emacs.pane.dialog.faceName: none
address@hidden example
-
address@hidden
-To specify a non-Xft font, use @code{font}. For example:
+Emacs.pane.menubar.font: Courier-12
address@hidden example
+
address@hidden
+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.
+
address@hidden
The Lucid menus can display multilingual text in your locale with old style
fonts. For more information about fontsets see the man page for
@code{XCreateFontSet}. To enable multilingual menu text you specify a
@@ -480,7 +471,7 @@
For dialog boxes, use @samp{dialog*}:
@example
-Emacs.dialog*.faceName: Sans-12
+Emacs.dialog*.font: Sans-12
@end example
@noindent
@@ -495,8 +486,6 @@
Here is a list of the specific resources for menu bars and pop-up menus:
@table @code
address@hidden faceName
-Xft font for menu item text.
@item font
Font for menu item text.
@item fontSet
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2011-02-14 01:49:24 +0000
+++ b/etc/NEWS 2011-02-14 17:21:10 +0000
@@ -137,9 +137,8 @@
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
=== modified file 'lwlib/ChangeLog'
--- a/lwlib/ChangeLog 2011-02-13 02:07:25 +0000
+++ b/lwlib/ChangeLog 2011-02-14 17:21:10 +0000
@@ -1,3 +1,31 @@
+2011-02-14 Jan Djärv <address@hidden>
+
+ * 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 <address@hidden>
* lwlib-utils.c (index, rindex): Don't undef (neither used in lwlib/,
=== modified file 'lwlib/lwlib-Xaw.c'
--- a/lwlib/lwlib-Xaw.c 2011-02-10 05:03:29 +0000
+++ b/lwlib/lwlib-Xaw.c 2011-02-14 17:21:10 +0000
@@ -577,13 +577,20 @@
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;
=== modified file 'lwlib/xlwmenu.c'
--- a/lwlib/xlwmenu.c 2011-02-10 05:03:29 +0000
+++ b/lwlib/xlwmenu.c 2011-02-14 17:21:10 +0000
@@ -71,8 +71,6 @@
static int pointer_grabbed;
static XEvent menu_post_event;
-static XFontStruct *xlwmenu_default_font;
-
static char
xlwMenuTranslations [] =
"<BtnDown>: start()\n\
@@ -131,14 +129,12 @@
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 @@
#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 @@
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 @@
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 @@
}
#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 @@
--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 @@
;
else
#endif
+ {
+ mw->menu.font = XLoadQueryFont (display, mw->menu.fontName);
+ if (!mw->menu.font)
+ {
+ mw->menu.font = XLoadQueryFont (display, "fixed");
+ if (!mw->menu.font)
+ {
+ fprintf (stderr, "Menu font fixed not found, can't continue.\n");
+ abort ();
+ }
+ }
+ }
- if (!mw->menu.font)
- {
- if (!xlwmenu_default_font)
- xlwmenu_default_font = XLoadQueryFont (display, "fixed");
- mw->menu.font = xlwmenu_default_font;
- 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 @@
static void
XlwMenuClassInitialize (void)
{
- xlwmenu_default_font = 0;
}
static void
@@ -2126,13 +2137,13 @@
#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 @@
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 @@
}
#ifdef HAVE_XFT
- if (facename_changed (newmw, oldmw))
+ if (fontname_changed (newmw, oldmw))
{
int i;
int screen = XScreenNumberOfScreen (newmw->core.screen);
=== modified file 'lwlib/xlwmenu.h'
--- a/lwlib/xlwmenu.h 2011-01-26 08:36:39 +0000
+++ b/lwlib/xlwmenu.h 2011-02-14 17:21:10 +0000
@@ -58,10 +58,6 @@
#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"
=== modified file 'lwlib/xlwmenuP.h'
--- a/lwlib/xlwmenuP.h 2011-01-26 08:36:39 +0000
+++ b/lwlib/xlwmenuP.h 2011-02-14 17:21:10 +0000
@@ -59,11 +59,11 @@
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;
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2011-02-14 16:25:04 +0000
+++ b/src/ChangeLog 2011-02-14 17:21:10 +0000
@@ -1,3 +1,14 @@
+2011-02-14 Jan Djärv <address@hidden>
+
+ * 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 <address@hidden>
* keyboard.h: Remove obsolete comment.
=== modified file 'src/xmenu.c'
--- a/src/xmenu.c 2011-02-05 09:49:52 +0000
+++ b/src/xmenu.c 2011-02-14 17:21:10 +0000
@@ -887,31 +887,26 @@
{
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 @@
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 @@
/* 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 @@
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 @@
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;
=== modified file 'src/xrdb.c'
--- a/src/xrdb.c 2011-01-25 04:08:28 +0000
+++ b/src/xrdb.c 2011-02-14 17:21:10 +0000
@@ -546,12 +546,14 @@
#else /* not USE_MOTIF */
+ 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, "Emacs.dialog*.background: grey75");
- 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");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r103275: Use *font for Xft font names for Lucid menus and dialogs.,
Jan D. <=