]> code.delx.au - gnu-emacs/blobdiff - src/xfaces.c
Fix for Bug#5984.
[gnu-emacs] / src / xfaces.c
index 2b6df6406f59f157284ec87bef957c7738a13382..6bde1c121d2c3942094359e91fc4bbfbc15572ad 100644 (file)
@@ -1,6 +1,6 @@
 /* xfaces.c -- "Face" primitives.
    Copyright (C) 1993, 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+                 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1745,8 +1745,8 @@ the face font sort order.  */)
      (family, frame)
      Lisp_Object family, frame;
 {
-  Lisp_Object font_spec, vec;
-  int i, nfonts;
+  Lisp_Object font_spec, list, *drivers, vec;
+  int i, nfonts, ndrivers;
   Lisp_Object result;
 
   if (NILP (frame))
@@ -1759,32 +1759,38 @@ the face font sort order.  */)
       CHECK_STRING (family);
       font_parse_family_registry (family, Qnil, font_spec);
     }
-  vec = font_list_entities (frame, font_spec);
-  nfonts = ASIZE (vec);
-  if (nfonts == 0)
+
+  list = font_list_entities (frame, font_spec);
+  if (NILP (list))
     return Qnil;
-  if (nfonts > 1)
-    {
-      for (i = 0; i < 4; i++)
-       switch (font_sort_order[i])
-         {
-         case XLFD_SWIDTH:
-           font_props_for_sorting[i] = FONT_WIDTH_INDEX; break;
-         case XLFD_POINT_SIZE:
-           font_props_for_sorting[i] = FONT_SIZE_INDEX; break;
-         case XLFD_WEIGHT:
-           font_props_for_sorting[i] = FONT_WEIGHT_INDEX; break;
-         default:
-           font_props_for_sorting[i] = FONT_SLANT_INDEX; break;
-         }
-      font_props_for_sorting[i++] = FONT_FAMILY_INDEX;
-      font_props_for_sorting[i++] = FONT_FOUNDRY_INDEX;
-      font_props_for_sorting[i++] = FONT_ADSTYLE_INDEX;
-      font_props_for_sorting[i++] = FONT_REGISTRY_INDEX;
 
-      qsort (XVECTOR (vec)->contents, nfonts, sizeof (Lisp_Object),
-            compare_fonts_by_sort_order);
-    }
+  /* Sort the font entities.  */
+  for (i = 0; i < 4; i++)
+    switch (font_sort_order[i])
+      {
+      case XLFD_SWIDTH:
+       font_props_for_sorting[i] = FONT_WIDTH_INDEX; break;
+      case XLFD_POINT_SIZE:
+       font_props_for_sorting[i] = FONT_SIZE_INDEX; break;
+      case XLFD_WEIGHT:
+       font_props_for_sorting[i] = FONT_WEIGHT_INDEX; break;
+      default:
+       font_props_for_sorting[i] = FONT_SLANT_INDEX; break;
+      }
+  font_props_for_sorting[i++] = FONT_FAMILY_INDEX;
+  font_props_for_sorting[i++] = FONT_FOUNDRY_INDEX;
+  font_props_for_sorting[i++] = FONT_ADSTYLE_INDEX;
+  font_props_for_sorting[i++] = FONT_REGISTRY_INDEX;
+
+  ndrivers = XINT (Flength (list));
+  drivers  = alloca (sizeof (Lisp_Object) * ndrivers);
+  for (i = 0; i < ndrivers; i++, list = XCDR (list))
+    drivers[i] = XCAR (list);
+  vec = Fvconcat (ndrivers, drivers);
+  nfonts = ASIZE (vec);
+
+  qsort (XVECTOR (vec)->contents, nfonts, sizeof (Lisp_Object),
+        compare_fonts_by_sort_order);
 
   result = Qnil;
   for (i = nfonts - 1; i >= 0; --i)
@@ -2885,6 +2891,7 @@ Value is a vector of face attributes.  */)
 DEFUN ("internal-lisp-face-p", Finternal_lisp_face_p,
        Sinternal_lisp_face_p, 1, 2, 0,
        doc: /* Return non-nil if FACE names a face.
+FACE should be a symbol or string.
 If optional second argument FRAME is non-nil, check for the
 existence of a frame-local face with name FACE on that frame.
 Otherwise check for the existence of a global face.  */)
@@ -4085,7 +4092,7 @@ face_attr_equal_p (v1, v2)
 
       return bcmp (SDATA (v1), SDATA (v2), SBYTES (v1)) == 0;
 
-    case Lisp_Int:
+    case_Lisp_Int:
     case Lisp_Symbol:
       return 0;
 
@@ -6952,7 +6959,7 @@ that number of fonts when searching for a matching font.  */);
 This stipple pattern is used on monochrome displays
 instead of shades of gray for a face background color.
 See `set-face-stipple' for possible values for this variable.  */);
-  Vface_default_stipple = build_string ("gray3");
+  Vface_default_stipple = make_pure_c_string ("gray3");
 
   DEFVAR_LISP ("tty-defined-color-alist", &Vtty_defined_color_alist,
    doc: /* An alist of defined terminal colors and their RGB values.  */);