Index: pango/pangocairo-atsuifont.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-atsuifont.c,v
retrieving revision 1.1
diff -u -p -r1.1 pangocairo-atsuifont.c
--- pango/pangocairo-atsuifont.c	22 Nov 2005 09:12:05 -0000	1.1
+++ pango/pangocairo-atsuifont.c	4 Jan 2006 02:11:11 -0000
@@ -68,15 +68,6 @@ pango_cairo_atsui_font_install (PangoCai
   cairo_set_font_options (cr, cwfont->options);
 }
 
-static void
-cairo_font_iface_init (PangoCairoFontIface *iface)
-{
-  iface->install = pango_cairo_atsui_font_install;
-}
-
-G_DEFINE_TYPE_WITH_CODE (PangoCairoATSUIFont, pango_cairo_atsui_font, PANGO_TYPE_ATSUI_FONT,
-    { G_IMPLEMENT_INTERFACE (PANGO_TYPE_CAIRO_FONT, cairo_font_iface_init) });
-
 static cairo_font_face_t *
 pango_cairo_atsui_font_get_font_face (PangoCairoFont *font)
 {
@@ -114,6 +105,17 @@ pango_cairo_atsui_font_get_scaled_font (
   
   return cafont->scaled_font;
 }
+
+static void
+cairo_font_iface_init (PangoCairoFontIface *iface)
+{
+  iface->install = pango_cairo_atsui_font_install;
+  iface->get_font_face = pango_cairo_atsui_font_get_font_face;
+  iface->get_scaled_font = pango_cairo_atsui_font_get_scaled_font;
+}
+
+G_DEFINE_TYPE_WITH_CODE (PangoCairoATSUIFont, pango_cairo_atsui_font, PANGO_TYPE_ATSUI_FONT,
+    { G_IMPLEMENT_INTERFACE (PANGO_TYPE_CAIRO_FONT, cairo_font_iface_init) });
 
 static void
 pango_cairo_atsui_font_get_glyph_extents (PangoFont        *font,
Index: pango/pangocairo-fcfont.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-fcfont.c,v
retrieving revision 1.22
diff -u -p -r1.22 pangocairo-fcfont.c
--- pango/pangocairo-fcfont.c	12 Dec 2005 23:25:47 -0000	1.22
+++ pango/pangocairo-fcfont.c	4 Jan 2006 02:11:12 -0000
@@ -189,6 +189,8 @@ static void
 cairo_font_iface_init (PangoCairoFontIface *iface)
 {
   iface->install = pango_cairo_fc_font_install;
+  iface->get_font_face = pango_cairo_fc_font_get_font_face;
+  iface->get_scaled_font = pango_cairo_fc_font_get_scaled_font;
 }
 
 G_DEFINE_TYPE_WITH_CODE (PangoCairoFcFont, pango_cairo_fc_font, PANGO_TYPE_FC_FONT,
@@ -363,8 +365,7 @@ pango_cairo_fc_font_glyph_extents_cache_
   cffont->font_extents.x = 0;
   cffont->font_extents.y = - font_extents.ascent * PANGO_SCALE;
   cffont->font_extents.height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE;
-  /* The width is only used for the width of box drawn for glyph-not-found */
-  cffont->font_extents.width = (font_extents.ascent - font_extents.descent) * PANGO_SCALE;
+  cffont->font_extents.width = 0;
 
   cffont->glyph_extents_cache = g_new0 (GlyphExtentsCacheEntry, GLYPH_CACHE_NUM_ENTRIES);
   /* Make sure all cache entries are invalid initially */
@@ -445,8 +446,18 @@ 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 || glyph & PANGO_CAIRO_UNKNOWN_FLAG)
+  if (glyph & PANGO_CAIRO_UNKNOWN_FLAG) 
+    {
+      int *logical_width = NULL;
+      if (logical_rect)
+        {
+	  *logical_rect = cffont->font_extents;
+	  logical_width = &logical_rect->width;
+	}
+      _pango_cairo_get_glyph_extents_missing((PangoCairoFont *)font, glyph, ink_rect, logical_width);
+      return;
+    }
+  else if (!glyph)
     {
       if (ink_rect)
 	*ink_rect = cffont->font_extents;
@@ -537,7 +548,7 @@ get_font_size (PangoCairoFcFontMap      
 	       PangoContext               *context,
 	       const PangoFontDescription *desc,
 	       FcPattern                  *pattern,
-	       PangoMatrix                *matrix)
+	       const PangoMatrix          *matrix)
 {
   double size;
 
Index: pango/pangocairo-font.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-font.c,v
retrieving revision 1.5
diff -u -p -r1.5 pangocairo-font.c
--- pango/pangocairo-font.c	4 Nov 2005 23:55:37 -0000	1.5
+++ pango/pangocairo-font.c	4 Jan 2006 02:11:12 -0000
@@ -69,3 +69,147 @@ _pango_cairo_font_install (PangoCairoFon
   
   (* PANGO_CAIRO_FONT_GET_IFACE (font)->install) (font, cr);
 }
+
+cairo_font_face_t *
+_pango_cairo_font_get_font_face (PangoCairoFont *font)
+{
+  g_return_if_fail (PANGO_IS_CAIRO_FONT (font));
+  
+  (* PANGO_CAIRO_FONT_GET_IFACE (font)->get_font_face) (font);
+}
+
+cairo_scaled_font_t *
+_pango_cairo_font_get_scaled_font (PangoCairoFont *font)
+{
+  g_return_if_fail (PANGO_IS_CAIRO_FONT (font));
+  
+  (* PANGO_CAIRO_FONT_GET_IFACE (font)->get_scaled_font) (font);
+}
+
+static void
+_pango_cairo_hex_box_info_destroy (PangoCairoHexBoxInfo *hbi)
+{
+  if (hbi)
+    {
+      g_object_unref (hbi->font);
+      g_slice_free (PangoCairoHexBoxInfo, hbi);
+    }
+}  
+   
+PangoCairoHexBoxInfo *
+_pango_cairo_get_hex_box_info (PangoCairoFont *cfont)
+{
+  PangoFont *mini_font;
+  PangoCairoFont *mini_cfont;
+  PangoCairoHexBoxInfo *hbi;
+  int new_size;
+  int i;
+  double width = 0;
+  double height = 0;
+  cairo_font_extents_t font_extents;
+  const char hexdigits[] = "0123456789ABCDEF";
+  PangoFontMap *fontmap, *mini_fontmap;
+  PangoFontDescription *mini_desc, *desc;
+  PangoContext *context, *mini_context;
+  cairo_scaled_font_t *scaled_font;
+  cairo_surface_t *surface;
+  cairo_t *cr;
+  char c[2] = {0, 0};
+
+  hbi = (PangoCairoHexBoxInfo *) g_object_get_data (G_OBJECT (cfont), "hex_box_info");
+  if (hbi)
+    return hbi;
+
+  fontmap = pango_font_get_font_map ((PangoFont *)cfont);
+  g_assert (fontmap);
+
+  mini_desc = pango_font_description_new ();
+
+  context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
+  pango_context_set_language (context, pango_language_from_string ("en"));
+
+  pango_font_description_set_family_static (mini_desc, "monospace");
+
+  desc = pango_font_describe ((PangoFont *)cfont);
+
+  new_size = pango_font_description_get_size (desc) / 2;
+
+  if (pango_font_description_get_size_is_absolute (desc))
+      pango_font_description_set_absolute_size (mini_desc, new_size);
+  else
+      pango_font_description_set_size (mini_desc, new_size);
+
+  mini_font = pango_font_map_load_font (fontmap, context, mini_desc);
+
+  mini_fontmap = pango_font_get_font_map (mini_font);
+  mini_context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (mini_fontmap));
+
+  mini_cfont = (PangoCairoFont *) mini_font;
+  scaled_font = _pango_cairo_font_get_scaled_font (cfont);  
+
+  surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 0, 0);
+  cr = cairo_create (surface);
+  _pango_cairo_font_install (mini_cfont, cr);
+  cairo_surface_destroy (surface);
+
+  for (i = 0 ; i < 16 ; i++)
+    {
+      cairo_text_extents_t extents;
+
+      c[0] = hexdigits[i];
+      cairo_text_extents (cr, c, &extents);      
+      width = MAX (width, extents.width);
+      height = MAX (height, extents.height);
+    }
+
+  cairo_destroy (cr);
+  cairo_scaled_font_extents (scaled_font, &font_extents);
+
+  pango_font_description_free (desc);
+  pango_font_description_free (mini_desc);
+  g_object_unref (context);
+  g_object_unref (mini_context);
+
+  hbi = g_slice_new (PangoCairoHexBoxInfo);
+  hbi->font = mini_font;
+
+  hbi->digit_width = width;
+  hbi->digit_height = height;
+
+  hbi->pad = hbi->digit_height / 10;
+
+  hbi->box_height = 5 * hbi->pad + 2 * hbi->digit_height;
+  hbi->box_descent = font_extents.descent -
+		    (font_extents.ascent + font_extents.descent - hbi->box_height) / 2;
+  
+  g_object_set_data_full (G_OBJECT (cfont), "hex_box_info", hbi, (GDestroyNotify)_pango_cairo_hex_box_info_destroy); 
+
+  return hbi;
+}
+
+void
+_pango_cairo_get_glyph_extents_missing (PangoCairoFont *cfont,
+				        PangoGlyph      glyph,
+				        PangoRectangle *ink_rect,
+				        int            *logical_width)
+{
+  PangoCairoHexBoxInfo *hbi;  
+  gint cols;
+
+  cols = (glyph & ~PANGO_CAIRO_UNKNOWN_FLAG) > 0xffff ? 3 : 2;
+  hbi = _pango_cairo_get_hex_box_info (cfont);
+  
+  if (ink_rect)
+    {
+      ink_rect->x = PANGO_SCALE * hbi->pad;
+      ink_rect->y = PANGO_SCALE * (hbi->box_descent - hbi->box_height);
+      ink_rect->width = PANGO_SCALE * (3 * hbi->pad + cols * (hbi->digit_width + hbi->pad));
+      ink_rect->height = PANGO_SCALE * hbi->box_height;
+    }
+  
+  if (logical_width)
+    {
+      *logical_width = PANGO_SCALE * (5 * hbi->pad + cols * (hbi->digit_width + hbi->pad));
+    }  
+}
+
Index: pango/pangocairo-private.h
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-private.h,v
retrieving revision 1.6
diff -u -p -r1.6 pangocairo-private.h
--- pango/pangocairo-private.h	6 Dec 2005 01:20:46 -0000	1.6
+++ pango/pangocairo-private.h	4 Jan 2006 02:11:12 -0000
@@ -60,12 +60,18 @@ struct _PangoCairoFontIface
 
   void (*install) (PangoCairoFont *font,
 		   cairo_t        *cr);
+
+  cairo_font_face_t *(*get_font_face) (PangoCairoFont *font);
+
+  cairo_scaled_font_t *(*get_scaled_font) (PangoCairoFont *font);
 };
 
 GType pango_cairo_font_get_type (void);
 
 void _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);
 
 #define PANGO_TYPE_CAIRO_RENDERER            (pango_cairo_renderer_get_type())
 #define PANGO_CAIRO_RENDERER(object)         (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_CAIRO_RENDERER, PangoCairoRenderer))
@@ -77,6 +83,25 @@ GType pango_cairo_renderer_get_type    (
 
 const cairo_font_options_t *_pango_cairo_context_get_merged_font_options (PangoContext *context);
 
+
+typedef struct _PangoCairoHexBoxInfo PangoCairoHexBoxInfo;
+
+struct _PangoCairoHexBoxInfo
+{
+	PangoFont *font;
+	double digit_width;
+	double digit_height;
+	double pad;
+	double box_descent;
+	double box_height;
+};
+
+PangoCairoHexBoxInfo *_pango_cairo_get_hex_box_info (PangoCairoFont *font);
+
+void _pango_cairo_get_glyph_extents_missing (PangoCairoFont *cfont,
+					     PangoGlyph      glyph,
+					     PangoRectangle *ink_rect,
+					     int            *logical_width);
 
 G_END_DECLS
 
Index: pango/pangocairo-render.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-render.c,v
retrieving revision 1.10
diff -u -p -r1.10 pangocairo-render.c
--- pango/pangocairo-render.c	6 Dec 2005 01:20:46 -0000	1.10
+++ pango/pangocairo-render.c	4 Jan 2006 02:11:12 -0000
@@ -55,6 +55,71 @@ set_color (PangoCairoRenderer *crenderer
 			  color->green / 65535.,
 			  color->blue / 65535.);
 }
+
+static void
+_pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
+					  PangoFont          *font,
+					  PangoGlyphInfo     *gi,
+					  double              cx,
+					  double              cy)
+{
+  char buf[7];
+  double ys[2];
+  double xs[3];
+  int row, col;
+  int cols;
+  char hexbox_string[2] = {0, 0};
+  double temp_x, temp_y;
+  PangoCairoHexBoxInfo *hbi;
+  gunichar ch;
+
+  hbi = _pango_cairo_get_hex_box_info ((PangoCairoFont *)font);      
+
+  ch = gi->glyph & ~PANGO_CAIRO_UNKNOWN_FLAG;
+
+  cols = ch > 0xffff ? 3 : 2;
+  g_snprintf (buf, sizeof(buf), cols == 2 ? "%04X" : "%06X", ch);
+
+  ys[1] = cy + hbi->box_descent - hbi->pad * 2;
+  ys[0] = ys[1] - hbi->digit_height - hbi->pad;
+
+  xs[0] = cx + hbi->pad * 3.0;
+  xs[1] = xs[0] + hbi->digit_width + hbi->pad;
+  xs[2] = xs[1] + hbi->digit_width + hbi->pad;
+
+  cairo_save (crenderer->cr);
+  cairo_get_current_point (crenderer->cr, &temp_x, &temp_y);
+
+  cairo_rectangle (crenderer->cr,
+		   cx + hbi->pad * 1.5,
+		   cy + hbi->box_descent - hbi->pad * 0.5,
+		   (double)gi->geometry.width / PANGO_SCALE - 3 * hbi->pad,
+		   -(hbi->box_height - hbi->pad));
+
+  if (!crenderer->do_path)
+    {
+      cairo_save (crenderer->cr);
+      cairo_set_line_width (crenderer->cr, hbi->pad);
+      cairo_stroke (crenderer->cr);
+      cairo_restore (crenderer->cr);
+    }
+
+  _pango_cairo_font_install (PANGO_CAIRO_FONT (hbi->font), crenderer->cr);
+  for (row = 0; row < 2; row++)
+      for (col = 0; col < cols; col++)
+	{
+	  hexbox_string[0] = buf[row * cols + col];
+	  cairo_move_to (crenderer->cr, xs[col], ys[row]);
+
+	  if (crenderer->do_path)
+	      cairo_text_path (crenderer->cr, hexbox_string);
+	  else
+	      cairo_show_text (crenderer->cr, hexbox_string);
+	}
+
+  cairo_move_to (crenderer->cr, temp_x, temp_y);
+  cairo_restore (crenderer->cr);
+}
      
 static void
 pango_cairo_renderer_draw_glyphs (PangoRenderer     *renderer,
@@ -91,36 +156,20 @@ pango_cairo_renderer_draw_glyphs (PangoR
       PangoGlyphInfo *gi = &glyphs->glyphs[i];
 
       if (gi->glyph)
-	{
-	  if (gi->glyph & PANGO_CAIRO_UNKNOWN_FLAG)
-	    {
-	      int mini_pad = gi->geometry.width / 10;
-	      /* draw an empty dashed box, no hexbox for now */
-	      cairo_rectangle (crenderer->cr,
-			       crenderer->x_offset + (double)(x + x_position + mini_pad) / PANGO_SCALE,
-			       crenderer->y_offset + (double)(y - mini_pad) / PANGO_SCALE, 
-			       (double)(gi->geometry.width - 2 * mini_pad) / PANGO_SCALE,
-			       -(double)(gi->geometry.width - 2 * mini_pad) / PANGO_SCALE);
-	      if (!crenderer->do_path)
-		{
-		  double dash = (double)mini_pad * 2 / PANGO_SCALE;
-		  cairo_save (crenderer->cr);
-		  cairo_set_line_width (crenderer->cr, (double)mini_pad / PANGO_SCALE);
-		  cairo_set_dash (crenderer->cr, &dash, 1, 0);
-		  cairo_stroke (crenderer->cr);
-		  cairo_restore (crenderer->cr);
-		}
-	    }
-	  else
-	    {
-	      cairo_glyphs[count].index = gi->glyph;
-	      cairo_glyphs[count].x = crenderer->x_offset + (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
-	      cairo_glyphs[count].y = crenderer->y_offset + (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
-
-	      count++;
-	    }
-	}
-	  
+        {
+          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_CAIRO_UNKNOWN_FLAG)
+	    _pango_cairo_renderer_draw_unknown_glyph (crenderer, font, gi, cx, cy);
+          else
+            {
+              cairo_glyphs[count].index = gi->glyph;
+              cairo_glyphs[count].x = cx;
+              cairo_glyphs[count].y = cy;
+              count++;
+            }
+        }	  
       x_position += gi->geometry.width;
     }
 
Index: pango/pangocairo-win32font.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pangocairo-win32font.c,v
retrieving revision 1.15
diff -u -p -r1.15 pangocairo-win32font.c
--- pango/pangocairo-win32font.c	22 Sep 2005 15:00:39 -0000	1.15
+++ pango/pangocairo-win32font.c	4 Jan 2006 02:11:12 -0000
@@ -154,6 +154,8 @@ static void
 cairo_font_iface_init (PangoCairoFontIface *iface)
 {
   iface->install = pango_cairo_win32_font_install;
+  iface->get_font_face = pango_cairo_win32_font_get_font_face;
+  iface->get_scaled_font = pango_cairo_win32_font_get_scaled_font;
 }
 
 G_DEFINE_TYPE_WITH_CODE (PangoCairoWin32Font, pango_cairo_win32_font, PANGO_TYPE_WIN32_FONT,

