changeset 3397:6aa26bef0527

[xemacs-hg @ 2006-05-12 19:25:28 by stephent] Stop trashing xftFont resources. <87mzdnxd1j.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Fri, 12 May 2006 19:25:29 +0000
parents af3bfea5c60e
children b68d5faaffb0
files lwlib/ChangeLog lwlib/lwlib-fonts.h lwlib/xlwmenu.c lwlib/xlwmenuP.h lwlib/xlwtabs.c lwlib/xlwtabs.h lwlib/xlwtabsP.h
diffstat 7 files changed, 79 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/ChangeLog	Thu May 11 21:50:58 2006 +0000
+++ b/lwlib/ChangeLog	Fri May 12 19:25:29 2006 +0000
@@ -1,3 +1,23 @@
+2006-05-12  Stephen J. Turnbull  <stephen@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.
+
 2006-04-24  Jerry James  <james@xemacs.org>
 
 	* lwlib-Xaw.c (lw_debug_print_class_resources): Casting from a
--- a/lwlib/lwlib-fonts.h	Thu May 11 21:50:58 2006 +0000
+++ b/lwlib/lwlib-fonts.h	Fri May 12 19:25:29 2006 +0000
@@ -48,9 +48,11 @@
 #ifdef USE_XFT
 #ifndef XtNxftFont
 #define XtNxftFont "xftFont"
+#define XtCXftFont "XftFont"
 #endif
-#ifndef XtCXftFont
-#define XtCXftFont "XftFont"
+#ifndef XtNfcFont
+#define XtNfcFontName "fcFontName"
+#define XtCFcFontName "FcFontName"
 #endif
 #endif /* USE_XFT */
 
--- a/lwlib/xlwmenu.c	Thu May 11 21:50:58 2006 +0000
+++ b/lwlib/xlwmenu.c	Fri May 12 19:25:29 2006 +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);
--- a/lwlib/xlwmenuP.h	Thu May 11 21:50:58 2006 +0000
+++ b/lwlib/xlwmenuP.h	Fri May 12 19:25:29 2006 +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
--- a/lwlib/xlwtabs.c	Thu May 11 21:50:58 2006 +0000
+++ b/lwlib/xlwtabs.c	Fri May 12 19:25:29 2006 +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
+	      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 > 2)
+	      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,
--- a/lwlib/xlwtabs.h	Thu May 11 21:50:58 2006 +0000
+++ b/lwlib/xlwtabs.h	Fri May 12 19:25:29 2006 +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:
--- a/lwlib/xlwtabsP.h	Thu May 11 21:50:58 2006 +0000
+++ b/lwlib/xlwtabsP.h	Fri May 12 19:25:29 2006 +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
  *
  ****************************************************************/