On 29/02/12 04:09, Carlos Garcia Campos wrote: > Excerpts from Adrian Johnson's message of mar feb 28 12:15:57 +0100 2012: >> 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 > > Look good to me in general, thanks! some minor comments below. >
I've updated the patches to address all the comments.
>From 18bc59fcf5a59b1fd51a631c02e900790c3a6dc0 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-docs.sgml | 4 ++++ glib/reference/poppler-sections.txt | 1 + 4 files changed, 33 insertions(+), 0 deletions(-) diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index bf83bf0..59124b5 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 *name; + FontInfo *info; + + info = (FontInfo *)iter->items->get (iter->index); + + name = info->getSubstituteName(); + if (name != NULL) { + return name->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..d29ef6b 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-docs.sgml b/glib/reference/poppler-docs.sgml index 390ae67..d15bd18 100644 --- a/glib/reference/poppler-docs.sgml +++ b/glib/reference/poppler-docs.sgml @@ -50,6 +50,10 @@ <title>Index of new symbols in 0.18</title> <xi:include href="xml/api-index-0.18.xml"><xi:fallback /></xi:include> </index> + <index id="api-index-0-20"> + <title>Index of new symbols in 0.20</title> + <xi:include href="xml/api-index-0.20.xml"><xi:fallback /></xi:include> + </index> <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> </book> 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 b666d19308a043206e405c7e9d4ad709d68d331b 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..bbc9b8a 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 a2b008223ad6887f00d76c535f2b0b0f13f52b76 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 | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/glib/demo/selections.c b/glib/demo/selections.c index 881733e..3912dc6 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,15 @@ pgd_selections_render (GtkButton *button, } static void +pgd_selections_copy (GtkButton *button, + PgdSelectionsDemo *demo) +{ + 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 +611,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
