[poppler] poppler/FontInfo.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Nov 28 05:57:18 PST 2010


 poppler/FontInfo.cc |   50 +++++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

New commits:
commit 1ac14df61d711097837e44d80a9332f0a854b95e
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Nov 28 13:49:41 2010 +0000

    find fonts inside patterns
    
    Bug 31948

diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc
index 1dea32c..908a40b 100644
--- a/poppler/FontInfo.cc
+++ b/poppler/FontInfo.cc
@@ -8,6 +8,7 @@
 // Copyright (C) 2006 Kouhei Sutou <kou at cozmixng.org>
 // Copyright (C) 2009 Pino Toscano <pino at kde.org>
 // Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
+// Copyright (C) 2010 Adrian Johnson <ajohnson at redneon.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -92,7 +93,7 @@ GooList *FontInfoScanner::scan(int nPages) {
 }
 
 void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) {
-  Object obj1, obj2, xObjDict, xObj, xObj2, resObj;
+  Object obj1, obj2, objDict, resObj;
   Ref r;
   GfxFontDict *gfxFontDict;
   GfxFont *font;
@@ -129,35 +130,38 @@ void FontInfoScanner::scanFonts(Dict *resDict, GooList *fontsList) {
 
   // recursively scan any resource dictionaries in objects in this
   // resource dictionary
-  resDict->lookup("XObject", &xObjDict);
-  if (xObjDict.isDict()) {
-    for (i = 0; i < xObjDict.dictGetLength(); ++i) {
-      xObjDict.dictGetValNF(i, &xObj);
-      if (xObj.isRef()) {
-        // check for an already-seen XObject
-        const Ref r = xObj.getRef();
-        if (visitedXObjects.find(r.num) != visitedXObjects.end()) {
-          xObj.free();
-          continue;
+  char *resTypes[] = { "XObject", "Pattern" };
+  for (uint resType = 0; resType < sizeof(resTypes) / sizeof(resTypes[0]); ++resType) {
+    resDict->lookup(resTypes[resType], &objDict);
+    if (objDict.isDict()) {
+      for (i = 0; i < objDict.dictGetLength(); ++i) {
+        objDict.dictGetValNF(i, &obj1);
+        if (obj1.isRef()) {
+          // check for an already-seen XObject
+          const Ref r = obj1.getRef();
+          if (visitedXObjects.find(r.num) != visitedXObjects.end()) {
+            obj1.free();
+            continue;
+          }
+
+          visitedXObjects.insert(r.num);
         }
 
-        visitedXObjects.insert(r.num);
-      }
-
-      xObj.fetch(doc->getXRef(), &xObj2);
+        obj1.fetch(doc->getXRef(), &obj2);
 
-      if (xObj2.isStream()) {
-        xObj2.streamGetDict()->lookup("Resources", &resObj);
-        if (resObj.isDict() && resObj.getDict() != resDict) {
-          scanFonts(resObj.getDict(), fontsList);
+        if (obj2.isStream()) {
+          obj2.streamGetDict()->lookup("Resources", &resObj);
+          if (resObj.isDict() && resObj.getDict() != resDict) {
+            scanFonts(resObj.getDict(), fontsList);
+          }
+          resObj.free();
         }
-        resObj.free();
+        obj1.free();
+        obj2.free();
       }
-      xObj.free();
-      xObj2.free();
     }
+    objDict.free();
   }
-  xObjDict.free();
 }
 
 FontInfo::FontInfo(GfxFont *font, PDFDoc *doc) {


More information about the poppler mailing list