]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/ev-poppler.cc
(font_type_to_string): Remove trailing space from "unknown font"
[evince.git] / pdf / ev-poppler.cc
index 528ecfd436621f696498691feabfc96e9cb13560..29f18cf0c34f9224c47bb64410ed14cd28ee73f7 100644 (file)
@@ -80,7 +80,10 @@ static void pdf_document_thumbnails_get_dimensions      (EvDocumentThumbnails
                                                         gint                       size,
                                                         gint                      *width,
                                                         gint                      *height);
+static int  pdf_document_get_n_pages                   (EvDocument                *document);
+
 static EvLink * ev_link_from_action (PopplerAction *action);
+static void pdf_document_search_free (PdfDocumentSearch   *search);
 
 
 G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT,
@@ -103,6 +106,25 @@ G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT,
                                                        pdf_selection_iface_init);
                         });
 
+static void
+pdf_document_search_free (PdfDocumentSearch   *search)
+{
+        PdfDocument *pdf_document = search->document;
+       int n_pages;
+       int i;
+
+        if (search->idle != 0)
+                g_source_remove (search->idle);
+
+       n_pages = pdf_document_get_n_pages (EV_DOCUMENT (pdf_document));
+       for (i = 0; i < n_pages; i++) {
+               g_list_foreach (search->pages[i], (GFunc) g_free, NULL);
+               g_list_free (search->pages[i]);
+       }
+       
+        g_free (search->text);
+}
+
 static void
 pdf_document_dispose (GObject *object)
 {
@@ -337,8 +359,7 @@ pdf_document_render_pixbuf (EvDocument   *document,
                                       0, 0,
                                       width, height,
                                       rc->scale,
-                                      pixbuf,
-                                      0, 0);
+                                      pixbuf);
        
        g_object_unref (poppler_page);
        
@@ -657,6 +678,30 @@ pdf_document_fonts_scan (EvDocumentFonts *document_fonts,
        return result;
 }
 
+static const char *
+font_type_to_string (PopplerFontType type)
+{
+       switch (type)
+       {
+       case POPPLER_FONT_TYPE_TYPE1:
+               return _("Type 1");
+       case POPPLER_FONT_TYPE_TYPE1C:
+               return _("Type 1C");
+       case POPPLER_FONT_TYPE_TYPE3:
+               return _("Type 3");
+       case POPPLER_FONT_TYPE_TRUETYPE:
+               return _("TrueType");
+       case POPPLER_FONT_TYPE_CID_TYPE0:
+               return _("Type 1 (CID)");
+       case POPPLER_FONT_TYPE_CID_TYPE0C:
+               return _("Type 1C (CID)");
+       case POPPLER_FONT_TYPE_CID_TYPE2:
+               return _("TrueType (CID)");
+       default:
+               return _("Unknown font type");
+       }
+}
+
 static void
 pdf_document_fonts_fill_model (EvDocumentFonts *document_fonts,
                               GtkTreeModel    *model)
@@ -666,22 +711,44 @@ pdf_document_fonts_fill_model (EvDocumentFonts *document_fonts,
 
        g_return_if_fail (PDF_IS_DOCUMENT (document_fonts));
 
-       if (iter) {
-               do {
-                       GtkTreeIter list_iter;
-                       const char *name;
+       if (!iter)
+               return;
+
+       do {
+               GtkTreeIter list_iter;
+               const char *name;
+               const char *type;
+               const char *embedded;
+               char *details;
                
-                       name = poppler_fonts_iter_get_name (iter);
-                       if (name == NULL) {
-                               name = _("No name");
-                       }
-
-                       gtk_list_store_append (GTK_LIST_STORE (model), &list_iter);
-                       gtk_list_store_set (GTK_LIST_STORE (model), &list_iter,
-                                           EV_DOCUMENT_FONTS_COLUMN_NAME, name,
-                                           -1);
-               } while (poppler_fonts_iter_next (iter));
-       }
+               name = poppler_fonts_iter_get_name (iter);
+
+               if (name == NULL) {
+                       name = _("No name");
+               }
+
+               type = font_type_to_string (
+                       poppler_fonts_iter_get_font_type (iter));
+
+               if (poppler_fonts_iter_is_embedded (iter)) {
+                       if (poppler_fonts_iter_is_subset (iter))
+                               embedded = _("Embedded subset");
+                       else
+                               embedded = _("Embedded");
+               } else {
+                       embedded = _("Not embedded");
+               }
+
+               details = g_markup_printf_escaped ("%s\n%s", type, embedded);
+
+               gtk_list_store_append (GTK_LIST_STORE (model), &list_iter);
+               gtk_list_store_set (GTK_LIST_STORE (model), &list_iter,
+                                   EV_DOCUMENT_FONTS_COLUMN_NAME, name,
+                                   EV_DOCUMENT_FONTS_COLUMN_DETAILS, details,
+                                   -1);
+
+               g_free (details);
+       } while (poppler_fonts_iter_next (iter));
 }
 
 static void
@@ -800,9 +867,8 @@ make_thumbnail_for_size (PdfDocument *pdf_document,
                         gboolean     border)
 {
        PopplerPage *poppler_page;
-       GdkPixbuf *pixbuf;
+       GdkPixbuf *pixbuf, *sub_pixbuf;
        int width, height;
-       int x_offset, y_offset;
        double scale;
        gdouble unscaled_width, unscaled_height;
 
@@ -816,20 +882,24 @@ make_thumbnail_for_size (PdfDocument *pdf_document,
 
        if (border) {
                pixbuf = ev_document_misc_get_thumbnail_frame (width, height, NULL);
-               x_offset = 1;
-               y_offset = 1;
+
+               sub_pixbuf = gdk_pixbuf_new_subpixbuf (pixbuf,
+                                                      1, 1,
+                                                      width - 1, height - 1);
        } else {
                pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
                                         width, height);
                gdk_pixbuf_fill (pixbuf, 0xffffffff);
-               x_offset = 0;
-               y_offset = 0;
+               sub_pixbuf = gdk_pixbuf_new_subpixbuf (pixbuf,
+                                                      0, 0,
+                                                      width, height);
        }
 
        poppler_page_render_to_pixbuf (poppler_page, 0, 0,
                                       width, height,
-                                      scale, pixbuf,
-                                      x_offset, y_offset);
+                                      scale, sub_pixbuf);
+
+       g_object_unref (G_OBJECT (sub_pixbuf));
 
        g_object_unref (poppler_page);
        return pixbuf;
@@ -989,25 +1059,6 @@ pdf_document_search_new (PdfDocument *pdf_document,
        return search;
 }
 
-static void
-pdf_document_search_free (PdfDocumentSearch   *search)
-{
-        PdfDocument *pdf_document = search->document;
-       int n_pages;
-       int i;
-
-        if (search->idle != 0)
-                g_source_remove (search->idle);
-
-       n_pages = pdf_document_get_n_pages (EV_DOCUMENT (pdf_document));
-       for (i = 0; i < n_pages; i++) {
-               g_list_foreach (search->pages[i], (GFunc) g_free, NULL);
-               g_list_free (search->pages[i]);
-       }
-       
-        g_free (search->text);
-}
-
 static void
 pdf_document_find_begin (EvDocumentFind   *document,
                         int               page,
@@ -1233,11 +1284,35 @@ pdf_selection_get_selection_region (EvSelection     *selection,
        return retval;
 }
 
+GdkRegion *
+pdf_selection_get_selection_map (EvSelection     *selection,
+                                EvRenderContext *rc)
+{
+       PdfDocument *pdf_document;
+       PopplerPage *poppler_page;
+       PopplerRectangle points;
+       GdkRegion *retval;
+
+       pdf_document = PDF_DOCUMENT (selection);
+       poppler_page = poppler_document_get_page (pdf_document->document,
+                                                 rc->page);
+       set_page_orientation (pdf_document, poppler_page);
+
+       points.x1 = 0.0;
+       points.y1 = 0.0;
+       poppler_page_get_size (poppler_page, &(points.x2), &(points.y2));
+       retval = poppler_page_get_selection_region (poppler_page, 1.0, &points);
+       g_object_unref (poppler_page);
+
+       return retval;
+}
+
 static void
 pdf_selection_iface_init (EvSelectionIface *iface)
 {
         iface->render_selection = pdf_selection_render_selection;
         iface->get_selection_region = pdf_selection_get_selection_region;
+        iface->get_selection_map = pdf_selection_get_selection_map;
 }
 
 PdfDocument *