Here are some patches that:
- add poppler_fonts_iter_get_substitute_name to the api
- make the glib demo show the substitute name
- add a copy button to the selections demo
>From fca6e91a00618fd58d9bca226d8f49f77ffdc367 Mon Sep 17 00:00:00 2001
From: Adrian Johnson <[email protected]>
Date: Tue, 28 Feb 2012 21:06:38 +1030
Subject: [PATCH 1/3] glib: add poppler_fonts_iter_get_substitute_name

---
 glib/poppler-document.cc            |   27 +++++++++++++++++++++++++++
 glib/poppler-document.h             |    1 +
 glib/reference/poppler-sections.txt |    1 +
 3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index bf83bf0..73bf949 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -1716,6 +1716,33 @@ poppler_fonts_iter_get_name (PopplerFontsIter *iter)
 }
 
 /**
+ * poppler_fonts_iter_get_substitute_name:
+ * @iter: a #PopplerFontsIter
+ *
+ * The name of the substitute font of the font associated with @iter or %NULL if
+ * the font is embedded
+ *
+ * Returns: the name of the substitute font or %NULL y font is emebedded
+ *
+ * Since: 0.20
+ */
+const char *
+poppler_fonts_iter_get_substitute_name (PopplerFontsIter *iter)
+{
+	GooString *file;
+	FontInfo *info;
+
+	info = (FontInfo *)iter->items->get (iter->index);
+
+	file = info->getSubstituteName();
+	if (file != NULL) {
+		return file->getCString();
+	} else {
+		return NULL;
+	}
+}
+
+/**
  * poppler_fonts_iter_get_file_name:
  * @iter: a #PopplerFontsIter
  *
diff --git a/glib/poppler-document.h b/glib/poppler-document.h
index 4ab17c8..4049487 100644
--- a/glib/poppler-document.h
+++ b/glib/poppler-document.h
@@ -246,6 +246,7 @@ PopplerFontsIter *poppler_fonts_iter_copy          (PopplerFontsIter  *iter);
 void              poppler_fonts_iter_free          (PopplerFontsIter  *iter);
 const char       *poppler_fonts_iter_get_name      (PopplerFontsIter  *iter);
 const char       *poppler_fonts_iter_get_full_name (PopplerFontsIter  *iter);
+const char *      poppler_fonts_iter_get_substitute_name (PopplerFontsIter *iter);
 const char       *poppler_fonts_iter_get_file_name (PopplerFontsIter  *iter);
 PopplerFontType   poppler_fonts_iter_get_font_type (PopplerFontsIter  *iter);
 gboolean	  poppler_fonts_iter_is_embedded   (PopplerFontsIter  *iter);
diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt
index c2759b8..08df585 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -156,6 +156,7 @@ poppler_fonts_iter_free
 poppler_fonts_iter_get_name
 poppler_fonts_iter_get_full_name
 poppler_fonts_iter_get_font_type
+poppler_fonts_iter_get_substitute_name
 poppler_fonts_iter_get_file_name
 poppler_fonts_iter_is_embedded
 poppler_fonts_iter_is_subset
-- 
1.7.5.4

>From 2e4adc99c097917e2ef275fdaa029a1133eefec4 Mon Sep 17 00:00:00 2001
From: Adrian Johnson <[email protected]>
Date: Tue, 28 Feb 2012 21:07:06 +1030
Subject: [PATCH 2/3] glib: show substitute font name in demo

---
 glib/demo/fonts.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/glib/demo/fonts.c b/glib/demo/fonts.c
index 07ea589..50bedbd 100644
--- a/glib/demo/fonts.c
+++ b/glib/demo/fonts.c
@@ -155,6 +155,7 @@ pgd_fonts_fill_model (PgdFontsDemo *demo)
 			const gchar *name;
 			const gchar *type;
 			const gchar *embedded;
+			const gchar *substitute;
 			const gchar *filename;
 			gchar       *details;
 
@@ -173,10 +174,11 @@ pgd_fonts_fill_model (PgdFontsDemo *demo)
 				embedded = "Not embedded";
 			}
 
+			substitute = poppler_fonts_iter_get_substitute_name (fonts_iter);
 			filename = poppler_fonts_iter_get_file_name (fonts_iter);
 
-			if (filename)
-				details = g_markup_printf_escaped ("%s\n%s (%s)", type, embedded, filename);
+			if (substitute && filename)
+			    details = g_markup_printf_escaped ("%s\n%s, substituting with <b>%s</b>\n(%s)", type, embedded, substitute, filename);
 			else
 				details = g_markup_printf_escaped ("%s\n%s", type, embedded);
 
-- 
1.7.5.4

>From 93bc7e41372ad5e1f06b83feb7f4850ee67b1429 Mon Sep 17 00:00:00 2001
From: Adrian Johnson <[email protected]>
Date: Tue, 28 Feb 2012 21:38:19 +1030
Subject: [PATCH 3/3] glib: add copy button to selections demo

---
 glib/demo/selections.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/glib/demo/selections.c b/glib/demo/selections.c
index 881733e..3ad7487 100644
--- a/glib/demo/selections.c
+++ b/glib/demo/selections.c
@@ -34,6 +34,7 @@ typedef struct {
 	GtkWidget            *darea;
 	GtkWidget            *fg_color_button;
 	GtkWidget            *bg_color_button;
+	GtkWidget            *copy_button;
 
 	PopplerPage          *page;
 	cairo_surface_t      *surface;
@@ -76,6 +77,7 @@ pgd_selections_clear_selections (PgdSelectionsDemo *demo)
 		cairo_region_destroy (demo->selected_region);
 		demo->selected_region = NULL;
 	}
+	gtk_widget_set_sensitive(demo->copy_button, FALSE);
 }
 
 static void
@@ -146,6 +148,7 @@ pgd_selections_update_seleted_text (PgdSelectionsDemo *demo)
 	if (text) {
 		demo->selected_text = g_utf8_normalize (text, -1, G_NORMALIZE_NFKC);
 		g_free (text);
+		gtk_widget_set_sensitive(demo->copy_button, TRUE);
 	}
 }
 
@@ -430,6 +433,17 @@ pgd_selections_render (GtkButton         *button,
 }
 
 static void
+pgd_selections_copy (GtkButton         *button,
+		     PgdSelectionsDemo *demo)
+{
+	if (demo->selected_text) {
+		GtkClipboard *clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(),
+									GDK_SELECTION_CLIPBOARD);
+		gtk_clipboard_set_text (clipboard, demo->selected_text, -1);
+	}
+}
+
+static void
 pgd_selections_page_selector_value_changed (GtkSpinButton     *spinbutton,
 					    PgdSelectionsDemo *demo)
 {
@@ -599,6 +613,14 @@ pgd_selections_properties_selector_create (PgdSelectionsDemo *demo)
 	gtk_box_pack_start (GTK_BOX (hbox), color_hbox, FALSE, TRUE, 0);
 	gtk_widget_show (color_hbox);
 
+	demo->copy_button = gtk_button_new_with_label ("Copy");
+	g_signal_connect (G_OBJECT (demo->copy_button), "clicked",
+			  G_CALLBACK (pgd_selections_copy),
+			  (gpointer)demo);
+	gtk_box_pack_end (GTK_BOX (hbox), demo->copy_button, FALSE, TRUE, 0);
+	gtk_widget_set_sensitive(demo->copy_button, FALSE);
+	gtk_widget_show (demo->copy_button);
+
 	button = gtk_button_new_with_label ("Render");
 	g_signal_connect (G_OBJECT (button), "clicked",
 			  G_CALLBACK (pgd_selections_render),
-- 
1.7.5.4

_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to