summaryrefslogtreecommitdiff
path: root/backend/pdf
diff options
context:
space:
mode:
authorAntia Puentes <[email protected]>2013-07-10 17:50:18 +0200
committerraveit65 <[email protected]>2017-09-06 18:25:34 +0200
commitf2a0613eaeddc32f0393044ce06bc1709de44842 (patch)
tree0e1e445cdf252d327d48b75e018fb4e7d77c07a8 /backend/pdf
parent7a9f2cc8fa9c783b4b00c7990bc01ec6b64018ab (diff)
downloadatril-f2a0613eaeddc32f0393044ce06bc1709de44842.tar.bz2
atril-f2a0613eaeddc32f0393044ce06bc1709de44842.tar.xz
pdf: Implement ev_document_text_get_text_attrs()
origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-10&id=96b9a1
Diffstat (limited to 'backend/pdf')
-rw-r--r--backend/pdf/ev-poppler.cc53
1 files changed, 53 insertions, 0 deletions
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 20cd8e75..e9bb9a4c 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -2033,12 +2033,65 @@ pdf_document_text_get_text_layout (EvDocumentText *selection,
(PopplerRectangle **)areas, n_areas);
}
+static PangoAttrList *
+pdf_document_text_get_text_attrs (EvDocumentText *document_text,
+ EvPage *page)
+{
+ GList *backend_attrs_list, *l;
+ PangoAttrList *attrs_list;
+
+ g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
+
+ backend_attrs_list = poppler_page_get_text_attributes (POPPLER_PAGE (page->backend_page));
+ if (!backend_attrs_list)
+ return NULL;
+
+ attrs_list = pango_attr_list_new ();
+ for (l = backend_attrs_list; l; l = g_list_next (l)) {
+ PopplerTextAttributes *backend_attrs = (PopplerTextAttributes *)l->data;
+ PangoAttribute *attr;
+
+ if (backend_attrs->is_underlined) {
+ attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
+ attr->start_index = backend_attrs->start_index;
+ attr->end_index = backend_attrs->end_index;
+ pango_attr_list_insert (attrs_list, attr);
+ }
+
+ attr = pango_attr_foreground_new (backend_attrs->color.red,
+ backend_attrs->color.green,
+ backend_attrs->color.blue);
+ attr->start_index = backend_attrs->start_index;
+ attr->end_index = backend_attrs->end_index;
+ pango_attr_list_insert (attrs_list, attr);
+
+ if (backend_attrs->font_name) {
+ attr = pango_attr_family_new (backend_attrs->font_name);
+ attr->start_index = backend_attrs->start_index;
+ attr->end_index = backend_attrs->end_index;
+ pango_attr_list_insert (attrs_list, attr);
+ }
+
+ if (backend_attrs->font_size) {
+ attr = pango_attr_size_new (backend_attrs->font_size * PANGO_SCALE);
+ attr->start_index = backend_attrs->start_index;
+ attr->end_index = backend_attrs->end_index;
+ pango_attr_list_insert (attrs_list, attr);
+ }
+ }
+
+ poppler_page_free_text_attributes (backend_attrs_list);
+
+ return attrs_list;
+}
+
static void
pdf_document_text_iface_init (EvDocumentTextInterface *iface)
{
iface->get_text_mapping = pdf_document_text_get_text_mapping;
iface->get_text = pdf_document_text_get_text;
iface->get_text_layout = pdf_document_text_get_text_layout;
+ iface->get_text_attrs = pdf_document_text_get_text_attrs;
}
/* Page Transitions */