changeset 28793:e56af637f7a2

(x_produce_glyphs) <composite chars>: Handle case that x_per_char_metric returns null.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 03 May 2000 11:39:25 +0000
parents f870c858cfdf
children 2274787ba380
files src/xterm.c
diffstat 1 files changed, 42 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Wed May 03 10:45:51 2000 +0000
+++ b/src/xterm.c	Wed May 03 11:39:25 2000 +0000
@@ -2049,16 +2049,30 @@
 	  int font_descent = font->descent - boff;
 	  /* Bounding box of the overall glyphs.  */
 	  int leftmost, rightmost, lowest, highest;
-	  int i;
+	  int i, width, ascent, descent;
 
 	  cmp->font = (void *) font;
 
 	  /* Initialize the bounding box.  */
 	  pcm = x_per_char_metric (font, &char2b);
+	  if (pcm)
+	    {
+	      width = pcm->width;
+	      ascent = pcm->ascent;
+	      descent = pcm->descent;
+	    }
+	  else
+	    {
+	      width = FONT_WIDTH (font);
+	      ascent = font->ascent;
+	      descent = font->descent;
+	    }
+	  
+	  rightmost = width;
+	  lowest = - descent + boff;
+	  highest = ascent + boff;
 	  leftmost = 0;
-	  rightmost = pcm->width;
-	  lowest = - pcm->descent + boff;
-	  highest = pcm->ascent + boff;
+	  
 	  if (font_info
 	      && font_info->default_ascent
 	      && CHAR_TABLE_P (Vuse_default_ascent)
@@ -2099,26 +2113,37 @@
 		}
 
 	      pcm = x_per_char_metric (font, &char2b);
+	      if (pcm)
+		{
+		  width = pcm->width;
+		  ascent = pcm->ascent;
+		  descent = pcm->descent;
+		}
+	      else
+		{
+		  width = FONT_WIDTH (font);
+		  ascent = font->ascent;
+		  descent = font->descent;
+		}
 
 	      if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS)
 		{
 		  /* Relative composition with or without
 		     alternate chars.  */
-		  left = (leftmost + rightmost - pcm->width) / 2;
-		  btm = - pcm->descent + boff;
+		  left = (leftmost + rightmost - width) / 2;
+		  btm = - descent + boff;
 		  if (font_info && font_info->relative_compose
 		      && (! CHAR_TABLE_P (Vignore_relative_composition)
 			  || NILP (Faref (Vignore_relative_composition,
 					  make_number (ch)))))
 		    {
 
-		      if (- pcm->descent
-			  >= font_info->relative_compose)
+		      if (- descent >= font_info->relative_compose)
 			/* One extra pixel between two glyphs.  */
 			btm = highest + 1;
-		      else if (pcm->ascent <= 0)
+		      else if (ascent <= 0)
 			/* One extra pixel between two glyphs.  */
-			btm = lowest - 1 - pcm->ascent - pcm->descent;
+			btm = lowest - 1 - ascent - descent;
 		    }
 		}
 	      else
@@ -2147,23 +2172,23 @@
 
 		  left = (leftmost
 			  + grefx * (rightmost - leftmost) / 2
-			  - nrefx * pcm->width / 2);
+			  - nrefx * width / 2);
 		  btm = ((grefy == 0 ? highest
 			  : grefy == 1 ? 0
 			  : grefy == 2 ? lowest
 			  : (highest + lowest) / 2)
-			 - (nrefy == 0 ? pcm->ascent + pcm->descent
-			    : nrefy == 1 ? pcm->descent - boff
+			 - (nrefy == 0 ? ascent + descent
+			    : nrefy == 1 ? descent - boff
 			    : nrefy == 2 ? 0
-			    : (pcm->ascent + pcm->descent) / 2));
+			    : (ascent + descent) / 2));
 		}
 
 	      cmp->offsets[i * 2] = left;
-	      cmp->offsets[i * 2 + 1] = btm + pcm->descent;
+	      cmp->offsets[i * 2 + 1] = btm + descent;
 
 	      /* Update the bounding box of the overall glyphs. */
-	      right = left + pcm->width;
-	      top = btm + pcm->descent + pcm->ascent;
+	      right = left + width;
+	      top = btm + descent + ascent;
 	      if (left < leftmost)
 		leftmost = left;
 	      if (right > rightmost)