Index: ChangeLog
===================================================================
--- ChangeLog	(revision 1522)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2008-01-13  Davyd Madeley  <davyd@madeley.id.au>
+
+	* gucharmap-charmap.[ch]:
+	- add a to show and compare all of the fonts that implement the
+	  specified codepoint
+
 2007-12-26  Christian Persch  <chpe@gnome.org>
 
 	* gucharmap.desktop.in.in:
Index: gucharmap/gucharmap-charmap.c
===================================================================
--- gucharmap/gucharmap-charmap.c	(revision 1522)
+++ gucharmap/gucharmap-charmap.c	(working copy)
@@ -20,6 +20,7 @@
 
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
+#include <pango/pango.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -39,6 +40,13 @@
   NUM_SIGNALS
 };
 
+enum
+{
+  IMPL_FONTS_FONT_DESC = 0,
+  IMPL_FONTS_FONT_NAME,
+  IMPL_FONTS_N_COLUMNS
+};
+
 static guint gucharmap_charmap_signals[NUM_SIGNALS] = { 0, 0 };
 
 static void
@@ -480,6 +488,79 @@
 #endif /* #if ENABLE_UNIHAN */
 }
 
+static void
+set_impl_fonts (GucharmapCharmap *charmap,
+		gunichar uc)
+{
+  /* get all of the fonts that implement this specific gunichar */
+  PangoContext *context;
+  PangoLayout *layout;
+  PangoFontFamily **families;
+  GtkListStore *store;
+  char *str, utf8[7] = "\0\0\0\0\0\0\0";
+  int i, n;
+
+  store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (
+				  charmap->impl_fonts)));
+  gtk_list_store_clear (store);
+
+  context = gtk_widget_get_pango_context (charmap->impl_fonts);
+  layout = pango_layout_new (context); /* !! unref me */
+
+  /* prepare a Pango layout with this character */
+  /* FIXME -- should use PangoAttrList instead */
+  g_unichar_to_utf8 (uc, utf8);
+  str = g_strdup_printf ("<span fallback=\"false\">%s</span>", utf8);
+  pango_layout_set_markup (layout, str, -1);
+  g_free (str);
+  g_object_set (charmap->preview_renderer, "text", utf8, NULL);
+
+  /* get all of the font families known to Pango */
+  pango_context_list_families (context, &families, &n);
+
+  for (i = 0; i < n; i++)
+  {
+	  PangoFontFamily *family = families[i];
+	  PangoFontFace **faces, *face;
+	  PangoFontDescription *desc;
+	  GtkTreeIter iter;
+	  int o;
+
+	  pango_font_family_list_faces (family, &faces, &o);
+
+	  if (o == 0) continue;
+	  face = faces[0]; /* take the first face */
+	  desc = pango_font_face_describe (face);
+	  pango_font_description_set_size (desc, 80 * PANGO_SCALE);
+
+	  /* set the pre-created layout to the current font description */
+	  pango_layout_set_font_description (layout, desc);
+
+	  if (pango_layout_get_unknown_glyphs_count (layout) > 0)
+	  {
+	  	pango_font_description_free (desc);
+		continue;
+	  }
+
+	  /* append this font to the list */
+	  str = g_strdup_printf ("%s %s",
+			  pango_font_family_get_name (family),
+			  pango_font_face_get_face_name (face));
+
+	  gtk_list_store_append (store, &iter);
+	  gtk_list_store_set (store, &iter,
+			  IMPL_FONTS_FONT_DESC, desc,
+			  IMPL_FONTS_FONT_NAME, str,
+			  -1);
+
+	  g_free (str);
+	  pango_font_description_free (desc);
+  }
+
+  g_free (families);
+  g_object_unref (layout);
+}
+
 static gboolean
 gucharmap_active_char_save (gpointer last_char)
 {
@@ -499,6 +580,8 @@
 
   if (charmap->showing_details_page)
     set_details (charmap, wc);
+  else if (charmap->showing_impl_fonts_page)
+    set_impl_fonts (charmap, wc);
 
   g_idle_add (gucharmap_active_char_save, GUINT_TO_POINTER(wc));
 
@@ -766,6 +849,42 @@
   return scrolled_window;
 }
 
+static GtkWidget *
+make_implementing_fonts_page (GucharmapCharmap *charmap)
+{
+  GtkWidget *scrolled_window = NULL;
+  GtkListStore *store = NULL;
+  GtkCellRenderer *renderer = NULL;
+
+  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_show (scrolled_window);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), 
+                                       GTK_SHADOW_ETCHED_IN);
+  
+  store = gtk_list_store_new (IMPL_FONTS_N_COLUMNS,
+		  		PANGO_TYPE_FONT_DESCRIPTION,
+				G_TYPE_STRING);
+  charmap->impl_fonts = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+  gtk_widget_show (charmap->impl_fonts);
+
+  charmap->preview_renderer = renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_insert_column_with_attributes (
+		  GTK_TREE_VIEW (charmap->impl_fonts), -1, "Preview", renderer,
+		  "font-desc", IMPL_FONTS_FONT_DESC,
+		  NULL);
+  
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_insert_column_with_attributes (
+		  GTK_TREE_VIEW (charmap->impl_fonts), -1, "Font", renderer,
+		  "text", IMPL_FONTS_FONT_NAME,
+		  NULL);
+
+  gtk_container_add (GTK_CONTAINER (scrolled_window), charmap->impl_fonts);
+  return scrolled_window;
+}
+
 static void
 notebook_switch_page (GtkNotebook *notebook,
                       GtkNotebookPage *page /* useless */,
@@ -773,6 +892,7 @@
                       GucharmapCharmap *charmap)
 {
   charmap->showing_details_page = (page_num == 1);
+  charmap->showing_impl_fonts_page = (page_num == 2);
 
   if (charmap->showing_details_page)
     set_details (charmap, gucharmap_table_get_active_character (charmap->chartable));
@@ -783,6 +903,15 @@
       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (charmap->details));
       gtk_text_buffer_set_text (buffer, "", 0);
     }
+
+  if (charmap->showing_impl_fonts_page)
+  {
+    set_impl_fonts (charmap, gucharmap_table_get_active_character (charmap->chartable));
+  }
+  else
+  {
+	  /* FIXME -- do something here? */
+  }
 }
 
 static GtkWidget *
@@ -807,6 +936,9 @@
   gtk_notebook_append_page (
           GTK_NOTEBOOK (notebook), make_details_page (charmap), 
           gtk_label_new_with_mnemonic (_("Character _Details")));
+  gtk_notebook_append_page (
+	  GTK_NOTEBOOK (notebook), make_implementing_fonts_page (charmap),
+	  gtk_label_new_with_mnemonic (_("_Implementing Fonts")));
 
   return notebook;
 }
Index: gucharmap/gucharmap-charmap.h
===================================================================
--- gucharmap/gucharmap-charmap.h	(revision 1522)
+++ gucharmap/gucharmap-charmap.h	(working copy)
@@ -48,8 +48,11 @@
 
   gint _unused_1;
   gboolean showing_details_page;
+  gboolean showing_impl_fonts_page;
 
   GtkWidget *details;  /* GtkTextView * */
+  GtkWidget *impl_fonts;  /* GtkTreeView * */
+  GtkCellRenderer *preview_renderer;
 
   GdkCursor *hand_cursor;
   GdkCursor *regular_cursor;
