changeset 3065:fff06093b756

* xfns.c (Fx_list_fonts): New function. (same_size_fonts): Function moved here from xfaces.c. (face_name_id_number): Add extern declaration for this. * xfaces.c (same_size_fonts): Moved to xfns.c. Left an extern declaration behind. (face_name_id_number): Make this externally visible, and make the FRAME argument a FRAME_PTR, not a Lisp_Object. (compute_char_face): Call face_name_id_number properly. * xfaces.c (unload_color): Don't free the pixel for now. * xfaces.c (merge_faces): You can't tell if a font is a character-cell font or not by testing whether or not it has a per_char table. They all do.
author Jim Blandy <jimb@redhat.com>
date Tue, 25 May 1993 06:59:12 +0000
parents fa5466904709
children 039cbddadc51
files src/xfaces.c
diffstat 1 files changed, 20 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Tue May 25 06:38:43 1993 +0000
+++ b/src/xfaces.c	Tue May 25 06:59:12 1993 +0000
@@ -136,6 +136,10 @@
 /* The number of the face to use to indicate the region.  */
 int region_face;
 
+/* Return non-zero if FONT1 and FONT2 have the same size bounding box.
+   We assume that they're both character-cell fonts.  */
+extern int same_size_fonts ();
+
 /* This is what appears in a slot in a face to signify that the face
    does not specify that display aspect.  */
 #define FACE_DEFAULT (~0)
@@ -143,7 +147,7 @@
 Lisp_Object Qface, Qwindow, Qpriority;
 
 static void build_face ();
-static Lisp_Object face_name_id_number ();
+int face_name_id_number ();
 
 struct face *intern_face ();
 static void ensure_face_ready ();
@@ -406,6 +410,13 @@
      struct frame *f;
      Pixel pixel;
 {
+  /* Since faces get built by copying parameters from other faces, the
+     allocation counts for the colors get all screwed up.  I don't see
+     any solution that will take less than 10 minutes, and it's better
+     to have a color leak than a crash, so I'm just dyking this out.
+     This isn't really a color leak, anyway - if we ask for it again,
+     we'll get the same pixel.  */
+#if 0
   Colormap cmap;
   Display *dpy = x_current_display;
   if (pixel == FACE_DEFAULT
@@ -416,6 +427,7 @@
   BLOCK_INPUT;
   XFreeColors (dpy, cmap, &pixel, 1, 0);
   UNBLOCK_INPUT;
+#endif
 }
 
 /* Initializing face arrays for frames. */
@@ -552,21 +564,6 @@
 
 /* Computing faces appropriate for a given piece of text in a buffer.  */
 
-/* Return non-zero if FONT1 and FONT2 have the same size bounding box.
-   We assume that they're both character-cell fonts.  */
-static int
-same_size_fonts (font1, font2)
-     XFontStruct *font1, *font2;
-{
-  XCharStruct *bounds1 = &font1->min_bounds;
-  XCharStruct *bounds2 = &font2->min_bounds;
-
-  return (bounds1->width == bounds2->width
-	  && bounds1->ascent == bounds2->ascent
-	  && bounds1->descent == bounds2->descent);
-}
-
-
 /* Modify face TO by copying from FROM all properties which have
    nondefault settings.  */
 static void 
@@ -575,7 +572,6 @@
 {
   /* Only merge the font if it's the same size as the base font.  */
   if (from->font != (XFontStruct *) FACE_DEFAULT
-      && ! from->font->per_char
       && same_size_fonts (from->font, to->font))
     to->font = from->font;
   if (from->foreground != FACE_DEFAULT)
@@ -689,7 +685,7 @@
 
   if (!NILP (prop))
     {
-      facecode = face_name_id_number (frame, prop);
+      facecode = face_name_id_number (f, prop);
       if (facecode >= 0 && facecode < FRAME_N_FACES (f)
 	  && FRAME_FACES (f) [facecode] != 0)
 	merge_faces (FRAME_FACES (f) [facecode], &face);
@@ -746,7 +742,7 @@
 	  Lisp_Object oend;
 	  int oendpos;
 
-	  facecode = face_name_id_number (frame, prop);
+	  facecode = face_name_id_number (f, prop);
 	  if (facecode >= 0 && facecode < FRAME_N_FACES (f)
 	      && FRAME_FACES (f) [facecode] != 0)
 	    merge_faces (FRAME_FACES (f) [facecode], &face);
@@ -949,14 +945,14 @@
    but it's as easy to use the "right" frame to look it up
    as to use any other one.)  */
 
-static Lisp_Object
-face_name_id_number (frame, name)
-     Lisp_Object frame, name;
+int
+face_name_id_number (f, name)
+     FRAME_PTR f;
+     Lisp_Object name;
 {
   Lisp_Object tem;
 
-  CHECK_FRAME (frame, 0);
-  tem = Fcdr (Fassq (name, XFRAME (frame)->face_alist));
+  tem = Fcdr (Fassq (name, f->face_alist));
   if (NILP (tem))
     return 0;
   CHECK_VECTOR (tem, 0);