Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/pango/ChangeLog,v
retrieving revision 1.1345
diff -u -p -r1.1345 ChangeLog
--- ChangeLog	2 Feb 2006 12:03:51 -0000	1.1345
+++ ChangeLog	3 Feb 2006 02:42:15 -0000
@@ -1,5 +1,55 @@
 2006-02-02  Behdad Esfahbod  <behdad@gnome.org>
 
+	Finish the 'glyph 0' work of this morning:
+	PANGO_GLYPH_NULL that I introduced is renamed to
+	PANGO_GLYPH_EMPTY.  It means, no rendering should
+	be performed.  The backends however, still return
+	0 if a glyph is not found.  The modules then are
+	free to replace this 0 glyph with an unknown
+	character.
+
+	* modules/arabic/arabic-fc.c, modules/basic/basic-atsui.c,
+	modules/basic/basic-fc.c, modules/basic/basic-win32.c,
+	modules/basic/basic-x.c, modules/hangul/hangul-fc.c,
+	modules/hebrew/hebrew-fc.c, modules/indic/indic-fc.c,
+	modules/khmer/khmer-fc.c, modules/syriac/syriac-fc.c,
+	modules/thai/thai-fc.c, modules/tibetan/tibetan-fc.c,
+	pango/pangox.c, pango/pangowin32.c:
+	Adapt to above change.  Backends return 0 if glyph not
+	found.
+
+	* pango/fonts.c (pango_font_get_glyph_extents): If font
+	is not usable (!PANGO_IS_FONT (font)), return the generic
+	UNKNOWN_GLYPH metrics.  This is used when your backends
+	are misconfigured and you don't find *any* font at all.
+
+	* pango/pango-engince.c: Add unknown glyphs in fallback
+	shaper, instead of empty glyphs.
+
+	* pango/shape.c: Call the fall-back shaper if shaper
+	fails, instead of generating a dummy glyph string ourselves.
+
+	* pango/pango-layout.c (imposed_shape, shape_tab): Use
+	PANGO_GLYPH_EMPTY instead of glyph 0.
+
+	* pango/pango-renderer.c (pango_renderer_draw_glyph): No-op on
+	PANGO_GLYPH_EMPTY instead of glyph 0.
+
+	* pango/pangocairo-atsuifont.c, pango/pangocairo-win32font.c,
+	pango/pangocairo-fcfont.c, pango/pangocairo-font.c,
+	pango/pangocairo-private.h: install_font returns a boolean now.
+
+	* pango/pangocairo-render.c, pango/pangoxft-render.c: Handle font
+	and hex-box failures more gracefully by drawing a generic
+	unknown-box glyph.
+
+	* pango/pangoft2.c, pango/pangoft2-render.c: Draw the generic
+	unknown-box glyph here too.  For unknown glyphs though, if
+	the font is TTF (FT_IS_SFNT), use the zero-indexed glyph,
+	otherwise, draw a box of proper size.
+
+2006-02-02  Behdad Esfahbod  <behdad@gnome.org>
+
 	* pango/pangoft2.c: Do unknown glyph extents here too.
 
 2006-02-02  Behdad Esfahbod  <behdad@gnome.org>
Index: modules/arabic/arabic-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/arabic/arabic-fc.c,v
retrieving revision 1.25
diff -u -p -r1.25 arabic-fc.c
--- modules/arabic/arabic-fc.c	2 Feb 2006 10:52:45 -0000	1.25
+++ modules/arabic/arabic-fc.c	3 Feb 2006 02:42:15 -0000
@@ -209,13 +209,13 @@ fallback_shape (PangoEngineShape *engine
 
       if (pango_is_zero_width (wc))
 	{
-	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL);
+	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY);
 	}
       else
 	{
 	  index = pango_fc_font_get_glyph (fc_font, wc);
 
-	  if (index == PANGO_GLYPH_NULL)
+	  if (!index)
 	    index = pango_fc_font_get_unknown_glyph (fc_font, wc);
 
 	  set_glyph (font, glyphs, i, p - text, index);
@@ -317,7 +317,7 @@ arabic_engine_shape (PangoEngineShape *e
 
       if (pango_is_zero_width (wc))	/* Zero-width characters */
 	{
-	  pango_ot_buffer_add_glyph (buffer, 0, properties[i], p - text);
+	  pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, properties[i], p - text);
 	}
       else
 	{
Index: modules/basic/basic-atsui.c
===================================================================
RCS file: /cvs/gnome/pango/modules/basic/basic-atsui.c,v
retrieving revision 1.3
diff -u -p -r1.3 basic-atsui.c
--- modules/basic/basic-atsui.c	2 Feb 2006 10:52:46 -0000	1.3
+++ modules/basic/basic-atsui.c	3 Feb 2006 02:42:15 -0000
@@ -160,7 +160,7 @@ basic_engine_shape (PangoEngineShape *en
       
       if (pango_is_zero_width (wc))
 	{
-	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL);
+	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY);
 	}
       else
 	{
Index: modules/basic/basic-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/basic/basic-fc.c,v
retrieving revision 1.27
diff -u -p -r1.27 basic-fc.c
--- modules/basic/basic-fc.c	2 Feb 2006 10:52:46 -0000	1.27
+++ modules/basic/basic-fc.c	3 Feb 2006 02:42:15 -0000
@@ -166,13 +166,13 @@ fallback_shape (PangoEngineShape *engine
 
       if (pango_is_zero_width (wc))
 	{
-	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL);
+	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY);
 	}
       else
 	{
 	  index = pango_fc_font_get_glyph (fc_font, wc);
 
-	  if (index == PANGO_GLYPH_NULL)
+	  if (!index)
             {
 	      index = pango_fc_font_get_unknown_glyph (fc_font, wc);
               set_glyph (font, glyphs, i, p - text, index);
@@ -382,7 +382,7 @@ basic_engine_shape (PangoEngineShape *en
 
       if (pango_is_zero_width (wc))	/* Zero-width characters */
 	{
-	  pango_ot_buffer_add_glyph (buffer, 0, unknown_property, p - text);
+	  pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, unknown_property, p - text);
 	}
       else
         {
Index: modules/basic/basic-win32.c
===================================================================
RCS file: /cvs/gnome/pango/modules/basic/basic-win32.c,v
retrieving revision 1.40
diff -u -p -r1.40 basic-win32.c
--- modules/basic/basic-win32.c	2 Feb 2006 10:52:46 -0000	1.40
+++ modules/basic/basic-win32.c	3 Feb 2006 02:42:16 -0000
@@ -1003,12 +1003,12 @@ basic_engine_shape (PangoEngineShape *en
 		
       if (pango_is_zero_width (wc))
 	{
-	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL);
+	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY);
 	}
       else
 	{
 	  index = find_char (font, wc);
-	  if (index != PANGO_GLYPH_NULL)
+	  if (index)
 	    {
 	      set_glyph (font, glyphs, i, p - text, index);
 	      
Index: modules/basic/basic-x.c
===================================================================
RCS file: /cvs/gnome/pango/modules/basic/basic-x.c,v
retrieving revision 1.42
diff -u -p -r1.42 basic-x.c
--- modules/basic/basic-x.c	2 Feb 2006 10:52:46 -0000	1.42
+++ modules/basic/basic-x.c	3 Feb 2006 02:42:16 -0000
@@ -284,7 +284,7 @@ find_char (CharCache *cache, PangoFont *
 	}
     }
 
-  return PANGO_GLYPH_NULL;
+  return 0;
 }
 
 static void
@@ -610,12 +610,12 @@ basic_engine_shape (PangoEngineShape *en
 		
       if (pango_is_zero_width (wc))
 	{
-	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL);
+	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY);
 	}
       else
 	{
 	  index = find_char (cache, font, wc, input);
-	  if (index != PANGO_GLYPH_NULL)
+	  if (index)
 	    {
 	      set_glyph (font, glyphs, i, p - text, index);
 	      
@@ -680,7 +680,7 @@ basic_engine_covers (PangoEngineShape *e
 
   g_unichar_to_utf8 (wc, buf);
 
-  return find_char (cache, font, wc, buf) != PANGO_GLYPH_NULL ? PANGO_COVERAGE_EXACT : PANGO_COVERAGE_NONE;
+  return find_char (cache, font, wc, buf) ? PANGO_COVERAGE_EXACT : PANGO_COVERAGE_NONE;
 }
 
 static void
Index: modules/hangul/hangul-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/hangul/hangul-fc.c,v
retrieving revision 1.21
diff -u -p -r1.21 hangul-fc.c
--- modules/hangul/hangul-fc.c	2 Feb 2006 10:52:46 -0000	1.21
+++ modules/hangul/hangul-fc.c	3 Feb 2006 02:42:16 -0000
@@ -138,7 +138,7 @@ render_tone (PangoFont *font, gunichar t
 
   index = find_char (font, tone);
   pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
-  if (index != PANGO_GLYPH_NULL)
+  if (index)
     {
       set_glyph_tone (font, glyphs, *n_glyphs, cluster_offset, index);
     }
@@ -146,7 +146,7 @@ render_tone (PangoFont *font, gunichar t
     {
       /* fall back : HTONE1(0x302e) => middle-dot, HTONE2(0x302f) => colon */
       index = find_char (font, tone == HTONE1 ? 0x00b7 : 0x003a);
-      if (index != PANGO_GLYPH_NULL)
+      if (index)
         {
           set_glyph_tone (font, glyphs, *n_glyphs, cluster_offset, index);
         }
@@ -167,11 +167,11 @@ render_isolated_tone (PangoFont *font, g
   /* Find a base character to render the mark on
    */
   int index = find_char (font, 0x25cc);	/* DOTTED CIRCLE */
-  if (index == PANGO_GLYPH_NULL)
+  if (!index)
     index = find_char (font, 0x25cb);   /* WHITE CIRCLE, in KSC-5601 */
-  if (index == PANGO_GLYPH_NULL)
+  if (!index)
     index = find_char (font, ' ');      /* Space */
-  if (index == PANGO_GLYPH_NULL)        /* Unknown glyph box with 0000 in it */
+  if (!index)				/* Unknown glyph box with 0000 in it */
     index = find_char (font, get_unknown_glyph (font, 0));
 
   /* Add the base character
@@ -217,7 +217,7 @@ render_syllable (PangoFont *font, gunich
 	wc = S_FROM_LV(text[0], text[1]);
       index = find_char (font, wc);
       pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
-      if (index == PANGO_GLYPH_NULL)
+      if (!index)
 	set_glyph (font, glyphs, *n_glyphs, cluster_offset,
 		   get_unknown_glyph (font, wc));
       else
@@ -236,7 +236,7 @@ render_syllable (PangoFont *font, gunich
 	continue;
 
       index = find_char (font, text[i]);
-      if (index != PANGO_GLYPH_NULL)
+      if (index)
 	{
 	  pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
 	  set_glyph (font, glyphs, *n_glyphs, cluster_offset, index);
@@ -250,9 +250,9 @@ render_syllable (PangoFont *font, gunich
       for (j = 0; j < 3 && (__jamo_to_ksc5601[jindex][j] != 0); j++)
 	{
 	  wc = __jamo_to_ksc5601[jindex][j] - KSC_JAMOBASE + UNI_JAMOBASE;
-	  index = (wc >= 0x3131) ? find_char (font, wc) : PANGO_GLYPH_NULL;
+	  index = (wc >= 0x3131) ? find_char (font, wc) : 0;
 	  pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
-	  if (index == PANGO_GLYPH_NULL)
+	  if (!index)
 	    set_glyph (font, glyphs, *n_glyphs, cluster_offset,
 		       get_unknown_glyph (font, index));
 	  else
@@ -264,7 +264,7 @@ render_syllable (PangoFont *font, gunich
     {
       index = find_char (font, 0x3164);
       pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
-      if (index == PANGO_GLYPH_NULL)
+      if (!index)
 	set_glyph (font, glyphs, *n_glyphs, cluster_offset,
 		   get_unknown_glyph (font, index));
       else
@@ -285,17 +285,17 @@ render_basic (PangoFont *font, gunichar 
   if (wc == 0xa0)	/* non-break-space */
     wc = 0x20;
 
-  index = find_char (font, wc);
   pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
-  if (index != PANGO_GLYPH_NULL)
-    set_glyph (font, glyphs, *n_glyphs, cluster_offset, index);
+
+  if (pango_is_zero_width (wc))
+    set_glyph (font, glyphs, *n_glyphs, cluster_offset, PANGO_GLYPH_EMPTY);
   else
     {
-      if (pango_is_zero_width (wc))
-	set_glyph (font, glyphs, *n_glyphs, cluster_offset, PANGO_GLYPH_NULL);
+      index = find_char (font, wc);
+      if (index)
+	set_glyph (font, glyphs, *n_glyphs, cluster_offset, index);
       else
-	set_glyph (font, glyphs, *n_glyphs, cluster_offset,
-		   get_unknown_glyph (font, wc));
+	set_glyph (font, glyphs, *n_glyphs, cluster_offset, get_unknown_glyph (font, wc));
     }
   (*n_glyphs)++;
 }
Index: modules/hebrew/hebrew-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/hebrew/hebrew-fc.c,v
retrieving revision 1.16
diff -u -p -r1.16 hebrew-fc.c
--- modules/hebrew/hebrew-fc.c	2 Feb 2006 10:52:47 -0000	1.16
+++ modules/hebrew/hebrew-fc.c	3 Feb 2006 02:42:16 -0000
@@ -348,13 +348,13 @@ hebrew_engine_shape (PangoEngineShape *e
 
       if (pango_is_zero_width (wc))	/* Zero-width characters */
 	{
-	  pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_NULL, unknown_property, p - text);
+	  pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, unknown_property, p - text);
 	}
       else
 	{
 	  index = pango_fc_font_get_glyph (fc_font, wc);
 	  
-	  if (index == PANGO_GLYPH_NULL)
+	  if (!index)
 	    {
 	      pango_ot_buffer_add_glyph (buffer, pango_fc_font_get_unknown_glyph (fc_font, wc),
 					 unknown_property, p - text);
Index: modules/indic/indic-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/indic/indic-fc.c,v
retrieving revision 1.22
diff -u -p -r1.22 indic-fc.c
--- modules/indic/indic-fc.c	2 Feb 2006 10:52:47 -0000	1.22
+++ modules/indic/indic-fc.c	3 Feb 2006 02:42:16 -0000
@@ -266,22 +266,21 @@ set_glyphs (PangoFont      *font,
 
   fc_font = PANGO_FC_FONT (font);
 
-  for (i = 0; i < n_glyphs; i += 1)
+  for (i = 0; i < n_glyphs; i++)
     {
       guint glyph;
 
       if (pango_is_zero_width (wcs[i]) &&
 	  (!process_zwj || wcs[i] != 0x200D))
-	glyph = PANGO_GLYPH_NULL;
+	glyph = PANGO_GLYPH_EMPTY;
       else
         {
 	  glyph = pango_fc_font_get_glyph (fc_font, wcs[i]);
 
-	  if (glyph == PANGO_GLYPH_NULL)
+	  if (!glyph)
 	    glyph = pango_fc_font_get_unknown_glyph (fc_font, wcs[i]);
-
-          pango_ot_buffer_add_glyph (buffer, glyph, tags[i], i);
 	}
+      pango_ot_buffer_add_glyph (buffer, glyph, tags[i], i);
     }
 }
 
Index: modules/khmer/khmer-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/khmer/khmer-fc.c,v
retrieving revision 1.9
diff -u -p -r1.9 khmer-fc.c
--- modules/khmer/khmer-fc.c	2 Feb 2006 10:52:47 -0000	1.9
+++ modules/khmer/khmer-fc.c	3 Feb 2006 02:42:16 -0000
@@ -508,7 +508,7 @@ static PangoGlyph
 get_index (PangoFcFont *fc_font, gunichar wc)
 {
   PangoGlyph index = pango_fc_font_get_glyph (fc_font, wc);
-  if (index == PANGO_GLYPH_NULL)
+  if (!index)
     index = pango_fc_font_get_unknown_glyph (fc_font, wc);
   return index;
 }
Index: modules/syriac/syriac-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/syriac/syriac-fc.c,v
retrieving revision 1.9
diff -u -p -r1.9 syriac-fc.c
--- modules/syriac/syriac-fc.c	2 Feb 2006 10:52:48 -0000	1.9
+++ modules/syriac/syriac-fc.c	3 Feb 2006 02:42:16 -0000
@@ -201,13 +201,13 @@ fallback_shape (PangoEngineShape *engine
 
       if (pango_is_zero_width (wc))
 	{
-	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL);
+	  set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY);
 	}
       else
 	{
 	  index = pango_fc_font_get_glyph (fc_font, wc);
 
-	  if (index == PANGO_GLYPH_NULL)
+	  if (!index)
 	    index = pango_fc_font_get_unknown_glyph (fc_font, wc);
 
 	  set_glyph (font, glyphs, i, p - text, index);
@@ -301,7 +301,7 @@ syriac_engine_shape (PangoEngineShape *e
 
       if (pango_is_zero_width (wc))
 	{
-	  pango_ot_buffer_add_glyph (buffer, 0, properties[i], p - text);
+	  pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, properties[i], p - text);
 	}
       else
 	{
Index: modules/thai/thai-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/thai/thai-fc.c,v
retrieving revision 1.21
diff -u -p -r1.21 thai-fc.c
--- modules/thai/thai-fc.c	2 Feb 2006 10:52:48 -0000	1.21
+++ modules/thai/thai-fc.c	3 Feb 2006 02:42:16 -0000
@@ -228,7 +228,7 @@ thai_make_glyph_uni (ThaiFontInfo *font_
   PangoFcFont *fc_font = (PangoFcFont *)font_info->font;
 
   result = pango_fc_font_get_glyph (fc_font, uc);
-  if (result != PANGO_GLYPH_NULL)
+  if (result)
     return result;
   else
     return pango_fc_font_get_unknown_glyph (fc_font, uc);
Index: modules/tibetan/tibetan-fc.c
===================================================================
RCS file: /cvs/gnome/pango/modules/tibetan/tibetan-fc.c,v
retrieving revision 1.5
diff -u -p -r1.5 tibetan-fc.c
--- modules/tibetan/tibetan-fc.c	2 Feb 2006 10:52:48 -0000	1.5
+++ modules/tibetan/tibetan-fc.c	3 Feb 2006 02:42:17 -0000
@@ -473,7 +473,7 @@ static PangoGlyph
 get_index (PangoFcFont *fc_font, gunichar wc)
 {
   PangoGlyph index = pango_fc_font_get_glyph (fc_font, wc);
-  if (index == PANGO_GLYPH_NULL)
+  if (!index)
     index = pango_fc_font_get_unknown_glyph (fc_font, wc);
   return index;
 }
Index: pango/fonts.c
===================================================================
RCS file: /cvs/gnome/pango/pango/fonts.c,v
retrieving revision 1.83
diff -u -p -r1.83 fonts.c
--- pango/fonts.c	2 Feb 2006 12:07:17 -0000	1.83
+++ pango/fonts.c	3 Feb 2006 02:42:17 -0000
@@ -1166,25 +1166,25 @@ pango_font_get_glyph_extents  (PangoFont
 			       PangoRectangle *ink_rect,
 			       PangoRectangle *logical_rect)
 {
-  if (G_UNLIKELY (font == NULL))
+  if (G_UNLIKELY (!PANGO_IS_FONT (font)))
     {
       
       if (!_pango_warning_history.get_glyph_extents)
         {
 	  _pango_warning_history.get_glyph_extents = TRUE;
-	  g_critical ("pango_font_get_glyph_extents called with font == NULL, expect ugly output");
+	  g_critical ("pango_font_get_glyph_extents called with bad font, expect ugly output");
 	}
       if (ink_rect)
         {
-	  ink_rect->x = 0;
-	  ink_rect->y = 0;
-	  ink_rect->height = PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE;
-	  ink_rect->width = PANGO_UNKNOWN_GLYPH_WIDTH * PANGO_SCALE;
+	  ink_rect->x = PANGO_SCALE;
+	  ink_rect->y = - (PANGO_UNKNOWN_GLYPH_HEIGHT - 1) * PANGO_SCALE;
+	  ink_rect->height = (PANGO_UNKNOWN_GLYPH_HEIGHT - 2) * PANGO_SCALE;
+	  ink_rect->width = (PANGO_UNKNOWN_GLYPH_WIDTH - 2) * PANGO_SCALE;
         }
       if (logical_rect)
         {
-	  logical_rect->x = 0;
-	  logical_rect->y = 0;
+	  logical_rect->x = logical_rect->y = 0;
+	  logical_rect->y = - PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE;
 	  logical_rect->height = PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE;
 	  logical_rect->width = PANGO_UNKNOWN_GLYPH_WIDTH * PANGO_SCALE;
 	}
@@ -1279,7 +1279,8 @@ pango_font_metrics_new (void)
 PangoFontMetrics *
 pango_font_metrics_ref (PangoFontMetrics *metrics)
 {
-  g_return_val_if_fail (metrics != NULL, NULL);
+  if (!metrics)
+    return NULL;
   
   metrics->ref_count++;
 
@@ -1297,7 +1298,8 @@ pango_font_metrics_ref (PangoFontMetrics
 void
 pango_font_metrics_unref (PangoFontMetrics *metrics)
 {
-  g_return_if_fail (metrics != NULL);
+  if (!metrics)
+    return;
   g_return_if_fail (metrics->ref_count > 0 );
   
   metrics->ref_count--;
Index: pango/modules.c
===================================================================
RCS file: /cvs/gnome/pango/pango/modules.c,v
retrieving revision 1.54
diff -u -p -r1.54 modules.c
--- pango/modules.c	29 Jan 2006 23:06:59 -0000	1.54
+++ pango/modules.c	3 Feb 2006 02:42:17 -0000
@@ -600,11 +600,11 @@ build_map (PangoMapInfo *info)
 	  gchar *filename = g_build_filename (pango_get_sysconf_subdirectory (),
 					      "pango.modules",
 					      NULL);
-	  g_warning ("No builtin or dynamically loaded modules\n"
-		     "were found. Pango will not work correctly. This probably means\n"
-		     "there was an error in the creation of:\n"
+	  g_warning ("No builtin or dynamically\n"
+		     "loaded modules were found. Pango will not work correctly.\n"
+		     "This probably means there was an error in the creation of:\n"
 		     "  '%s'\n"
-		     "You may be able to recreate this file by running pango-querymodules.",
+		     "You should create this file by running pango-querymodules.",
 		     filename);
 	  g_free (filename);
 	  
Index: pango/pango-engine.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-engine.c,v
retrieving revision 1.6
diff -u -p -r1.6 pango-engine.c
--- pango/pango-engine.c	29 Jan 2006 20:58:40 -0000	1.6
+++ pango/pango-engine.c	3 Feb 2006 02:42:17 -0000
@@ -68,12 +68,6 @@ _pango_engine_shape_shape (PangoEngineSh
 {
   glyphs->num_glyphs = 0;
 
-  g_return_if_fail (PANGO_IS_ENGINE_SHAPE (engine));
-  g_return_if_fail (PANGO_IS_FONT (font));
-  g_return_if_fail (text != NULL);
-  g_return_if_fail (analysis != NULL);
-  g_return_if_fail (glyphs != NULL);
-
   PANGO_ENGINE_SHAPE_GET_CLASS (engine)->script_shape (engine,
 						       font,
 						       text, length,
@@ -112,27 +106,26 @@ fallback_engine_shape (PangoEngineShape 
   int i;
   const char *p;
   
-  g_return_if_fail (font != NULL);
-  g_return_if_fail (text != NULL);
-  g_return_if_fail (length >= 0);
-  g_return_if_fail (analysis != NULL);
+  n_chars = text ? g_utf8_strlen (text, length) : 0;
 
-  n_chars = g_utf8_strlen (text, length);
   pango_glyph_string_set_size (glyphs, n_chars);
   
   p = text;
-  i = 0;
-  while (i < n_chars)
+  for (i = 0; i < n_chars; i++)
     {
-      glyphs->glyphs[i].glyph = 0;
+      PangoRectangle logical_rect;
+      PangoGlyph glyph = g_utf8_get_char (p) | PANGO_GLYPH_UNKNOWN_FLAG;
+      
+      pango_font_get_glyph_extents (analysis->font, glyph, NULL, &logical_rect);
+
+      glyphs->glyphs[i].glyph = glyph;
       
       glyphs->glyphs[i].geometry.x_offset = 0;
       glyphs->glyphs[i].geometry.y_offset = 0;
-      glyphs->glyphs[i].geometry.width = 0;
-
-      glyphs->log_clusters[i] = p - text;
+      glyphs->glyphs[i].geometry.width = logical_rect.width;
       
-      ++i;
+      glyphs->log_clusters[i] = p - text;
+
       p = g_utf8_next_char (p);
     }
 }
Index: pango/pango-engine.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-engine.h,v
retrieving revision 1.13
diff -u -p -r1.13 pango-engine.h
--- pango/pango-engine.h	4 Nov 2005 23:55:37 -0000	1.13
+++ pango/pango-engine.h	3 Feb 2006 02:42:17 -0000
@@ -162,8 +162,8 @@ struct _PangoEngineShape
  *   using the @log_clusters array. Each input character must occur in one
  *   of the output logical clusters;
  *   if no rendering is desired for a character, this may involve
- *   inserting glyphs with the #PangoGlyph ID 0, which is guaranteed never
- *   to render.
+ *   inserting glyphs with the #PangoGlyph ID #PANGO_GLYPH_EMPTY, which
+ *   is guaranteed never to render.
  * @covers: Returns the characters that this engine can cover
  *   with a given font for a given language. If not overridden, the default
  *   implementation simply returns the coverage information for the
Index: pango/pango-layout.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-layout.c,v
retrieving revision 1.159
diff -u -p -r1.159 pango-layout.c
--- pango/pango-layout.c	31 Jan 2006 19:50:27 -0000	1.159
+++ pango/pango-layout.c	3 Feb 2006 02:42:18 -0000
@@ -2339,7 +2339,7 @@ imposed_shape (const char       *text,
 
   for (i=0, p = text; i < n_chars; i++, p = g_utf8_next_char (p))
     {
-      glyphs->glyphs[i].glyph = 0;
+      glyphs->glyphs[i].glyph = PANGO_GLYPH_EMPTY;
       glyphs->glyphs[i].geometry.x_offset = 0;
       glyphs->glyphs[i].geometry.y_offset = 0;
       glyphs->glyphs[i].geometry.width = shape_logical->width;
@@ -2612,7 +2612,7 @@ shape_tab (PangoLayoutLine  *line,
 
   pango_glyph_string_set_size (glyphs, 1);
   
-  glyphs->glyphs[0].glyph = 0;
+  glyphs->glyphs[0].glyph = PANGO_GLYPH_EMPTY;
   glyphs->glyphs[0].geometry.x_offset = 0;
   glyphs->glyphs[0].geometry.y_offset = 0;
   glyphs->glyphs[0].attr.is_cluster_start = 1;
@@ -3844,11 +3844,19 @@ pango_layout_line_get_empty_extents (Pan
 	  metrics = pango_font_get_metrics (font,
 					    pango_context_get_language (layout->context));
 
-	  logical_rect->y = - pango_font_metrics_get_ascent (metrics);
-	  logical_rect->height = - logical_rect->y + pango_font_metrics_get_descent (metrics);
+	  if (metrics)
+	    {
+	      logical_rect->y = - pango_font_metrics_get_ascent (metrics);
+	      logical_rect->height = - logical_rect->y + pango_font_metrics_get_descent (metrics);
 
+	      pango_font_metrics_unref (metrics);
+	    }
+	  else
+	    {
+	      logical_rect->y = 0;
+	      logical_rect->height = 0;
+	    }
 	  g_object_unref (font);
-	  pango_font_metrics_unref (metrics);
 	}
       else
 	{
Index: pango/pango-renderer.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-renderer.c,v
retrieving revision 1.12
diff -u -p -r1.12 pango-renderer.c
--- pango/pango-renderer.c	21 Jan 2006 19:51:25 -0000	1.12
+++ pango/pango-renderer.c	3 Feb 2006 02:42:18 -0000
@@ -965,7 +965,7 @@ pango_renderer_draw_glyph (PangoRenderer
   g_return_if_fail (PANGO_IS_RENDERER (renderer));
   g_return_if_fail (renderer->active_count > 0);
 	  
-  if (glyph == 0)		/* glyph 0 never renders */
+  if (glyph == PANGO_GLYPH_EMPTY) /* glyph PANGO_GLYPH_EMPTY never renders */
     return;
   
   PANGO_RENDERER_GET_CLASS (renderer)->draw_glyph (renderer, font, glyph, x, y);
Index: pango/pango-types.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-types.h,v
retrieving revision 1.29
diff -u -p -r1.29 pango-types.h
--- pango/pango-types.h	2 Feb 2006 10:52:49 -0000	1.29
+++ pango/pango-types.h	3 Feb 2006 02:42:18 -0000
@@ -46,7 +46,7 @@ typedef struct _PangoLanguage PangoLangu
 typedef guint32 PangoGlyph;
 
 #define PANGO_GLYPH_UNKNOWN_FLAG ((PangoGlyph)0x10000000)
-#define PANGO_GLYPH_NULL         ((PangoGlyph)0xFFFFFFFF)
+#define PANGO_GLYPH_EMPTY        ((PangoGlyph)0xFFFFFFFF)
 
 /* A rectangle. Used to store logical and physical extents of glyphs,
  * runs, strings, etc.
Index: pango/pangocairo-atsuifont.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-atsuifont.c,v
retrieving revision 1.7
diff -u -p -r1.7 pangocairo-atsuifont.c
--- pango/pangocairo-atsuifont.c	27 Jan 2006 19:14:29 -0000	1.7
+++ pango/pangocairo-atsuifont.c	3 Feb 2006 02:42:18 -0000
@@ -67,7 +67,7 @@ pango_cairo_atsui_font_get_atsu_font_id 
   return cafont->font_id;
 }
 
-static void
+static gboolean
 pango_cairo_atsui_font_install (PangoCairoFont *font,
 				cairo_t        *cr)
 {
@@ -78,6 +78,8 @@ pango_cairo_atsui_font_install (PangoCai
 
   cairo_set_font_matrix (cr, &cafont->font_matrix);
   cairo_set_font_options (cr, cafont->options);
+
+  return TRUE;
 }
 
 static cairo_font_face_t *
@@ -142,36 +144,53 @@ pango_cairo_atsui_font_get_glyph_extents
 					  PangoRectangle   *logical_rect)
 {
   cairo_scaled_font_t *scaled_font;
+  cairo_font_extents_t font_extents;
   cairo_text_extents_t extents;
   cairo_glyph_t cairo_glyph;
 
   scaled_font = pango_cairo_atsui_font_get_scaled_font (PANGO_CAIRO_FONT (font));
 
+  if (logical_rect)
+    cairo_scaled_font_extents (scaled_font, &font_extents);
+	  
   cairo_glyph.index = glyph;
   cairo_glyph.x = 0;
   cairo_glyph.y = 0;
 
-  cairo_scaled_font_glyph_extents (scaled_font,
-				   &cairo_glyph, 1, &extents);
-
-  if (ink_rect)
-    {
-      ink_rect->x = extents.x_bearing * PANGO_SCALE;
-      ink_rect->y = extents.y_bearing * PANGO_SCALE;
-      ink_rect->width = extents.width * PANGO_SCALE;
-      ink_rect->height = extents.height * PANGO_SCALE;
-    }
-  
-  if (logical_rect)
+  if (glyph != PANGO_GLYPH_EMPTY)
     {
-      cairo_font_extents_t font_extents;
+      cairo_scaled_font_glyph_extents (scaled_font,
+				       &cairo_glyph, 1, &extents);
 
-      cairo_scaled_font_extents (scaled_font, &font_extents);
+      if (ink_rect)
+	{
+	  ink_rect->x = extents.x_bearing * PANGO_SCALE;
+	  ink_rect->y = extents.y_bearing * PANGO_SCALE;
+	  ink_rect->width = extents.width * PANGO_SCALE;
+	  ink_rect->height = extents.height * PANGO_SCALE;
+	}
       
-      logical_rect->x = 0;
-      logical_rect->y = - font_extents.ascent * PANGO_SCALE;
-      logical_rect->width = extents.x_advance * PANGO_SCALE;
-      logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE;
+      if (logical_rect)
+	{
+	  logical_rect->x = 0;
+	  logical_rect->y = - font_extents.ascent * PANGO_SCALE;
+	  logical_rect->width = extents.x_advance * PANGO_SCALE;
+	  logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE;
+	}
+    }
+  else
+    {
+      if (ink_rect)
+	{
+	  ink_rect->x = ink_rect->y = ink_rect->width = ink_rect->height = 0;
+	}
+      if (logical_rect)
+        {
+	  logical_rect->x = 0;
+	  logical_rect->y = - font_extents.ascent * PANGO_SCALE;
+	  logical_rect->width = 0;
+	  logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE;
+	}
     }
 }
 
Index: pango/pangocairo-fcfont.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-fcfont.c,v
retrieving revision 1.27
diff -u -p -r1.27 pangocairo-fcfont.c
--- pango/pangocairo-fcfont.c	2 Feb 2006 10:52:49 -0000	1.27
+++ pango/pangocairo-fcfont.c	3 Feb 2006 02:42:18 -0000
@@ -173,7 +173,7 @@ pango_cairo_fc_font_get_scaled_font (Pan
  *    Method implementations    *
  ********************************/
 
-static void
+static gboolean
 pango_cairo_fc_font_install (PangoCairoFont *font,
 			     cairo_t        *cr)
 {
@@ -183,6 +183,8 @@ pango_cairo_fc_font_install (PangoCairoF
 		       pango_cairo_fc_font_get_font_face (font));
   cairo_set_font_matrix (cr, &cffont->font_matrix);
   cairo_set_font_options (cr, cffont->options);
+
+  return TRUE;
 }
 
 static void
@@ -438,7 +440,7 @@ pango_cairo_fc_font_get_glyph_extents (P
   if (cffont->glyph_extents_cache == NULL)
     pango_cairo_fc_font_glyph_extents_cache_init (cffont);
 
-  if (glyph == PANGO_GLYPH_NULL)
+  if (glyph == PANGO_GLYPH_EMPTY)
     {
       if (ink_rect)
 	*ink_rect = cffont->font_extents;
Index: pango/pangocairo-font.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-font.c,v
retrieving revision 1.16
diff -u -p -r1.16 pangocairo-font.c
--- pango/pangocairo-font.c	2 Feb 2006 12:24:52 -0000	1.16
+++ pango/pangocairo-font.c	3 Feb 2006 02:42:18 -0000
@@ -69,7 +69,7 @@ pango_cairo_font_get_type (void)
  * Makes @font the current font for rendering in the specified
  * Cairo context.
  **/
-void
+gboolean
 _pango_cairo_font_install (PangoCairoFont *font,
 			   cairo_t        *cr)
 {
@@ -78,13 +78,13 @@ _pango_cairo_font_install (PangoCairoFon
       if (!_pango_cairo_warning_history.font_install)
         {
 	  _pango_cairo_warning_history.font_install = TRUE;
-	  g_critical ("_pango_cairo_font_install called with font == NULL, expect ugly output");
+	  g_critical ("_pango_cairo_font_install called with bad font, expect ugly output");
 	  cairo_set_font_face (cr, NULL);
 	}
-      return;
+      return FALSE;
     }
   
-  (* PANGO_CAIRO_FONT_GET_IFACE (font)->install) (font, cr);
+  return (* PANGO_CAIRO_FONT_GET_IFACE (font)->install) (font, cr);
 }
 
 cairo_font_face_t *
@@ -161,7 +161,7 @@ _pango_cairo_font_get_hex_box_info (Pang
   }
 
 /* we hint to the nearest device units */
-#define HINT(value, scale, scale_inv) (ceil ((value) * scale) * scale_inv)
+#define HINT(value, scale, scale_inv) (ceil ((value-1e-5) * scale) * scale_inv)
 #define HINT_X(value) HINT ((value), scale_x, scale_x_inv)
 #define HINT_Y(value) HINT ((value), scale_y, scale_y_inv)
   
@@ -233,7 +233,7 @@ _pango_cairo_font_get_hex_box_info (Pang
   hbi->digit_width = HINT_X (width);
   hbi->digit_height = HINT_Y (height);
 
-  pad = MIN (hbi->digit_width / 10, hbi->digit_height / 12);
+  pad = (font_extents.ascent + font_extents.descent) / 43;
   hbi->pad_x = HINT_X (pad);
   hbi->pad_y = HINT_Y (pad);
   hbi->line_width = MIN (hbi->pad_x, hbi->pad_y);
@@ -257,6 +257,11 @@ _pango_cairo_get_glyph_extents_missing (
   gint rows, cols;
 
   hbi = _pango_cairo_font_get_hex_box_info (cfont);
+  if (!hbi)
+    {
+      pango_font_get_glyph_extents (NULL, glyph, ink_rect, logical_rect);
+      return;
+    }
 
   rows = hbi->rows;
   cols = ((glyph & ~PANGO_GLYPH_UNKNOWN_FLAG) > 0xffff ? 6 : 4) / rows;
Index: pango/pangocairo-private.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-private.h,v
retrieving revision 1.11
diff -u -p -r1.11 pangocairo-private.h
--- pango/pangocairo-private.h	2 Feb 2006 12:24:52 -0000	1.11
+++ pango/pangocairo-private.h	3 Feb 2006 02:42:18 -0000
@@ -56,8 +56,8 @@ struct _PangoCairoFontIface
 {
   GTypeInterface g_iface;
 
-  void (*install) (PangoCairoFont *font,
-		   cairo_t        *cr);
+  gboolean (*install) (PangoCairoFont *font,
+		       cairo_t        *cr);
 
   cairo_font_face_t *(*get_font_face) (PangoCairoFont *font);
 
@@ -66,8 +66,8 @@ struct _PangoCairoFontIface
 
 GType pango_cairo_font_get_type (void);
 
-void _pango_cairo_font_install (PangoCairoFont *font,
-				cairo_t        *cr);
+gboolean _pango_cairo_font_install (PangoCairoFont *font,
+				    cairo_t        *cr);
 cairo_font_face_t *_pango_cairo_font_get_font_face (PangoCairoFont *font);
 cairo_scaled_font_t *_pango_cairo_font_get_scaled_font (PangoCairoFont *font);
 
Index: pango/pangocairo-render.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-render.c,v
retrieving revision 1.16
diff -u -p -r1.16 pangocairo-render.c
--- pango/pangocairo-render.c	2 Feb 2006 12:24:52 -0000	1.16
+++ pango/pangocairo-render.c	3 Feb 2006 02:42:18 -0000
@@ -59,6 +59,33 @@ set_color (PangoCairoRenderer *crenderer
 }
 
 static void
+_pango_cairo_renderer_draw_box_glyph (PangoCairoRenderer *crenderer,
+				      PangoGlyphInfo     *gi,
+				      double              cx,
+				      double              cy)
+{
+  double temp_x, temp_y;
+
+  cairo_save (crenderer->cr);
+  cairo_get_current_point (crenderer->cr, &temp_x, &temp_y);
+
+  cairo_rectangle (crenderer->cr,
+		   cx + 1.5,
+		   cy + 1.5 - PANGO_UNKNOWN_GLYPH_HEIGHT,
+		   (double)gi->geometry.width / PANGO_SCALE - 3.0,
+		   PANGO_UNKNOWN_GLYPH_HEIGHT - 3.0);
+
+  if (!crenderer->do_path)
+    {
+      cairo_set_line_width (crenderer->cr, 1.0);
+      cairo_stroke (crenderer->cr);
+    }
+
+  cairo_move_to (crenderer->cr, temp_x, temp_y);
+  cairo_restore (crenderer->cr);
+}
+
+static void
 _pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
 					  PangoFont          *font,
 					  PangoGlyphInfo     *gi,
@@ -78,20 +105,10 @@ _pango_cairo_renderer_draw_unknown_glyph
   cairo_get_current_point (crenderer->cr, &temp_x, &temp_y);
 
   hbi = _pango_cairo_font_get_hex_box_info ((PangoCairoFont *)font);      
-  if (!hbi)
-    {
-      cairo_rectangle (crenderer->cr,
-		       cx + 1.5,
-		       cy - 1.5,
-		       (double)gi->geometry.width / PANGO_SCALE - 3.0,
-		       PANGO_UNKNOWN_GLYPH_HEIGHT - 3.0);
-
-      if (!crenderer->do_path)
-	{
-	  cairo_set_line_width (crenderer->cr, 1.0);
-	  cairo_stroke (crenderer->cr);
-	}
 
+  if (!hbi || !_pango_cairo_font_install (PANGO_CAIRO_FONT (hbi->font), crenderer->cr))
+    {
+      _pango_cairo_renderer_draw_box_glyph (crenderer, gi, cx, cy);
       goto done;
     }
 
@@ -103,9 +120,9 @@ _pango_cairo_renderer_draw_unknown_glyph
 
   cairo_rectangle (crenderer->cr,
 		   cx + hbi->pad_x * 1.5,
-		   cy + hbi->box_descent - hbi->pad_y * 0.5,
+		   cy + hbi->box_descent - hbi->box_height + hbi->pad_y * 0.5,
 		   (double)gi->geometry.width / PANGO_SCALE - 3 * hbi->pad_x,
-		   -(hbi->box_height - hbi->pad_y));
+		   (hbi->box_height - hbi->pad_y));
 
   if (!crenderer->do_path)
     {
@@ -113,8 +130,6 @@ _pango_cairo_renderer_draw_unknown_glyph
       cairo_stroke (crenderer->cr);
     }
 
-  _pango_cairo_font_install (PANGO_CAIRO_FONT (hbi->font), crenderer->cr);
-
   x0 = cx + hbi->pad_x * 3.0;
   y0 = cy + hbi->box_descent - hbi->pad_y * 2;
 
@@ -165,6 +180,27 @@ pango_cairo_renderer_draw_glyphs (PangoR
       set_color (crenderer, PANGO_RENDER_PART_FOREGROUND);
     }
 
+  if (!_pango_cairo_font_install (PANGO_CAIRO_FONT (font), crenderer->cr))
+    {
+      for (i = 0; i < glyphs->num_glyphs; i++)
+	{
+	  PangoGlyphInfo *gi = &glyphs->glyphs[i];
+
+	  if (gi->glyph != PANGO_GLYPH_EMPTY)
+	    {
+	      double cx = crenderer->x_offset +
+			  (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
+	      double cy = crenderer->y_offset +
+			  (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
+
+	      _pango_cairo_renderer_draw_unknown_glyph (crenderer, font, gi, cx, cy);
+	    }	  
+	  x_position += gi->geometry.width;
+	}
+
+      goto done;
+    }
+
   if (glyphs->num_glyphs > MAX_STACK)
     cairo_glyphs = g_new (cairo_glyph_t, glyphs->num_glyphs);
   else
@@ -175,10 +211,12 @@ pango_cairo_renderer_draw_glyphs (PangoR
     {
       PangoGlyphInfo *gi = &glyphs->glyphs[i];
 
-      if (gi->glyph != PANGO_GLYPH_NULL)
+      if (gi->glyph != PANGO_GLYPH_EMPTY)
         {
-          double cx = crenderer->x_offset + (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
-          double cy = crenderer->y_offset + (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
+          double cx = crenderer->x_offset +
+		      (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
+          double cy = crenderer->y_offset +
+		      (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
 
           if (gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG)
 	    _pango_cairo_renderer_draw_unknown_glyph (crenderer, font, gi, cx, cy);
@@ -193,8 +231,6 @@ pango_cairo_renderer_draw_glyphs (PangoR
       x_position += gi->geometry.width;
     }
 
-  _pango_cairo_font_install (PANGO_CAIRO_FONT (font), crenderer->cr);
-  
   if (crenderer->do_path)
     cairo_glyph_path (crenderer->cr, cairo_glyphs, count);
   else
@@ -203,6 +239,7 @@ pango_cairo_renderer_draw_glyphs (PangoR
   if (glyphs->num_glyphs > MAX_STACK)
     g_free (cairo_glyphs);
 
+done:
   if (!crenderer->do_path)
     cairo_restore (crenderer->cr);
   
Index: pango/pangocairo-win32font.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-win32font.c,v
retrieving revision 1.19
diff -u -p -r1.19 pangocairo-win32font.c
--- pango/pangocairo-win32font.c	29 Jan 2006 23:06:59 -0000	1.19
+++ pango/pangocairo-win32font.c	3 Feb 2006 02:42:18 -0000
@@ -138,7 +138,7 @@ pango_cairo_win32_font_get_scaled_font (
  *    Method implementations    *
  ********************************/
 
-static void
+static gboolean
 pango_cairo_win32_font_install (PangoCairoFont *font,
 				cairo_t        *cr)
 {
@@ -210,7 +210,7 @@ compute_glyph_extents (PangoFont        
   logical_rect->width = 0;
   logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE;
 
-  if (glyph)
+  if (glyph != PANGO_GLYPH_EMPTY)
     {
       cairo_glyph.index = glyph;
       cairo_glyph.x = 0;
Index: pango/pangofc-decoder.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangofc-decoder.c,v
retrieving revision 1.8
diff -u -p -r1.8 pangofc-decoder.c
--- pango/pangofc-decoder.c	2 Feb 2006 10:52:49 -0000	1.8
+++ pango/pangofc-decoder.c	3 Feb 2006 02:42:18 -0000
@@ -70,7 +70,7 @@ pango_fc_decoder_get_charset (PangoFcDec
  * glyph is most convenient for it. (Usually whatever glyph is directly
  * in the fonts character map table.)
  *
- * Return value: the glyph index, or %PANGO_GLYPH_NULL if the glyph isn't
+ * Return value: the glyph index, or 0 if the glyph isn't
  * covered by the font.
  *
  * Since: 1.6
@@ -80,7 +80,7 @@ pango_fc_decoder_get_glyph (PangoFcDecod
 			    PangoFcFont    *fcfont,
 			    guint32         wc)
 {
-  g_return_val_if_fail (PANGO_IS_FC_DECODER (decoder), PANGO_GLYPH_NULL);
+  g_return_val_if_fail (PANGO_IS_FC_DECODER (decoder), 0);
 
   return PANGO_FC_DECODER_GET_CLASS (decoder)->get_glyph (decoder, fcfont, wc);
 }
Index: pango/pangofc-font.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangofc-font.c,v
retrieving revision 1.29
diff -u -p -r1.29 pangofc-font.c
--- pango/pangofc-font.c	2 Feb 2006 10:52:49 -0000	1.29
+++ pango/pangofc-font.c	3 Feb 2006 02:42:18 -0000
@@ -435,7 +435,7 @@ pango_fc_font_create_metrics_for_context
   g_object_unref (layout);
 
   return metrics;
-}		    
+}
 
 /* This function is cut-and-pasted into pangocairo-fcfont.c - it might be
  * better to add a virtual fcfont->create_context (font).
@@ -469,7 +469,7 @@ pango_fc_font_get_metrics (PangoFont    
 	return pango_font_metrics_new ();
 
       info = g_slice_new0 (PangoFcMetricsInfo);
-      
+
       fcfont->metrics_by_lang = g_slist_prepend (fcfont->metrics_by_lang, 
 						 info);
 	
@@ -518,7 +518,7 @@ pango_fc_font_real_get_glyph (PangoFcFon
   
   index = FcFreeTypeCharIndex (face, wc);
   if (index > (FT_UInt)face->num_glyphs)
-    index = PANGO_GLYPH_NULL;
+    index = 0;
 
   PANGO_FC_FONT_UNLOCK_FACE (font);
 
@@ -600,7 +600,7 @@ pango_fc_font_has_char (PangoFcFont *fon
  * for @font. If you only want to determine
  * whether the font has the glyph, use pango_fc_font_has_char().
  * 
- * Return value: the glyph index, or %PANGO_GLYPH_NULL, if the Unicode
+ * Return value: the glyph index, or 0, if the Unicode
  *   character doesn't exist in the font.
  *
  * Since: 1.4
@@ -817,7 +817,7 @@ pango_fc_font_get_raw_extents (PangoFcFo
 
   face = PANGO_FC_FONT_LOCK_FACE (fcfont);
 
-  if (!glyph)
+  if (glyph == PANGO_GLYPH_EMPTY)
     gm = NULL;
   else
     gm = get_per_char (face, load_flags, glyph);
Index: pango/pangoft2-private.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pangoft2-private.h,v
retrieving revision 1.28
diff -u -p -r1.28 pangoft2-private.h
--- pango/pangoft2-private.h	9 Jan 2005 00:12:39 -0000	1.28
+++ pango/pangoft2-private.h	3 Feb 2006 02:42:18 -0000
@@ -112,4 +112,12 @@ GType pango_ft2_renderer_get_type    (vo
 
 PangoRenderer *_pango_ft2_font_map_get_renderer (PangoFT2FontMap *ft2fontmap);
 
+typedef struct _PangoFT2WarningHistory PangoFT2WarningHistory;
+
+struct _PangoFT2WarningHistory {
+  guint get_face		: 1;
+}; 
+
+extern PangoFT2WarningHistory _pango_ft2_warning_history;
+
 #endif /* __PANGOFT2_PRIVATE_H__ */
Index: pango/pangoft2-render.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangoft2-render.c,v
retrieving revision 1.11
diff -u -p -r1.11 pangoft2-render.c
--- pango/pangoft2-render.c	2 Feb 2006 10:52:49 -0000	1.11
+++ pango/pangoft2-render.c	3 Feb 2006 02:42:19 -0000
@@ -100,20 +100,97 @@ pango_ft2_free_rendered_glyph (PangoFT2R
 }
 
 static PangoFT2RenderedGlyph *
+pango_ft2_font_render_box_glyph (int width,
+				 int height,
+				 int top)
+{
+  PangoFT2RenderedGlyph *box;
+  int i, j, offset1, offset2, line_width;
+
+  line_width = MAX ((height + 43) / 44, 1);
+  if (width < 1 || height < 1)
+    line_width = 0;
+
+  box = g_slice_new (PangoFT2RenderedGlyph);
+
+  box->bitmap_left = 0;
+  box->bitmap_top = top;
+
+  box->bitmap.pixel_mode = ft_pixel_mode_grays;
+
+  box->bitmap.width = width;
+  box->bitmap.rows = height;
+  box->bitmap.pitch = height;
+
+  box->bitmap.buffer = g_malloc0 (box->bitmap.rows * box->bitmap.pitch);
+
+  /* draw the box */
+  for (j = 0; j < line_width; j++)
+    {
+      offset1 = box->bitmap.pitch * (MIN (1 + j, height - 1));
+      offset2 = box->bitmap.pitch * (MAX (box->bitmap.rows - 2 - j, 0));
+      for (i = 1;
+	   i < box->bitmap.width - 1;
+	   i++)
+	{
+	  box->bitmap.buffer[offset1 + i] = 0xff;
+	  box->bitmap.buffer[offset2 + i] = 0xff;
+	}
+    }
+  for (j = 0; j < line_width; j++)
+    {
+      offset1 = MIN (1 + j, width - 1);
+      offset2 = MAX (box->bitmap.width - 2 - j, 0);
+      for (i = box->bitmap.pitch;
+	   i < (box->bitmap.rows - 1) * box->bitmap.pitch;
+	   i += box->bitmap.pitch)
+	{
+	  box->bitmap.buffer[offset1 + i] = 0xff;
+	  box->bitmap.buffer[offset2 + i] = 0xff;
+	}
+    }
+
+  return box;
+}
+
+static PangoFT2RenderedGlyph *
 pango_ft2_font_render_glyph (PangoFont *font,
 			     int glyph_index)
 {
-  PangoFT2RenderedGlyph *rendered;
   FT_Face face;
 
-  rendered = g_slice_new (PangoFT2RenderedGlyph);
+  if (glyph_index & PANGO_GLYPH_UNKNOWN_FLAG)
+    {
+      static PangoFT2RenderedGlyph *box;
+      PangoFontMetrics *metrics;
+
+      if (!font)
+	goto generic_box;
+
+      metrics = pango_font_get_metrics (font, NULL);
+      if (!metrics)
+	goto generic_box;
+
+      /* this box gets cached, so don't bother with static'ing it.
+       */
+
+      box = pango_ft2_font_render_box_glyph (PANGO_PIXELS (metrics->approximate_char_width),
+					     PANGO_PIXELS (metrics->ascent + metrics->descent),
+					     PANGO_PIXELS (metrics->ascent));
+      pango_font_metrics_unref (metrics);
+
+      return box;
+    }
 
   face = pango_ft2_font_get_face (font);
   
   if (face)
     {
+      PangoFT2RenderedGlyph *rendered;
       PangoFT2Font *ft2font = (PangoFT2Font *) font;
 
+      rendered = g_slice_new (PangoFT2RenderedGlyph);
+
       /* Draw glyph */
       FT_Load_Glyph (face, glyph_index, ft2font->load_flags);
       FT_Render_Glyph (face->glyph,
@@ -125,11 +202,23 @@ pango_ft2_font_render_glyph (PangoFont *
 					  face->glyph->bitmap.rows * face->glyph->bitmap.pitch);
       rendered->bitmap_left = face->glyph->bitmap_left;
       rendered->bitmap_top = face->glyph->bitmap_top;
+
+      return rendered;
     }
   else
-    g_warning ("couldn't get face for PangoFT2Face, expect ugly output");
+    {
+      static PangoFT2RenderedGlyph *box = NULL;
 
-  return rendered;
+    generic_box:
+      if (!box)
+        {
+	  box = pango_ft2_font_render_box_glyph (PANGO_UNKNOWN_GLYPH_WIDTH,
+						 PANGO_UNKNOWN_GLYPH_HEIGHT,
+						 PANGO_UNKNOWN_GLYPH_HEIGHT);
+	}
+
+      return box;
+    }
 }
 
 static void
@@ -151,9 +240,18 @@ pango_ft2_renderer_draw_glyph (PangoRend
   int ix, iy;
 
   if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
-    glyph = PANGO_GLYPH_NULL;
-  if (glyph == PANGO_GLYPH_NULL)
-    return;
+    {
+      FT_Face face = pango_ft2_font_get_face (font);
+      if (face && FT_IS_SFNT (face))
+	glyph = pango_ft2_get_unknown_glyph (font);
+      else
+        {
+	  /* Since we only draw an empty box for FT2 renderer,
+	   * unify the rendered bitmaps in the cache.
+	   */
+	  glyph = PANGO_GLYPH_UNKNOWN_FLAG;
+	}
+    }
 
   rendered_glyph = _pango_ft2_font_get_cache_glyph_data (font, glyph);
   add_glyph_to_cache = FALSE;
@@ -588,8 +686,8 @@ pango_ft2_render_transformed (FT_Bitmap 
   PangoRenderer *renderer;
 
   g_return_if_fail (bitmap != NULL);
-  g_return_if_fail (PANGO_FT2_IS_FONT (font));
   g_return_if_fail (glyphs != NULL);
+  g_return_if_fail (PANGO_FT2_IS_FONT (font));
 
   fontmap = PANGO_FC_FONT (font)->fontmap;
   renderer = _pango_ft2_font_map_get_renderer (PANGO_FT2_FONT_MAP (fontmap));
Index: pango/pangoft2.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangoft2.c,v
retrieving revision 1.82
diff -u -p -r1.82 pangoft2.c
--- pango/pangoft2.c	2 Feb 2006 12:03:51 -0000	1.82
+++ pango/pangoft2.c	3 Feb 2006 02:42:19 -0000
@@ -33,6 +33,8 @@
 #include "pangofc-fontmap.h"
 #include "pangofc-private.h"
 
+PangoFT2WarningHistory _pango_ft2_warning_history = { FALSE };
+
 /* for compatibility with older freetype versions */
 #ifndef FT_LOAD_TARGET_MONO
 #define FT_LOAD_TARGET_MONO  FT_LOAD_MONOCHROME
@@ -58,8 +60,6 @@ static void                   pango_ft2_
 
 static FT_Face    pango_ft2_font_real_lock_face         (PangoFcFont      *font);
 static void       pango_ft2_font_real_unlock_face       (PangoFcFont      *font);
-static PangoGlyph pango_ft2_font_real_get_unknown_glyph (PangoFcFont      *font,
-							 gunichar          wc);
 
 PangoFT2Font *
 _pango_ft2_font_new (PangoFT2FontMap *ft2fontmap,
@@ -173,6 +173,16 @@ pango_ft2_font_get_face (PangoFont *font
   FcBool antialias, hinting, autohint;
   int id;
 
+  if (G_UNLIKELY (!PANGO_FT2_IS_FONT (font)))
+    {
+      if (!_pango_ft2_warning_history.get_face)
+        {
+	  _pango_ft2_warning_history.get_face = TRUE;
+	  g_critical ("pango_ft2_font_get_face called with bad font, expect ugly output");
+	}
+      return NULL;
+    }
+
   pattern = fcfont->font_pattern;
 
   if (!ft2font->face)
@@ -259,7 +269,6 @@ pango_ft2_font_class_init (PangoFT2FontC
   
   fc_font_class->lock_face = pango_ft2_font_real_lock_face;
   fc_font_class->unlock_face = pango_ft2_font_real_unlock_face;
-  fc_font_class->get_unknown_glyph = pango_ft2_font_real_get_unknown_glyph;
 }
 
 static PangoFT2GlyphInfo *
@@ -296,25 +305,52 @@ pango_ft2_font_get_glyph_extents (PangoF
 {
   PangoFT2GlyphInfo *info;
 
-  if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
-    glyph = PANGO_GLYPH_NULL;
-  if (glyph == PANGO_GLYPH_NULL)
+  if (glyph == PANGO_GLYPH_EMPTY)
     {
       if (ink_rect)
-        {
-	  ink_rect->x = 0;
-	  ink_rect->y = 0;
-	  ink_rect->height = PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE;
-	  ink_rect->width = PANGO_UNKNOWN_GLYPH_WIDTH * PANGO_SCALE;
-        }
+	ink_rect->x = ink_rect->y = ink_rect->height = ink_rect->width = 0;
       if (logical_rect)
+	logical_rect->x = logical_rect->y = logical_rect->height = logical_rect->width = 0;
+      return;
+    }
+
+  if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+    {
+      FT_Face face = pango_ft2_font_get_face (font);
+      if (face && FT_IS_SFNT (face))
+	glyph = pango_ft2_get_unknown_glyph (font);
+      else
         {
-	  logical_rect->x = 0;
-	  logical_rect->y = 0;
-	  logical_rect->height = PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE;
-	  logical_rect->width = PANGO_UNKNOWN_GLYPH_WIDTH * PANGO_SCALE;
+	  PangoFontMetrics *metrics = pango_font_get_metrics (font, NULL);
+
+	  if (metrics)
+	    {
+	      if (ink_rect)
+		{
+		  ink_rect->x = PANGO_SCALE;
+		  ink_rect->y = - (metrics->ascent - PANGO_SCALE);
+		  ink_rect->height = metrics->ascent + metrics->descent - 2 * PANGO_SCALE;
+		  ink_rect->width = metrics->approximate_char_width - 2 * PANGO_SCALE;
+		}
+	      if (logical_rect)
+		{
+		  logical_rect->x = 0;
+		  logical_rect->y = -metrics->ascent;
+		  logical_rect->height = metrics->ascent + metrics->descent;
+		  logical_rect->width = metrics->approximate_char_width;
+		}
+
+	      pango_font_metrics_unref (metrics);
+	    }
+	  else
+	    {
+	      if (ink_rect)
+		ink_rect->x = ink_rect->y = ink_rect->height = ink_rect->width = 0;
+	      if (logical_rect)
+		logical_rect->x = logical_rect->y = logical_rect->height = logical_rect->width = 0;
+	    }
+	  return;
 	}
-      return;
     }
 
   info = pango_ft2_font_get_glyph_info (font, glyph, TRUE);
@@ -381,13 +417,6 @@ pango_ft2_font_real_unlock_face (PangoFc
 {
 }
 
-static PangoGlyph
-pango_ft2_font_real_get_unknown_glyph (PangoFcFont *font,
-				       gunichar     wc)
-{
-  return 0;
-}
-
 static gboolean
 pango_ft2_free_glyph_info_callback (gpointer key,
 				    gpointer value,
@@ -505,7 +534,8 @@ _pango_ft2_font_get_cache_glyph_data (Pa
 {
   PangoFT2GlyphInfo *info;
 
-  g_return_val_if_fail (PANGO_FT2_IS_FONT (font), NULL);
+  if (!PANGO_FT2_IS_FONT (font))
+    return NULL;
   
   info = pango_ft2_font_get_glyph_info (font, glyph_index, FALSE);
 
@@ -522,7 +552,8 @@ _pango_ft2_font_set_cache_glyph_data (Pa
 {
   PangoFT2GlyphInfo *info;
 
-  g_return_if_fail (PANGO_FT2_IS_FONT (font));
+  if (!PANGO_FT2_IS_FONT (font))
+    return;
   
   info = pango_ft2_font_get_glyph_info (font, glyph_index, TRUE);
 
@@ -535,7 +566,8 @@ void
 _pango_ft2_font_set_glyph_cache_destroy (PangoFont      *font,
 					 GDestroyNotify  destroy_notify)
 {
-  g_return_if_fail (PANGO_FT2_IS_FONT (font));
+  if (!PANGO_FT2_IS_FONT (font))
+    return;
   
   PANGO_FT2_FONT (font)->glyph_cache_destroy = destroy_notify;
 }
Index: pango/pangowin32.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangowin32.c,v
retrieving revision 1.64
diff -u -p -r1.64 pangowin32.c
--- pango/pangowin32.c	2 Feb 2006 10:52:49 -0000	1.64
+++ pango/pangowin32.c	3 Feb 2006 02:42:19 -0000
@@ -311,11 +311,12 @@ pango_win32_render (HDC               hd
        * point zero (just spacing).
        */
       while (i < glyphs->num_glyphs &&
-	     (glyphs->glyphs[i].glyph == PANGO_GLYPH_NULL || cur_y_offset == glyphs->glyphs[i].geometry.y_offset))
+	     (glyphs->glyphs[i].glyph == PANGO_GLYPH_EMPTY ||
+	      cur_y_offset == glyphs->glyphs[i].geometry.y_offset))
 	{
-	  if (glyphs->glyphs[i].glyph == PANGO_GLYPH_NULL)
+	  if (glyphs->glyphs[i].glyph == PANGO_GLYPH_EMPTY)
 	    {
-	      /* PANGO_GLYPH_NULL glyphs should not be rendered, but their
+	      /* PANGO_GLYPH_EMPTY glyphs should not be rendered, but their
 	       * indicated width (set up by PangoLayout) should be taken
 	       * into account.
 	       */
@@ -460,6 +461,15 @@ pango_win32_font_get_glyph_extents (Pang
   MAT2 m = {{0,1}, {0,0}, {0,0}, {0,1}};
   PangoWin32GlyphInfo *info;
 
+  if (glyph == PANGO_GLYPH_EMPTY)
+    {
+      if (ink_rect)
+	ink_rect->x = ink_rect->width = ink_rect->y = ink_rect->height = 0;
+      if (logical_rect)
+	logical_rect->x = logical_rect->width = logical_rect->y = logical_rect->height = 0;
+      return;
+    }
+
   if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
     glyph_index = glyph = 0;
 
@@ -467,17 +477,7 @@ pango_win32_font_get_glyph_extents (Pang
   
   if (!info)
     {
-      info = g_new (PangoWin32GlyphInfo, 1);
-
-      info->ink_rect.x = 0;
-      info->ink_rect.width = 0;
-      info->ink_rect.y = 0;
-      info->ink_rect.height = 0;
-
-      info->logical_rect.x = 0;
-      info->logical_rect.width = 0;
-      info->logical_rect.y = 0;
-      info->logical_rect.height = 0;
+      info = g_new0 (PangoWin32GlyphInfo, 1);
 
       memset (&gm, 0, sizeof (gm));
 
@@ -1365,7 +1365,8 @@ font_get_cmap (PangoFont *font)
  * @font: a #PangoFont.
  * @wc: a Unicode character.
  *
- * Obtains the index of the glyph for @wc in @font.
+ * Obtains the index of the glyph for @wc in @font, or 0, if not
+ * covered.
  *
  * Return value: the glyph index for @wc.
  **/
@@ -1381,7 +1382,7 @@ pango_win32_font_get_glyph_index (PangoF
   cmap = font_get_cmap (font);
 
   if (cmap == NULL)
-    return PANGO_GLYPH_NULL;
+    return 0;
 
   if (win32font->win32face->cmap_format == 4)
     {
@@ -1394,10 +1395,10 @@ pango_win32_font_get_glyph_index (PangoF
       guint16 ch = wc;
   
       if (wc > 0xFFFF)
-	return PANGO_GLYPH_NULL;
+	return 0;
 
       if (!find_segment (cmap4, ch, &segment))
-	return PANGO_GLYPH_NULL;
+	return 0;
 
       id_range_offset = get_id_range_offset (cmap4);
       id_delta = get_id_delta (cmap4);
@@ -1413,7 +1414,7 @@ pango_win32_font_get_glyph_index (PangoF
 	  if (id)
 	    glyph = (id_delta[segment] + id) %65536;
 	  else
-	    glyph = PANGO_GLYPH_NULL;
+	    glyph = 0;
 	}
     }
   else if (win32font->win32face->cmap_format == 12)
@@ -1421,7 +1422,7 @@ pango_win32_font_get_glyph_index (PangoF
       struct format_12_cmap *cmap12 = cmap;
       guint32 i;
 
-      glyph = PANGO_GLYPH_NULL;
+      glyph = 0;
       for (i = 0; i < cmap12->count; i++)
 	{
 	  if (cmap12->groups[i*3+0] <= wc && wc <= cmap12->groups[i*3+1])
Index: pango/pangox.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangox.c,v
retrieving revision 1.92
diff -u -p -r1.92 pangox.c
--- pango/pangox.c	2 Feb 2006 10:52:49 -0000	1.92
+++ pango/pangox.c	3 Feb 2006 02:42:19 -0000
@@ -399,21 +399,58 @@ pango_x_render  (Display           *disp
        * the ink rect here would be a noticeable speed hit.
        * This is close enough.
        */
-      if (!(glyph != PANGO_GLYPH_NULL &&
+      if (!(glyph != PANGO_GLYPH_EMPTY &&
 	    glyph_x >= -16384 && glyph_x <= 32767 &&
 	    glyph_y >= -16384 && glyph_y <= 32767))
 	goto next_glyph;
 	      
-      if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
-        {
-	  PangoFontMetrics *metrics = pango_font_get_metrics (font,
-							      pango_language_from_string ("en"));
+      if ((glyph & PANGO_GLYPH_UNKNOWN_FLAG) == 0)
+	{
+	  guint16 index = PANGO_X_GLYPH_INDEX (glyph);
+	  guint16 subfont_index = PANGO_X_GLYPH_SUBFONT (glyph);
+	  PangoXSubfontInfo *subfont;
+      
+	  subfont = pango_x_find_subfont (font, subfont_index);
+	  if (subfont)
+	    {
+	      fs = pango_x_get_font_struct (font, subfont);
+	      if (!fs)
+		continue;
+	      
+	      if (fs->fid != old_fid)
+		{
+		  FLUSH;
+		  XSetFont (display, gc, fs->fid);
+		  old_fid = fs->fid;
+		}
+
+	      if (charcount == G_N_ELEMENTS (xcharbuffer) ||
+		  (charcount > 0 && (glyph_y != glyph_y0 ||
+				     glyph_x != expected_x)))
+		FLUSH;
+
+	      if (charcount == 0)
+		{
+		  glyph_x0 = glyph_x;
+		  glyph_y0 = glyph_y;
+		}
+	      xcharbuffer[charcount].byte1 = index / 256;
+	      xcharbuffer[charcount].byte2 = index % 256;
+
+	      expected_x = glyph_x + XTextWidth16 (fs, &xcharbuffer[charcount], 1);
+
+	      charcount++;
+	    } else
+	      goto unknown_glyph;
+	} else {
+	  PangoFontMetrics *metrics;
           int x1, y1, x2, y2; /* rectangle the character should go inside. */
           int baseline;
 	  int stroke_thick;
-
           gunichar wc;
-
+	  
+	unknown_glyph:
+	  metrics = pango_font_get_metrics (font, pango_language_from_string ("en"));
 	  FLUSH;
 
           x1 = glyph_x;
@@ -423,7 +460,10 @@ pango_x_render  (Display           *disp
           baseline = glyph_y;
 	  stroke_thick = MAX ((int) (0.5 + 0.075 * (y2 - y1)), 1);
           
-          wc = glyph & (~PANGO_GLYPH_UNKNOWN_FLAG);
+	  if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+	    wc = glyph & (~PANGO_GLYPH_UNKNOWN_FLAG);
+	  else
+	    wc = 0;
 
           switch (wc)
             {
@@ -518,44 +558,6 @@ pango_x_render  (Display           *disp
 
 	  pango_font_metrics_unref (metrics);
         }
-      else
-	{
-	  guint16 index = PANGO_X_GLYPH_INDEX (glyph);
-	  guint16 subfont_index = PANGO_X_GLYPH_SUBFONT (glyph);
-	  PangoXSubfontInfo *subfont;
-      
-	  subfont = pango_x_find_subfont (font, subfont_index);
-	  if (subfont)
-	    {
-	      fs = pango_x_get_font_struct (font, subfont);
-	      if (!fs)
-		continue;
-	      
-	      if (fs->fid != old_fid)
-		{
-		  FLUSH;
-		  XSetFont (display, gc, fs->fid);
-		  old_fid = fs->fid;
-		}
-
-	      if (charcount == G_N_ELEMENTS (xcharbuffer) ||
-		  (charcount > 0 && (glyph_y != glyph_y0 ||
-				     glyph_x != expected_x)))
-		FLUSH;
-
-	      if (charcount == 0)
-		{
-		  glyph_x0 = glyph_x;
-		  glyph_y0 = glyph_y;
-		}
-	      xcharbuffer[charcount].byte1 = index / 256;
-	      xcharbuffer[charcount].byte2 = index % 256;
-
-	      expected_x = glyph_x + XTextWidth16 (fs, &xcharbuffer[charcount], 1);
-
-	      charcount++;
-	    }
-	}
 
     next_glyph:
       x_off += glyphs->glyphs[i].geometry.width;
@@ -574,7 +576,32 @@ pango_x_font_get_glyph_extents  (PangoFo
   XCharStruct *cs;
   PangoXSubfontInfo *subfont;
 
-  if (glyph != PANGO_GLYPH_NULL && glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+  if (glyph == PANGO_GLYPH_EMPTY)
+    {
+      if (ink_rect)
+	ink_rect->x = ink_rect->width = ink_rect->y = ink_rect->height = 0;
+      if (logical_rect)
+	logical_rect->x = logical_rect->width = logical_rect->y = logical_rect->height = 0;
+      return;
+    }
+  if ((glyph & PANGO_GLYPH_UNKNOWN_FLAG) == 0 && pango_x_find_glyph (font, glyph, &subfont, &cs))
+    {
+      if (ink_rect)
+	{
+	  ink_rect->x = PANGO_SCALE * cs->lbearing;
+	  ink_rect->width = PANGO_SCALE * (cs->rbearing - cs->lbearing);
+	  ink_rect->y = PANGO_SCALE * -cs->ascent;
+	  ink_rect->height = PANGO_SCALE * (cs->ascent + cs->descent);
+	}
+      if (logical_rect)
+	{
+	  logical_rect->x = 0;
+	  logical_rect->width = PANGO_SCALE * cs->width;
+	  logical_rect->y = - PANGO_SCALE * subfont->font_struct->ascent;
+	  logical_rect->height = PANGO_SCALE * (subfont->font_struct->ascent + subfont->font_struct->descent);
+	}
+    }
+  else
     {
       PangoFontMetrics *metrics = pango_font_get_metrics (font,
 							  pango_language_from_string ("en"));
@@ -582,7 +609,10 @@ pango_x_font_get_glyph_extents  (PangoFo
       gdouble width_factor;
       int w;
       
-      wc = glyph & (~PANGO_GLYPH_UNKNOWN_FLAG);
+      if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+	wc = glyph & (~PANGO_GLYPH_UNKNOWN_FLAG);
+      else
+        wc = 0;
           
       switch (wc)
         {
@@ -623,40 +653,6 @@ pango_x_font_get_glyph_extents  (PangoFo
 	}
       
     }
-  else if (glyph != PANGO_GLYPH_NULL && pango_x_find_glyph (font, glyph, &subfont, &cs))
-    {
-      if (ink_rect)
-	{
-	  ink_rect->x = PANGO_SCALE * cs->lbearing;
-	  ink_rect->width = PANGO_SCALE * (cs->rbearing - cs->lbearing);
-	  ink_rect->y = PANGO_SCALE * -cs->ascent;
-	  ink_rect->height = PANGO_SCALE * (cs->ascent + cs->descent);
-	}
-      if (logical_rect)
-	{
-	  logical_rect->x = 0;
-	  logical_rect->width = PANGO_SCALE * cs->width;
-	  logical_rect->y = - PANGO_SCALE * subfont->font_struct->ascent;
-	  logical_rect->height = PANGO_SCALE * (subfont->font_struct->ascent + subfont->font_struct->descent);
-	}
-    }
-  else
-    {
-      if (ink_rect)
-	{
-	  ink_rect->x = 0;
-	  ink_rect->width = 0;
-	  ink_rect->y = 0;
-	  ink_rect->height = 0;
-	}
-      if (logical_rect)
-	{
-	  logical_rect->x = 0;
-	  logical_rect->width = 0;
-	  logical_rect->y = 0;
-	  logical_rect->height = 0;
-	}
-    }
 }
 
 static gboolean
@@ -701,7 +697,7 @@ itemize_string_foreach (PangoFont     *f
   PangoGlyphString *glyph_str = pango_glyph_string_new ();
   PangoEngineShape *shaper, *last_shaper;
   int last_level;
-  long n_chars, i;
+  int i;
   guint8 *embedding_levels;
   PangoDirection base_dir = PANGO_DIRECTION_LTR;
   gboolean finished = FALSE;
Index: pango/pangoxft-font.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangoxft-font.c,v
retrieving revision 1.69
diff -u -p -r1.69 pangoxft-font.c
--- pango/pangoxft-font.c	2 Feb 2006 11:30:35 -0000	1.69
+++ pango/pangoxft-font.c	3 Feb 2006 02:42:20 -0000
@@ -172,7 +172,7 @@ _pango_xft_font_get_mini_font (PangoXftF
       
       xfont->mini_width = PANGO_SCALE * width;
       xfont->mini_height = PANGO_SCALE * height;
-      xfont->mini_pad = PANGO_SCALE * MAX (height / 10, 1);
+      xfont->mini_pad = PANGO_SCALE * MAX ((int)(2.2 * height + 27) / 28, 1);
     }
 
   return xfont->mini_font;
@@ -325,27 +325,16 @@ pango_xft_font_get_glyph_extents (PangoF
   if (!fcfont->fontmap)		/* Display closed */
     goto fallback;
 
-  if (glyph == PANGO_GLYPH_NULL)
+  if (glyph == PANGO_GLYPH_EMPTY)
     {
     fallback:
-      
       if (ink_rect)
-	{
-	  ink_rect->x = 0;
-	  ink_rect->width = 0;
-	  ink_rect->y = 0;
-	  ink_rect->height = 0;
-	}
+	ink_rect->x = ink_rect->width = ink_rect->y = ink_rect->height = 0;
       if (logical_rect)
-	{
-	  logical_rect->x = 0;
-	  logical_rect->width = 0;
-	  logical_rect->y = 0;
-	  logical_rect->height = 0;
-	}
+	logical_rect->x = logical_rect->width = logical_rect->y = logical_rect->height = 0;
       return;
     }
-  else if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+  if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
     {
       get_glyph_extents_missing (xfont, glyph, ink_rect, logical_rect);
     }
@@ -449,7 +438,7 @@ pango_xft_font_real_get_glyph (PangoFcFo
 			       gunichar     wc)
 {
   XftFont *xft_font = xft_font_get_font ((PangoFont *)font);
-
+  
   return XftCharIndex (NULL, xft_font, wc);
 }
 
@@ -484,7 +473,7 @@ pango_xft_font_get_font (PangoFont *font
       if (!_pango_xft_warning_history.get_font)
         {
 	  _pango_xft_warning_history.get_font = TRUE;
-	  g_critical ("pango_xft_font_get_font called with font == NULL, expect ugly output");
+	  g_critical ("pango_xft_font_get_font called with bad font, expect ugly output");
 	}
       return NULL;
     }
@@ -587,7 +576,7 @@ pango_xft_font_unlock_face (PangoFont *f
  * 
  * Use pango_fc_font_get_glyph() instead.
  *
- * Return value: the glyph index, or %PANGO_GLYPH_NULL, if the Unicode
+ * Return value: the glyph index, or 0, if the Unicode
  *  character does not exist in the font.
  *
  * Since: 1.2
@@ -596,7 +585,7 @@ guint
 pango_xft_font_get_glyph (PangoFont *font,
 			  gunichar   wc)
 {
-  g_return_val_if_fail (PANGO_XFT_IS_FONT (font), PANGO_GLYPH_NULL);
+  g_return_val_if_fail (PANGO_XFT_IS_FONT (font), 0);
 
   return pango_fc_font_get_glyph (PANGO_FC_FONT (font), wc);
 }
Index: pango/pangoxft-render.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangoxft-render.c,v
retrieving revision 1.14
diff -u -p -r1.14 pangoxft-render.c
--- pango/pangoxft-render.c	2 Feb 2006 12:07:17 -0000	1.14
+++ pango/pangoxft-render.c	3 Feb 2006 02:42:20 -0000
@@ -68,11 +68,6 @@ static void pango_xft_renderer_draw_glyp
 					       PangoGlyphString *glyphs,
 					       int               x,
 					       int               y);
-static void pango_xft_renderer_draw_glyph     (PangoRenderer    *renderer,
-					       PangoFont        *font,
-					       PangoGlyph        glyph,
-					       double            x,
-					       double            y);
 static void pango_xft_renderer_draw_trapezoid (PangoRenderer    *renderer,
 					       PangoRenderPart   part,
 					       double            y1,
@@ -109,7 +104,6 @@ pango_xft_renderer_class_init (PangoXftR
   klass->composite_trapezoids = pango_xft_renderer_real_composite_trapezoids;
 
   renderer_class->draw_glyphs = pango_xft_renderer_draw_glyphs;
-  renderer_class->draw_glyph = pango_xft_renderer_draw_glyph;
   renderer_class->draw_trapezoid = pango_xft_renderer_draw_trapezoid;
   renderer_class->part_changed = pango_xft_renderer_part_changed;
   renderer_class->end = pango_xft_renderer_end;
@@ -314,6 +308,88 @@ draw_box (PangoRenderer *renderer,
 }
 
 static void
+_pango_xft_renderer_draw_box_glyph (PangoRenderer    *renderer,
+				    PangoGlyphInfo   *gi,
+				    int               glyph_x,
+				    int               glyph_y)
+{
+  int x = glyph_x + PANGO_SCALE;
+  int y = glyph_y - PANGO_SCALE * (PANGO_UNKNOWN_GLYPH_HEIGHT - 1);
+  int width = gi->geometry.width - PANGO_SCALE * 2;
+  int height = PANGO_SCALE * (PANGO_UNKNOWN_GLYPH_HEIGHT - 2);
+
+  if (box_in_bounds (renderer, x, y, width, height))
+    draw_box (renderer, PANGO_SCALE, x, y, width, height);
+}
+
+static void
+_pango_xft_renderer_draw_unknown_glyph (PangoRenderer    *renderer,
+					PangoXftFont     *xfont,
+					XftFont          *xft_font,
+					PangoGlyphInfo   *gi,
+					int               glyph_x,
+					int               glyph_y)
+{
+  char buf[7];
+  int ys[3];
+  int xs[4];
+  int row, col;
+  int cols;
+  PangoGlyph glyph;
+  
+  PangoFont *mini_font = _pango_xft_font_get_mini_font (xfont);
+  XftFont *mini_xft_font = pango_xft_font_get_font (mini_font);
+  if (!mini_xft_font)
+    {
+      _pango_xft_renderer_draw_box_glyph (renderer, gi, glyph_x, glyph_y);
+      return;
+    }
+  
+  glyph = gi->glyph & ~PANGO_GLYPH_UNKNOWN_FLAG;
+  
+  ys[0] = glyph_y - PANGO_SCALE * xft_font->ascent + PANGO_SCALE * (((xft_font->ascent + xft_font->descent) - (xfont->mini_height * 2 + xfont->mini_pad * 5 + PANGO_SCALE / 2) / PANGO_SCALE) / 2);
+  ys[1] = ys[0] + 2 * xfont->mini_pad + xfont->mini_height;
+  ys[2] = ys[1] + xfont->mini_height + xfont->mini_pad;
+
+  xs[0] = glyph_x; 
+  xs[1] = xs[0] + 2 * xfont->mini_pad;
+  xs[2] = xs[1] + xfont->mini_width + xfont->mini_pad;
+  xs[3] = xs[2] + xfont->mini_width + xfont->mini_pad;
+
+  if (glyph > 0xffff)
+    {
+      cols = 3;
+      g_snprintf (buf, sizeof(buf), "%06X", glyph);
+    }
+  else
+    {
+      cols = 2;
+      g_snprintf (buf, sizeof(buf), "%04X", glyph);
+    }
+
+  if (box_in_bounds (renderer,
+		     xs[0], ys[0],
+		     xfont->mini_width * cols + xfont->mini_pad * (2 * cols + 1),
+		     xfont->mini_height * 2 + xfont->mini_pad * 5))
+    {
+      draw_box (renderer, xfont->mini_pad,
+		xs[0], ys[0],
+		xfont->mini_width * cols + xfont->mini_pad * (2 * cols + 1),
+		xfont->mini_height * 2 + xfont->mini_pad * 5);
+      
+      for (row = 0; row < 2; row++)
+	for (col = 0; col < cols; col++)
+	  {
+	    draw_glyph (renderer, mini_font,
+			XftCharIndex (NULL, mini_xft_font,
+				      buf[row * cols + col] & 0xff),
+			xs[col+1],
+			ys[row+1]);
+	  }
+    }
+}
+
+static void
 pango_xft_renderer_draw_glyphs (PangoRenderer    *renderer,
 				PangoFont        *font,
 				PangoGlyphString *glyphs,
@@ -330,22 +406,17 @@ pango_xft_renderer_draw_glyphs (PangoRen
     {
       for (i=0; i<glyphs->num_glyphs; i++)
 	{
-	  PangoGlyph glyph = glyphs->glyphs[i].glyph;
-	  int glyph_x = x + x_off + glyphs->glyphs[i].geometry.x_offset;
-	  int glyph_y = y + glyphs->glyphs[i].geometry.y_offset;
+	  PangoGlyphInfo *gi = &glyphs->glyphs[i];
 
-	  if (glyph != PANGO_GLYPH_NULL && glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+	  if (gi->glyph != PANGO_GLYPH_EMPTY)
 	    {
-	      int x = glyph_x + PANGO_SCALE;
-	      int y = glyph_y + PANGO_SCALE;
-	      int width = PANGO_SCALE * (PANGO_UNKNOWN_GLYPH_WIDTH - 2);
-	      int height = PANGO_SCALE * (PANGO_UNKNOWN_GLYPH_HEIGHT - 2);
+	      int glyph_x = x + x_off + gi->geometry.x_offset;
+	      int glyph_y = y + gi->geometry.y_offset;
 
-	      if (box_in_bounds (renderer, x, y, width, height))
-		draw_box (renderer, PANGO_SCALE, x, y, width, height);
+	      _pango_xft_renderer_draw_box_glyph (renderer, gi, glyph_x, glyph_y);
 	    }
 
-          x_off += glyphs->glyphs[i].geometry.width;
+          x_off += gi->geometry.width;
 	}
       return;
     }
@@ -355,84 +426,30 @@ pango_xft_renderer_draw_glyphs (PangoRen
 
   for (i=0; i<glyphs->num_glyphs; i++)
     {
-      PangoGlyph glyph = glyphs->glyphs[i].glyph;
-      int glyph_x = x + x_off + glyphs->glyphs[i].geometry.x_offset;
-      int glyph_y = y + glyphs->glyphs[i].geometry.y_offset;
+      PangoGlyphInfo *gi = &glyphs->glyphs[i];
 
-      if (glyph != PANGO_GLYPH_NULL)
+      if (gi->glyph != PANGO_GLYPH_EMPTY)
 	{
-	  if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+	  int glyph_x = x + x_off + gi->geometry.x_offset;
+	  int glyph_y = y + gi->geometry.y_offset;
+
+	  if (gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG)
 	    {
-	      char buf[7];
-	      int ys[3];
-	      int xs[4];
-	      int row, col;
-              int cols;
-	      
-	      PangoFont *mini_font = _pango_xft_font_get_mini_font (xfont);
-	      XftFont *mini_xft_font = pango_xft_font_get_font (mini_font);
-	      
-	      glyph &= ~PANGO_GLYPH_UNKNOWN_FLAG;
-	      
-	      ys[0] = glyph_y - PANGO_SCALE * xft_font->ascent + PANGO_SCALE * (((xft_font->ascent + xft_font->descent) - (xfont->mini_height * 2 + xfont->mini_pad * 5 + PANGO_SCALE / 2) / PANGO_SCALE) / 2);
-	      ys[1] = ys[0] + 2 * xfont->mini_pad + xfont->mini_height;
-	      ys[2] = ys[1] + xfont->mini_height + xfont->mini_pad;
-
-	      xs[0] = glyph_x; 
-	      xs[1] = xs[0] + 2 * xfont->mini_pad;
-	      xs[2] = xs[1] + xfont->mini_width + xfont->mini_pad;
-	      xs[3] = xs[2] + xfont->mini_width + xfont->mini_pad;
-
-	      if (glyph > 0xffff)
-		{
-		  cols = 3;
-		  g_snprintf (buf, sizeof(buf), "%06X", glyph);
-		}
-	      else
-		{
-		  cols = 2;
-		  g_snprintf (buf, sizeof(buf), "%04X", glyph);
-		}
-
-	      if (box_in_bounds (renderer,
-				 xs[0], ys[0],
-				 xfont->mini_width * cols + xfont->mini_pad * (2 * cols + 1),
-				 xfont->mini_height * 2 + xfont->mini_pad * 5))
-		{
-		  draw_box (renderer, xfont->mini_pad,
-			    xs[0], ys[0],
-			    xfont->mini_width * cols + xfont->mini_pad * (2 * cols + 1),
-			    xfont->mini_height * 2 + xfont->mini_pad * 5);
-		  
-		  for (row = 0; row < 2; row++)
-		    for (col = 0; col < cols; col++)
-		      {
-			draw_glyph (renderer, mini_font,
-				    XftCharIndex (NULL, mini_xft_font,
-						  buf[row * cols + col] & 0xff),
-				    xs[col+1],
-				    ys[row+1]);
-		      }
-		}
+	      _pango_xft_renderer_draw_unknown_glyph (renderer,
+						      xfont,
+						      xft_font,
+						      gi,
+						      glyph_x,
+						      glyph_y);
 	    }
 	  else
 	    {
-	      draw_glyph (renderer, font, glyph, glyph_x, glyph_y);
+	      draw_glyph (renderer, font, gi->glyph, glyph_x, glyph_y);
 	    }
 	}
       
-      x_off += glyphs->glyphs[i].geometry.width;
+      x_off += gi->geometry.width;
     }
-}
-
-static void
-pango_xft_renderer_draw_glyph (PangoRenderer   *renderer,
-			       PangoFont       *font,
-			       PangoGlyph       glyph,
-			       double           x,
-			       double           y)
-{
-  g_critical ("pango_xft_renderer_draw_glyph(): should not be called");
 }
 
 static void
Index: pango/shape.c
===================================================================
RCS file: /cvs/gnome/pango/pango/shape.c,v
retrieving revision 1.18
diff -u -p -r1.18 shape.c
--- pango/shape.c	2 Feb 2006 10:57:19 -0000	1.18
+++ pango/shape.c	3 Feb 2006 02:42:20 -0000
@@ -46,7 +46,7 @@ pango_shape (const gchar      *text, 
   int i;
   int last_cluster = -1;
 
-  if (G_LIKELY (analysis->shape_engine && analysis->font))
+  if (G_LIKELY (PANGO_IS_ENGINE_SHAPE (analysis->shape_engine) && PANGO_IS_FONT (analysis->font)))
     {
       _pango_engine_shape_shape (analysis->shape_engine, analysis->font,
 				 text, length, analysis, glyphs);
@@ -84,15 +84,17 @@ pango_shape (const gchar      *text, 
     }
   else
     {
-      if (!analysis->shape_engine && !_pango_warning_history.shape_shape_engine)
+      if (!PANGO_IS_ENGINE_SHAPE (analysis->shape_engine) &&
+	  !_pango_warning_history.shape_shape_engine)
         {
 	  _pango_warning_history.shape_font = TRUE;
-	  g_critical ("pango_shape called with analysis->shape_engine == NULL, expect ugly output");
+	  g_critical ("pango_shape called with bad shape_engine, expect ugly output");
 	}
-      if (!analysis->font && !_pango_warning_history.shape_font)
+      if (!PANGO_IS_FONT (analysis->font) &&
+	  !_pango_warning_history.shape_font)
         {
 	  _pango_warning_history.shape_font = TRUE;
-	  g_critical ("pango_shape called with analysis->font == NULL, expect ugly output");
+	  g_critical ("pango_shape called with bad font, expect ugly output");
 	}
 
       glyphs->num_glyphs = 0;
@@ -100,28 +102,10 @@ pango_shape (const gchar      *text, 
 
   if (!glyphs->num_glyphs)
     {
-      /* If failed to get glyphs, put unknown glyphs for all characters
-       */
-      const char *p = text;
-      pango_glyph_string_set_size (glyphs, g_utf8_strlen (text, length));
+      PangoEngineShape *fallback_engine = _pango_get_fallback_shaper ();
 
-      for (i = 0; i < glyphs->num_glyphs; i++)
-        {
-	  PangoRectangle logical_rect;
-	  PangoGlyph glyph = g_utf8_get_char (p) | PANGO_GLYPH_UNKNOWN_FLAG;
-	  
-	  pango_font_get_glyph_extents (analysis->font, glyph, NULL, &logical_rect);
-
-	  glyphs->glyphs[i].glyph = glyph;
-	  
-	  glyphs->glyphs[i].geometry.x_offset = 0;
-	  glyphs->glyphs[i].geometry.y_offset = 0;
-	  glyphs->glyphs[i].geometry.width = logical_rect.width;
-	  
-	  glyphs->log_clusters[i] = i;
-
-	  p = g_utf8_next_char (p);
-	}
+      _pango_engine_shape_shape (fallback_engine, analysis->font,
+				 text, length, analysis, glyphs);
     }
 
   /* Set glyphs[i].attr.is_cluster_start based on log_clusters[]

