APPROVE COMMIT 21.5
Not for 21.4
This should fix the problem that Mats Lidell and perhaps others were
experiencing with XEmacs ignoring the tabs resources. The same
problem might have affected the menubar under some circumstances,
although I haven't actually observed that.
**** This patch creates a new resource category, fcFontName. Any ****
**** resources that have been using xftFont need to change to ****
**** fcFontName (resource class FcFontName). ****
This is the case for both the menu widget and the tabs widget.
I apologize for the inconvenience, but avoiding it would take
substantial effort I can't afford right now. The problem is that
there is no Xt resource converter for XftFonts (I've got a draft in a
workspace but it's entirely untested, and too risky for even the beta
series). So I had a kludge where the xftFont name was transformed
into a XftFont* in the widget initialization. Unfortunately, the
xftFont resource is also used in the glyphs and frames code, so the
initialized resources were getting trashed (actually, we're probably
lucky there was no crash). Since xftFont is the natural name for the
XftFont * representation, and we'll eventually have an automatic
converter, it seems best to reserve it for now.
You will have to switch back, once the converter is in place, I'm
afraid.
Index: lwlib/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/ChangeLog,v
retrieving revision 1.86
diff -u -r1.86 ChangeLog
--- lwlib/ChangeLog 2 May 2006 15:30:31 -0000 1.86
+++ lwlib/ChangeLog 12 May 2006 19:04:06 -0000
@@ -0,0 +1,20 @@
+2006-05-12 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ Make fcFontName and xftFont separate resources.
+
+ * lwlib-fonts.h (XtNfcFontName, XtCFcFontName): New macros.
+ (XtNxftFont, XtCXftFont): Coalesce the conditional definitions.
+
+ * xlwmenuP.h (XlwMenuPart):
+ * xlwtabsP.h (TabsPart):
+ Rename renderFontSpec member to fcFontName.
+
+ * xlwmenu.c (XlwMenuResources):
+ * xlwtabs.c (resources):
+ Add a record for fcFontName.
+
+ * xlwtabs.c (TabsInit): Use the fcFontName resource, not xftFont.
+
+ * xlwtabs.c (DrawTab,TabLayout,TabsGeometryManager): Improve
+ diagnostics.
+
Index: lwlib/lwlib-fonts.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/lwlib-fonts.h,v
retrieving revision 1.2
diff -u -r1.2 lwlib-fonts.h
--- lwlib/lwlib-fonts.h 26 Nov 2005 11:45:59 -0000 1.2
+++ lwlib/lwlib-fonts.h 12 May 2006 19:04:06 -0000
@@ -48,9 +48,11 @@
#ifdef USE_XFT
#ifndef XtNxftFont
#define XtNxftFont "xftFont"
-#endif
-#ifndef XtCXftFont
#define XtCXftFont "XftFont"
+#endif
+#ifndef XtNfcFont
+#define XtNfcFontName "fcFontName"
+#define XtCFcFontName "FcFontName"
#endif
#endif /* USE_XFT */
Index: lwlib/xlwmenu.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/xlwmenu.c,v
retrieving revision 1.40
diff -u -r1.40 xlwmenu.c
--- lwlib/xlwmenu.c 2 May 2006 15:30:32 -0000 1.40
+++ lwlib/xlwmenu.c 12 May 2006 19:04:07 -0000
@@ -93,9 +93,13 @@
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
offset(menu.font), XtRString, (XtPointer) "XtDefaultFont"},
#ifdef USE_XFT_MENUBARS
- {XtNxftFont, XtCXftFont, XtRString, sizeof (String),
- offset(menu.renderFontSpec),
+ {XtNfcFontName, XtCFcFontName, XtRString, sizeof (String),
+ offset(menu.fcFontName),
XtRString, (XtPointer) "Helvetica-12:bold"},
+ /* #### This needs to be fixed to give a proper type and converter for
+ XftFonts. See also xlwtabs.c. */
+ {XtNxftFont, XtCXftFont, XtRPointer, sizeof(XtPointer),
+ offset(menu.renderFont), XtRPointer, (XtPointer) NULL },
#endif
# ifdef USE_XFONTSET
/* #### Consider using the same method as for Motif; see the comment in
@@ -3241,7 +3245,7 @@
conversion function
*/
mw->menu.renderFont =
- xft_open_font_by_name (XtDisplay (mw), mw->menu.renderFontSpec);
+ xft_open_font_by_name (XtDisplay (mw), mw->menu.fcFontName);
#endif
make_drawing_gcs (mw);
Index: lwlib/xlwmenuP.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/xlwmenuP.h,v
retrieving revision 1.5
diff -u -r1.5 xlwmenuP.h
--- lwlib/xlwmenuP.h 26 Nov 2005 11:46:00 -0000 1.5
+++ lwlib/xlwmenuP.h 12 May 2006 19:04:07 -0000
@@ -34,8 +34,7 @@
#else
XFontStruct * font;
#ifdef USE_XFT_MENUBARS
- /* #### Fix naming convention here */
- String renderFontSpec;
+ String fcFontName;
XftFont *renderFont;
#endif
# ifdef USE_XFONTSET
Index: lwlib/xlwtabs.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/xlwtabs.c,v
retrieving revision 1.7
diff -u -r1.7 xlwtabs.c
--- lwlib/xlwtabs.c 2 May 2006 15:30:32 -0000 1.7
+++ lwlib/xlwtabs.c 12 May 2006 19:04:07 -0000
@@ -150,10 +150,14 @@
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
offset(font), XtRString, (XtPointer) XtDefaultFont},
#ifdef USE_XFT_TABS
- /* #### Maybe use "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1" here? */
- {XtNxftFont, XtCXftFont, XtRString, sizeof (String),
- offset(renderFontSpec), XtRString,
- (XtPointer) "AirCut-16" /* XtDefaultFont */},
+ /* #### Maybe use "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1" here?
+ or XtDefaultFont? */
+ {XtNfcFontName, XtCFcFontName, XtRString, sizeof(String),
+ offset(fcFontName), XtRString, (XtPointer) "AirCut-16" },
+ /* #### This needs to be fixed to give a proper type and converter for
+ XftFonts. See also xlwmenu.c. */
+ {XtNxftFont, XtCXftFont, XtRPointer, sizeof(XtPointer),
+ offset(renderFont), XtRPointer, (XtPointer) NULL },
#endif
{XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
offset(internalWidth), XtRImmediate, (XtPointer)4 },
@@ -481,7 +485,7 @@
*/
newTw->tabs.renderFont =
xft_open_font_by_name (XtDisplay ((Widget) newTw),
- newTw->tabs.renderFontSpec);
+ newTw->tabs.fcFontName);
if (newTw->tabs.renderFont != NULL)
#if XFT_USE_HEIGHT_NOT_ASCENT_DESCENT
newTw->tabs.tab_height += newTw->tabs.renderFont->height;
@@ -1089,7 +1093,7 @@
get triggered forever after */
int n = control->composite.num_children;
ah = control->tabs.tab_height;
- if (debug_tabs > 0)
+ if (debug_tabs > 1)
fprintf (stderr, "Kludging around %d != 1 rows,"
" #children = %d, total height %d, using %d.\n",
check_nrows, n, th, ah);
@@ -1616,7 +1620,7 @@
GC gc ;
int x,y ;
- if (debug_tabs > 1) fprintf (stderr, "DrawTab called.\n");
+ if (debug_tabs > 2) fprintf (stderr, "DrawTab called.\n");
if( !XtIsRealized((Widget)tw))
return ;
@@ -1712,7 +1716,6 @@
(int) strlen (lbl), &glyphinfo);
/* #### unnecessary? for the moment, give visual extent */
/* draw background rect */
-#if 1
if (debug_tabs > 2)
{
fprintf (stderr, "background color: pixel=%08lx, r=%04x,"
@@ -1725,19 +1728,16 @@
glyphinfo.x, glyphinfo.y, glyphinfo.xOff,
glyphinfo.yOff, glyphinfo.width, glyphinfo.height);
}
- XftDrawRect (xftDraw, &colorDBG,
- /* left, top, width, height */
- x+tab->tabs.l_x-glyphinfo.x,
- y+tab->tabs.l_y-glyphinfo.y,
- glyphinfo.width, glyphinfo.height);
-#endif
- /* draw text */
if (debug_tabs > 2)
+ XftDrawRect (xftDraw, &colorDBG,
+ /* left, top, width, height */
+ x+tab->tabs.l_x-glyphinfo.x,
+ y+tab->tabs.l_y-glyphinfo.y,
+ glyphinfo.width, glyphinfo.height);
+
+ /* draw text */
+ if (debug_tabs > 1)
{
- FcValue name;
- FcValue size;
- FcPatternGet (renderFont->pattern, FC_FAMILY, 0, &name);
- FcPatternGet (renderFont->pattern, FC_SIZE, 0, &size);
fprintf (stderr, "label: %s.\n", lbl);
fprintf (stderr, "foreground color: pixel=%08lx, r=%04x,"
" g=%04x, b=%04x, alpha=%04x.\n",
@@ -1747,6 +1747,13 @@
" yOffset=%d, height=%d, width=%d.\n",
glyphinfo.x, glyphinfo.y, glyphinfo.xOff,
glyphinfo.yOff, glyphinfo.height, glyphinfo.width);
+ }
+ if (debug_tabs > 0)
+ {
+ FcValue name;
+ FcValue size;
+ FcPatternGet (renderFont->pattern, FC_FAMILY, 0, &name);
+ FcPatternGet (renderFont->pattern, FC_SIZE, 0, &size);
fprintf (stderr, "font: name=%s-%.1f,"
" height=%d, ascent=%d, descent=%d.\n",
name.u.s, size.u.d, renderFont->height,
@@ -2065,11 +2072,11 @@
/* If wid or hgt is 0, we want to guess our own dimensions.
Currently the guessing functions are broken....
#### When PreferredSize*() get fixed, fix this too. */
- if (debug_tabs > 0)
+ if (debug_tabs > 1)
fprintf (stderr, "arg=%d,", wid);
wid = (wid ? wid : tw->core.width) - INDENT ;
hgt = hgt ? hgt : tw->core.height;
- if (debug_tabs > 0)
+ if (debug_tabs > 1)
fprintf (stderr, "wid=%d: x,w,y=", wid);
for(i=num_children, childP=tw->composite.children; --i >= 0; ++childP)
if( XtIsManaged(*childP) )
@@ -2077,7 +2084,7 @@
tab = (TabsConstraints) (*childP)->core.constraints ;
w = tab->tabs.width ;
- if (debug_tabs > 0)
+ if (debug_tabs > 1)
fprintf (stderr, "%d,%d,%d;", x, w, y);
if( x + w > wid ) { /* new row */
/* #### algorithm is not robust to wid < child's width */
@@ -2100,7 +2107,7 @@
tab->tabs.visible = 1;
}
- if (debug_tabs > 0)
+ if (debug_tabs > 1)
fprintf (stderr, "\n");
/* If there was only one row, increase the height by TABDELTA */
if( ++display_rows == 1 )
@@ -2127,7 +2134,7 @@
tw->tabs.realRows = row;
}
- if (debug_tabs > 0 && (row > 1 || display_rows > 1))
+ if (debug_tabs > 1 && (row > 1 || display_rows > 1))
fprintf (stderr, "tab: %d display rows, #children = %d,"
" total height %d, total rows %d%s.\n",
display_rows, num_children, y, row,
Index: lwlib/xlwtabs.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/xlwtabs.h,v
retrieving revision 1.2
diff -u -r1.2 xlwtabs.h
--- lwlib/xlwtabs.h 12 Apr 2001 18:21:57 -0000 1.2
+++ lwlib/xlwtabs.h 12 May 2006 19:04:07 -0000
@@ -44,16 +44,18 @@
Name Class RepType Default Value
---- ----- ------- -------------
font Font XFontStruct* XtDefaultFont
- internalWidth Width Dimension 4 *1
- internalHeight Height Dimension 2 *1
- topWidget TopWidget Widget *2
- callback Callback XtCallbackList NULL *3
- popdownCallback Callback XtCallbackList NULL *4
- selectInsensitive SelectInsensitive Boolean True *5
- beNiceToColormap BeNiceToColormap Boolean False *6
+ fcFontName FcFontName String AirCut-16 *0
+ xftFont XftFont XtPointer NULL *8
+ internalWidth Width Dimension 4 *1
+ internalHeight Height Dimension 2 *1
+ topWidget TopWidget Widget *2
+ callback Callback XtCallbackList NULL *3
+ popdownCallback Callback XtCallbackList NULL *4
+ selectInsensitive SelectInsensitive Boolean True *5
+ beNiceToColormap BeNiceToColormap Boolean False *6
topShadowContrast TopShadowContrast int 20
bottomShadowContrast BottomShadowContrast int 40
- insensitiveContrast InsensitiveContrast int 33 *7
+ insensitiveContrast InsensitiveContrast int 33 *7
background Background Pixel XtDefaultBackground
border BorderColor Pixel XtDefaultForeground
@@ -70,6 +72,7 @@
Notes:
+ 0 this is a joke, it will be changed.
1 internalWidth, internalHeight specify the margins around the text
in the tabs.
2 topWidget identifies the widget which is currently visible.
@@ -82,7 +85,8 @@
be selected anyway.
6 BeNiceToColormap causes the Tabs widget to use fewer colors.
7 InsensitiveContrast sets the contrast used for labels of insensitive widgets.
-
+ 8 fcFontName and xftFont are separate resources because there is not yet
+ registered representation and converter for XftFonts.
*/
/* Constraint parameters:
Index: lwlib/xlwtabsP.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/xlwtabsP.h,v
retrieving revision 1.3
diff -u -r1.3 xlwtabsP.h
--- lwlib/xlwtabsP.h 26 Nov 2005 11:46:00 -0000 1.3
+++ lwlib/xlwtabsP.h 12 May 2006 19:04:07 -0000
@@ -74,8 +74,8 @@
/* resources */
XFontStruct *font ;
#ifdef USE_XFT_TABS
- String renderFontSpec;
- XftFont *renderFont;
+ XftFont *renderFont;
+ String fcFontName;
#endif
Dimension internalHeight, internalWidth ;
Widget topWidget ;
@@ -122,7 +122,7 @@
/****************************************************************
*
- * constraint record declaration
+ * Constraint record declaration
*
****************************************************************/
--
Graduate School of Systems and Information Engineering University of Tsukuba
http://turnbull.sk.tsukuba.ac.jp/ Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Economics of Information Communication and Computation Systems
Experimental Economics, Microeconomic Theory, Game Theory