Commit 23e8ed5c authored by Kristian Høgsberg's avatar Kristian Høgsberg

2005-06-13 Kristian Høgsberg <krh@redhat.com>

        * glib/poppler-document.cc:
        * glib/poppler-document.h:
        * glib/poppler-private.h:
        * glib/poppler.h:
        * glib/test-poppler-glib.c:
        * poppler/Makefile.am: Patch from Marco to extract font info from
        document.
parent fbb86d29
2005-06-13 Kristian Høgsberg <krh@redhat.com>
* glib/poppler-document.cc:
* glib/poppler-document.h:
* glib/poppler-private.h:
* glib/poppler.h:
* glib/test-poppler-glib.c:
* poppler/Makefile.am: Patch from Marco to extract font info from
document.
2005-06-08 Kristian Høgsberg <krh@redhat.com>
* poppler/CairoFontEngine.cc: Remember to delete tmpFileName.
......
......@@ -26,6 +26,7 @@
#include <GfxState.h>
#include <SplashOutputDev.h>
#include <Stream.h>
#include <FontInfo.h>
#include "poppler.h"
#include "poppler-private.h"
......@@ -745,6 +746,136 @@ poppler_index_iter_free (PopplerIndexIter *iter)
}
struct _PopplerFontsIter
{
GooList *items;
int index;
};
GType
poppler_fonts_iter_get_type (void)
{
static GType our_type = 0;
if (our_type == 0)
our_type = g_boxed_type_register_static ("PopplerFontsIter",
(GBoxedCopyFunc) poppler_fonts_iter_copy,
(GBoxedFreeFunc) poppler_fonts_iter_free);
return our_type;
}
const char *
poppler_fonts_iter_get_name (PopplerFontsIter *iter)
{
FontInfo *info;
info = (FontInfo *)iter->items->get (iter->index);
return info->getName()->getCString();
}
gboolean
poppler_fonts_iter_next (PopplerFontsIter *iter)
{
g_return_val_if_fail (iter != NULL, FALSE);
iter->index++;
if (iter->index >= iter->items->getLength())
return FALSE;
return TRUE;
}
PopplerFontsIter *
poppler_fonts_iter_copy (PopplerFontsIter *iter)
{
PopplerFontsIter *new_iter;
g_return_val_if_fail (iter != NULL, NULL);
new_iter = g_new0 (PopplerFontsIter, 1);
*new_iter = *iter;
new_iter->items = new GooList ();
for (int i = 0; i < iter->items->getLength(); i++) {
FontInfo *info = (FontInfo *)iter->items->get(i);
new_iter->items->append (new FontInfo (*info));
}
return new_iter;
}
void
poppler_fonts_iter_free (PopplerFontsIter *iter)
{
if (iter == NULL)
return;
deleteGooList (iter->items, FontInfo);
g_free (iter);
}
static PopplerFontsIter *
poppler_fonts_iter_new (GooList *items)
{
PopplerFontsIter *iter;
iter = g_new0 (PopplerFontsIter, 1);
iter->items = items;
iter->index = 0;
return iter;
}
PopplerFontInfo *
poppler_font_info_new (PopplerDocument *document)
{
PopplerFontInfo *font_info;
g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), NULL);
font_info = g_new0 (PopplerFontInfo, 1);
font_info->document = (PopplerDocument *) g_object_ref (document);
font_info->scanner = new FontInfoScanner(document->doc);
return font_info;
}
gboolean
poppler_font_info_scan (PopplerFontInfo *font_info,
int n_pages,
PopplerFontsIter **iter)
{
GooList *items;
g_return_val_if_fail (iter != NULL, FALSE);
items = font_info->scanner->scan(n_pages);
if (items == NULL) {
*iter = NULL;
} else if (items->getLength() == 0) {
*iter = NULL;
delete items;
} else {
*iter = poppler_fonts_iter_new(items);
}
return (items != NULL);
}
void
poppler_font_info_free (PopplerFontInfo *font_info)
{
g_return_if_fail (font_info != NULL);
delete font_info->scanner;
g_object_unref (font_info->document);
}
/**
* poppler_ps_file_new:
* @document: a #PopplerDocument
......
......@@ -103,6 +103,19 @@ PopplerIndexIter *poppler_index_iter_get_child (PopplerIndexIter *parent);
PopplerAction *poppler_index_iter_get_action (PopplerIndexIter *iter);
gboolean poppler_index_iter_next (PopplerIndexIter *iter);
/* Interface for getting the Fonts of a poppler_document */
PopplerFontInfo *poppler_font_info_new (PopplerDocument *document);
gboolean poppler_font_info_scan (PopplerFontInfo *font_info,
int n_pages,
PopplerFontsIter **iter);
void poppler_font_info_free (PopplerFontInfo *font_info);
GType poppler_fonts_iter_get_type (void) G_GNUC_CONST;
PopplerFontsIter *poppler_fonts_iter_copy (PopplerFontsIter *iter);
void poppler_fonts_iter_free (PopplerFontsIter *iter);
const char *poppler_fonts_iter_get_name (PopplerFontsIter *iter);
gboolean poppler_fonts_iter_next (PopplerFontsIter *iter);
/* Export to ps */
PopplerPSFile *poppler_ps_file_new (PopplerDocument *document,
const char *filename,
......
......@@ -5,6 +5,7 @@
#include <PDFDoc.h>
#include <PSOutputDev.h>
#include <Link.h>
#include <FontInfo.h>
#if defined (HAVE_CAIRO)
#include <CairoOutputDevImage.h>
......@@ -30,6 +31,12 @@ struct _PopplerPSFile
PSOutputDev *out;
};
struct _PopplerFontInfo
{
PopplerDocument *document;
FontInfoScanner *scanner;
};
struct _PopplerPage
{
GObject parent_instance;
......
......@@ -45,9 +45,11 @@ typedef enum
typedef struct _PopplerDocument PopplerDocument;
typedef struct _PopplerIndexIter PopplerIndexIter;
typedef struct _PopplerFontsIter PopplerFontsIter;
typedef struct _PopplerRectangle PopplerRectangle;
typedef struct _PopplerLinkMapping PopplerLinkMapping;
typedef struct _PopplerPage PopplerPage;
typedef struct _PopplerFontInfo PopplerFontInfo;
typedef struct _PopplerPSFile PopplerPSFile;
typedef union _PopplerAction PopplerAction;
......
......@@ -15,6 +15,8 @@ print_document_info (PopplerDocument *document)
PopplerPageLayout layout;
PopplerPageMode mode;
PopplerViewerPreferences view_prefs;
PopplerFontInfo *font_info;
PopplerFontsIter *fonts_iter;
GEnumValue *enum_value;
g_object_get (document,
......@@ -53,6 +55,18 @@ print_document_info (PopplerDocument *document)
g_print ("\tcreation date:\t%d\n", creation_date);
g_print ("\tmodified date:\t%d\n", mod_date);
g_print ("\tfonts:\n");
font_info = poppler_font_info_new (document);
while (poppler_font_info_scan (font_info, 20, &fonts_iter)) {
if (fonts_iter) {
do {
g_print ("\t\t\t%s\n", poppler_fonts_iter_get_name (fonts_iter));
} while (poppler_fonts_iter_next (fonts_iter));
poppler_fonts_iter_free (fonts_iter);
}
}
poppler_font_info_free (font_info);
/* FIXME: print out the view prefs when we support it */
g_free (title);
......
......@@ -92,6 +92,7 @@ poppler_include_HEADERS = \
Dict.h \
Error.h \
FontEncodingTables.h \
FontInfo.h \
Function.cc \
Function.h \
Gfx.h \
......@@ -143,6 +144,7 @@ libpoppler_la_SOURCES = \
Dict.cc \
Error.cc \
FontEncodingTables.cc \
FontInfo.cc \
Function.cc \
Gfx.cc \
GfxFont.cc \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment