changeset 6784:d41c216ccd27

(frame_update_line_height): Check param_faces[i] not null.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Apr 1994 01:19:57 +0000
parents 3122395ded44
children 121f2c5eba5e
files src/xfaces.c
diffstat 1 files changed, 31 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Sun Apr 10 00:38:14 1994 +0000
+++ b/src/xfaces.c	Sun Apr 10 01:19:57 1994 +0000
@@ -636,10 +636,11 @@
     FRAME_PARAM_FACES (f) [id] = allocate_face ();
 }
 
-/* Computing faces appropriate for a given piece of text in a buffer.  */
+/* Return non-zero if FONT1 and FONT2 have the same width.
+   We do not check the height, because we can now deal with
+   different heights.
+   We assume that they're both character-cell fonts.  */
 
-/* Return non-zero if FONT1 and FONT2 have the same size bounding box.
-   We assume that they're both character-cell fonts.  */
 int
 same_size_fonts (font1, font2)
      XFontStruct *font1, *font2;
@@ -648,15 +649,6 @@
   XCharStruct *bounds2 = &font2->min_bounds;
 
   return (bounds1->width == bounds2->width);
-/* Checking the following caused bad results in some cases
-   when fonts that should be the same size
-   actually have very slightly different size.
-   It is possible that this reintroduces the bug whereby line positions
-   were not right.  However, the right way to fix that is to change xterm.c
-   so that the vertical positions of lines
-   depend only on the height of the frame's font.
-	  && bounds1->ascent == bounds2->ascent
-	  && bounds1->descent == bounds2->descent);  */
 }
 
 /* Update the line_height of frame F according to the biggest font in
@@ -670,7 +662,8 @@
   int biggest = FONT_HEIGHT (f->display.x->font);
 
   for (i = 0; i < f->display.x->n_param_faces; i++)
-    if (f->display.x->param_faces[i]->font != (XFontStruct *) FACE_DEFAULT)
+    if (f->display.x->param_faces[i] != 0
+	&& f->display.x->param_faces[i]->font != (XFontStruct *) FACE_DEFAULT)
       {
 	int height = FONT_HEIGHT (f->display.x->param_faces[i]->font);
 	if (height > biggest)
@@ -683,14 +676,16 @@
   f->display.x->line_height = biggest;
   x_set_window_size (f, 0, f->width, f->height);
 }
-
+
 /* Modify face TO by copying from FROM all properties which have
    nondefault settings.  */
+
 static void 
 merge_faces (from, to)
      struct face *from, *to;
 {
-  /* Only merge the font if it's the same size as the base font.  */
+  /* Only merge the font if it's the same width as the base font.
+     Otherwise ignore it, since we can't handle it properly.  */
   if (from->font != (XFontStruct *) FACE_DEFAULT
       && same_size_fonts (from->font, to->font))
     to->font = from->font;
@@ -706,6 +701,7 @@
 
 /* Set up the basic set of facial parameters, based on the frame's
    data; all faces are deltas applied to this.  */
+
 static void
 compute_base_face (f, face)
      FRAME_PTR f;
@@ -724,7 +720,26 @@
   face->cached_index = -1;
 }
 
+/* Return the face ID to use to display a special glyph which selects
+   FACE_CODE as the face ID, assuming that ordinarily the face would
+   be CURRENT_FACE.  F is the frame.  */
 
+int
+compute_glyph_face (f, face_code, current_face)
+     struct frame *f;
+     int face_code, current_face;
+{
+  struct face face;
+
+  face = *FRAME_COMPUTED_FACES (f)[current_face];
+
+  if (face_code >= 0 && face_code < FRAME_N_PARAM_FACES (f)
+      && FRAME_PARAM_FACES (f) [face_code] != 0)
+    merge_faces (FRAME_PARAM_FACES (f) [face_code], &face);
+
+  return intern_computed_face (f, &face);
+}
+
 /* Return the face ID associated with a buffer position POS.
    Store into *ENDPTR the position at which a different face is needed.
    This does not take account of glyphs that specify their own face codes.
@@ -861,28 +876,7 @@
 
   return intern_computed_face (f, &face);
 }
-
-/* Return the face ID to use to display a special glyph which selects
-   FACE_CODE as the face ID, assuming that ordinarily the face would
-   be CURRENT_FACE.  F is the frame.  */
-
-int
-compute_glyph_face (f, face_code, current_face)
-     struct frame *f;
-     int face_code, current_face;
-{
-  struct face face;
-
-  face = *FRAME_COMPUTED_FACES (f)[current_face];
-
-  if (face_code >= 0 && face_code < FRAME_N_PARAM_FACES (f)
-      && FRAME_PARAM_FACES (f) [face_code] != 0)
-    merge_faces (FRAME_PARAM_FACES (f) [face_code], &face);
-
-  return intern_computed_face (f, &face);
-}
-
-
+
 /* Recompute the GC's for the default and modeline faces.
    We call this after changing frame parameters on which those GC's
    depend.  */