[poppler] poppler/qt: Makefile.am, 1.4, 1.5 poppler-document.cc, 1.5, 1.6 poppler-private.h, 1.1, 1.2 poppler-qt.h, 1.9, 1.10

Albert Astals Cid aacid at freedesktop.org
Sat Dec 3 14:20:56 PST 2005


Update of /cvs/poppler/poppler/qt
In directory gabe:/tmp/cvs-serv8057/qt

Modified Files:
	Makefile.am poppler-document.cc poppler-private.h poppler-qt.h 
Log Message:
 * qt4/src/poppler-qt4.h:
 * qt4/src/poppler-fontinfo.cc:
 * qt4/src/poppler-textbox.cc: Remove implementation of that classes from the header, use pimpl


Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/qt/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.am	21 Nov 2005 19:44:09 -0000	1.4
+++ Makefile.am	3 Dec 2005 22:20:54 -0000	1.5
@@ -15,6 +15,7 @@
 lib_LTLIBRARIES=libpoppler-qt.la
 libpoppler_qt_la_SOURCES =			\
 	poppler-document.cc			\
+	poppler-fontinfo.cc			\
 	poppler-page.cc				\
 	poppler-private.h
 

Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-document.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- poppler-document.cc	28 Jul 2005 17:34:19 -0000	1.5
+++ poppler-document.cc	3 Dec 2005 22:20:54 -0000	1.6
@@ -43,6 +43,7 @@
       pdoc->data->locked = true;
     else
       pdoc->data->locked = false;
+    pdoc->data->m_fontInfoScanner = new FontInfoScanner(&(doc->doc));
     return pdoc;
   }
   else
@@ -105,6 +106,34 @@
   return data->doc.getNumPages();
 }
 
+QValueList<FontInfo> Document::fonts() const
+{
+  QValueList<FontInfo> ourList;
+  scanForFonts(getNumPages(), &ourList);
+  return ourList;
+}
+
+bool Document::scanForFonts( int numPages, QValueList<FontInfo> *fontList ) const
+{
+  GooList *items = data->m_fontInfoScanner->scan( numPages );
+
+  if ( NULL == items )
+    return false;
+
+  for ( int i = 0; i < items->getLength(); ++i ) {
+    QString fontName;
+    if (((::FontInfo*)items->get(i))->getName())
+      fontName = ((::FontInfo*)items->get(i))->getName()->getCString();
+
+    FontInfo font(fontName,
+                  ((::FontInfo*)items->get(i))->getEmbedded(),
+                  ((::FontInfo*)items->get(i))->getSubset(),
+                  (Poppler::FontInfo::Type)((::FontInfo*)items->get(i))->getType());
+    fontList->append(font);
+  }
+  return true;
+}
+
 /* borrowed from kpdf */
 static QString unicodeToQString(Unicode* u, int len) {
   QString ret;

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-private.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- poppler-private.h	6 Apr 2005 14:39:40 -0000	1.1
+++ poppler-private.h	3 Dec 2005 22:20:54 -0000	1.2
@@ -17,6 +17,7 @@
  */
 
 #include <PDFDoc.h>
+#include <FontInfo.h>
 
 namespace Poppler {
 
@@ -25,6 +26,7 @@
     DocumentData(GooString *filePath, GooString *password) : doc(filePath,password) {}
   class PDFDoc doc;
   bool locked;
+  FontInfoScanner *m_fontInfoScanner;
 };
 
 }

Index: poppler-qt.h
===================================================================
RCS file: /cvs/poppler/poppler/qt/poppler-qt.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- poppler-qt.h	21 Nov 2005 22:12:16 -0000	1.9
+++ poppler-qt.h	3 Dec 2005 22:20:54 -0000	1.10
@@ -58,6 +58,64 @@
 };
 
 
+/**
+  Container class for information about a font within a PDF document
+*/
+class FontInfoData;
+class FontInfo {
+public:
+  enum Type {
+    unknown,
+    Type1,
+    Type1C,
+    Type3,
+    TrueType,
+    CIDType0,
+    CIDType0C,
+    CIDTrueType
+  };
+
+  /**
+    Create a new font information container
+  */
+  FontInfo( const QString &fontName, const bool isEmbedded,
+            const bool isSubset, Type type );
+
+  FontInfo();
+
+  ~FontInfo();
+
+  /**
+    The name of the font. Can be QString::null if the font has no name
+  */
+  const QString &name() const;
+
+  /**
+    Whether the font is embedded in the file, or not
+
+    \return true if the font is embedded
+  */
+  bool isEmbedded() const;
+
+  /**
+    Whether the font provided is only a subset of the full
+    font or not. This only has meaning if the font is embedded.
+
+    \return true if the font is only a subset
+  */
+  bool isSubset() const;
+
+  /**
+    The type of font encoding
+  */
+  Type type() const;
+
+  const QString &typeName() const;
+
+private:
+  FontInfoData *data;
+};
+
 class PageTransitionData;
 class PageTransition
 {
@@ -212,7 +270,27 @@
   bool okToCopy() const;
   bool okToAddNotes() const;
   double getPDFVersion() const;
-  
+
+  /**
+    The fonts within the PDF document.
+
+    \note this can take a very long time to run with a large
+    document. You may wish to use the call below if you have more
+    than say 20 pages
+  */
+  QValueList<FontInfo> fonts() const;
+
+  /**
+    \overload
+
+    \param numPages the number of pages to scan
+    \param fontList pointer to the list where the font information
+    should be placed
+
+    \return false if the end of the document has been reached
+  */
+  bool scanForFonts( int numPages, QValueList<FontInfo> *fontList ) const;
+
   Document::~Document();
   
 private:



More information about the poppler mailing list