? pango/Out.ps
? pango/fonts.s
? pango/pango-glyph-item.c.good
? pango/pangofc-font.E
? pango/pangofc-font.s
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/pango/ChangeLog,v
retrieving revision 1.716
diff -u -p -r1.716 ChangeLog
--- ChangeLog	2 Jun 2003 18:15:11 -0000	1.716
+++ ChangeLog	4 Jun 2003 20:39:52 -0000
@@ -1,3 +1,9 @@
+Wed Jun  4 14:32:47 2003  Owen Taylor  <otaylor@redhat.com>
+
+	* pango/glyphstring.c (pango_glyph_string_extents_range): 
+	Improve handling of empty ink rectangles; rework for
+	simplicity.
+
 Mon Jun  2 10:43:15 PDT 2003 Keith Packard <keithp@keithp.com
 
 	* pango/pangoxft-font.c (pango_xft_font_real_get_kerning):
Index: pango/glyphstring.c
===================================================================
RCS file: /cvs/gnome/pango/pango/glyphstring.c,v
retrieving revision 1.16
diff -u -p -r1.16 glyphstring.c
--- pango/glyphstring.c	26 Nov 2002 01:47:56 -0000	1.16
+++ pango/glyphstring.c	4 Jun 2003 20:39:52 -0000
@@ -149,27 +149,30 @@ pango_glyph_string_extents_range (PangoG
   int x_pos = 0;
   int i;
 
+  /* Note that the handling of empty rectangles for ink
+   * and logical rectangles is different. A zero-height ink
+   * rectangle makes no contribution to the overall ink rect,
+   * while a zero-height logical rect still reserves horizontal
+   * width. Also, we may return zero-width, positive height
+   * logical rectangles, while we'll never do that for the
+   * ink rect.
+   */
   g_return_if_fail (start <= end);
 
-  if (end - start == 0)
+  if (ink_rect)
     {
-      if (ink_rect)
-	{
-	  ink_rect->x = 0;
-	  ink_rect->y = 0;
-	  ink_rect->width = 0;
-	  ink_rect->height = 0;
-	}
-      
-      if (logical_rect)
-	{
-	  logical_rect->x = 0;
-	  logical_rect->y = 0;
-	  logical_rect->width = 0;
-	  logical_rect->height = 0;
-	}
-
-      return;
+      ink_rect->x = 0;
+      ink_rect->y = 0;
+      ink_rect->width = 0;
+      ink_rect->height = 0;
+    }
+  
+  if (logical_rect)
+    {
+      logical_rect->x = 0;
+      logical_rect->y = 0;
+      logical_rect->width = 0;
+      logical_rect->height = 0;
     }
   
   for (i = start; i < end; i++)
@@ -179,52 +182,55 @@ pango_glyph_string_extents_range (PangoG
       
       PangoGlyphGeometry *geometry = &glyphs->glyphs[i].geometry;
 
-      if (i == start)
-	{
-	  pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph,
-                                        ink_rect, logical_rect);
+      pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph,
+				    ink_rect ? &glyph_ink : NULL,
+				    logical_rect ? &glyph_logical : NULL);
 
-	  if (logical_rect)
+      if (ink_rect && glyph_ink.width != 0 && glyph_ink.height != 0)
+	{
+	  if (ink_rect->width == 0 || ink_rect->height == 0)
 	    {
-	      logical_rect->x = 0;
-	      logical_rect->width = geometry->width;
+	      ink_rect->x = x_pos + glyph_ink.x;
+	      ink_rect->width = glyph_ink.width;
+	      ink_rect->y = glyph_ink.y;
+	      ink_rect->height = glyph_ink.height;
 	    }
-	}
-      else
-	{
-	  int new_pos;
-	  
-	  pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph,
-					ink_rect ? &glyph_ink : NULL,
-					logical_rect ? &glyph_logical : NULL);
-
-	  if (ink_rect)
+	  else
 	    {
-	      new_pos = MIN (ink_rect->x, x_pos + glyph_ink.x + geometry->x_offset);
+	      int new_x, new_y;
+	      
+	      new_x = MIN (ink_rect->x, x_pos + glyph_ink.x + geometry->x_offset);
 	      ink_rect->width = MAX (ink_rect->x + ink_rect->width,
-				     x_pos + glyph_ink.x + glyph_ink.width + geometry->x_offset) - new_pos;
-	      ink_rect->x = new_pos;
-
-	      new_pos = MIN (ink_rect->y, glyph_ink.y + geometry->y_offset);
+				     x_pos + glyph_ink.x + glyph_ink.width + geometry->x_offset) - new_x;
+	      ink_rect->x = new_x;
+	      
+	      new_y = MIN (ink_rect->y, glyph_ink.y + geometry->y_offset);
 	      ink_rect->height = MAX (ink_rect->y + ink_rect->height,
-				      glyph_ink.y + glyph_ink.height + geometry->y_offset) - new_pos;
-	      ink_rect->y = new_pos;
+				      glyph_ink.y + glyph_ink.height + geometry->y_offset) - new_y;
+	      ink_rect->y = new_y;
 	    }
+	}
 
-	  if (logical_rect)
-	    {
-	      logical_rect->width += geometry->width;
+      if (logical_rect)
+	{
+	  logical_rect->width += geometry->width;
 
-	      new_pos = MIN (logical_rect->y, glyph_logical.y);
+	  if (i == start)
+	    {
+	      logical_rect->y = glyph_logical.y;
+	      logical_rect->height = glyph_logical.height;
+	    }
+	  else
+	    {
+	      int new_y = MIN (logical_rect->y, glyph_logical.y);
 	      logical_rect->height = MAX (logical_rect->y + logical_rect->height,
-					  glyph_logical.y + glyph_logical.height) - new_pos;
-	      logical_rect->y = new_pos;
+					  glyph_logical.y + glyph_logical.height) - new_y;
+	      logical_rect->y = new_y;
 	    }
 	}
 
       x_pos += geometry->width;
     }
-
 }
      
 /**
