changeset 9813:e33e1c6864de

(Fx_list_fonts): Don't bother to retrieve font info when there's no size_ref to compare it against.
author Karl Heuer <kwzh@gnu.org>
date Wed, 02 Nov 1994 06:18:45 +0000
parents bc352c8f079c
children 5ae33de679f6
files src/xfns.c
diffstat 1 files changed, 36 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfns.c	Wed Nov 02 04:27:27 1994 +0000
+++ b/src/xfns.c	Wed Nov 02 06:18:45 1994 +0000
@@ -2866,7 +2866,9 @@
 {
   int num_fonts;
   char **names;
+#ifndef BROKEN_XLISTFONTSWITHINFO
   XFontStruct *info;
+#endif
   XFontStruct *size_ref;
   Lisp_Object list;
   FRAME_PTR f;
@@ -2943,18 +2945,20 @@
   BLOCK_INPUT;
 
   /* Solaris 2.3 has a bug in XListFontsWithInfo.  */
-#ifdef BROKEN_XLISTFONTSWITHINFO
-  names = XListFonts (FRAME_X_DISPLAY (f),
-                      XSTRING (pattern)->data,
-                      2000, /* maxnames */
-                      &num_fonts); /* count_return */
-#else
-  names = XListFontsWithInfo (FRAME_X_DISPLAY (f),
-			      XSTRING (pattern)->data,
-			      2000, /* maxnames */
-			      &num_fonts, /* count_return */
-			      &info); /* info_return */
+#ifndef BROKEN_XLISTFONTSWITHINFO
+  if (size_ref)
+    names = XListFontsWithInfo (FRAME_X_DISPLAY (f),
+				XSTRING (pattern)->data,
+				2000, /* maxnames */
+				&num_fonts, /* count_return */
+				&info); /* info_return */
+  else
 #endif
+    names = XListFonts (FRAME_X_DISPLAY (f),
+			XSTRING (pattern)->data,
+			2000, /* maxnames */
+			&num_fonts); /* count_return */
+
   UNBLOCK_INPUT;
 
   list = Qnil;
@@ -2977,27 +2981,36 @@
       list = Qnil;
       for (i = 0; i < num_fonts; i++)
         {
-	  XFontStruct *thisinfo;
-
+	  int keeper;
+
+	  if (!size_ref)
+	    keeper = 1;
+	  else
+	    {
 #ifdef BROKEN_XLISTFONTSWITHINFO
-          BLOCK_INPUT;
-          thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f), names[i]);
-          UNBLOCK_INPUT;
+	      XFontStruct *thisinfo;
+
+	      BLOCK_INPUT;
+	      thisinfo = XLoadQueryFont (FRAME_X_DISPLAY (f), names[i]);
+	      UNBLOCK_INPUT;
+
+	      keeper = thisinfo && same_size_fonts (thisinfo, size_ref);
 #else
-	  thisinfo = &info[i];
+	      keeper = same_size_fonts (&info[i], size_ref);
 #endif
-          if (thisinfo && (! size_ref
-			   || same_size_fonts (thisinfo, size_ref)))
+	    }
+          if (keeper)
 	    list = Fcons (build_string (names[i]), list);
         }
       list = Fnreverse (list);
 
       BLOCK_INPUT;
-#ifdef BROKEN_XLISTFONTSWITHINFO
-      XFreeFontNames (names);
-#else
-      XFreeFontInfo (names, info, num_fonts);
+#ifndef BROKEN_XLISTFONTSWITHINFO
+      if (size_ref)
+	XFreeFontInfo (names, info, num_fonts);
+      else
 #endif
+	XFreeFontNames (names);
       UNBLOCK_INPUT;
     }