From 474e0bcc4caeb06fe33b30d7c33f72bd6b0fa82d Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Sun, 28 Nov 2010 23:07:12 +1030 Subject: [PATCH 2/2] FontInfo: scan Patterns as well as XObjects for fonts --- poppler/FontInfo.cc | 73 ++++++++++++++++++++++++++------------------------ 1 files changed, 38 insertions(+), 35 deletions(-) diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc index df9c577..a0219fc 100644 --- a/poppler/FontInfo.cc +++ b/poppler/FontInfo.cc @@ -148,46 +148,49 @@ 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()) { - GBool alreadySeen = gFalse; - // check for an already-seen XObject - for (int k = 0; k < visitedXObjectsLen; ++k) { - if (xObj.getRef().num == visitedXObjects[k].num && - xObj.getRef().gen == visitedXObjects[k].gen) { - alreadySeen = gTrue; - } - } + char *resTypes[2] = { "XObject", "Pattern" }; + for (i = 0; i < 2; i++) { + resDict->lookup(resTypes[i], &xObjDict); + if (xObjDict.isDict()) { + for (i = 0; i < xObjDict.dictGetLength(); ++i) { + xObjDict.dictGetValNF(i, &xObj); + if (xObj.isRef()) { + GBool alreadySeen = gFalse; + // check for an already-seen XObject + for (int k = 0; k < visitedXObjectsLen; ++k) { + if (xObj.getRef().num == visitedXObjects[k].num && + xObj.getRef().gen == visitedXObjects[k].gen) { + alreadySeen = gTrue; + } + } - if (alreadySeen) { - xObj.free(); - continue; - } + if (alreadySeen) { + xObj.free(); + continue; + } - if (visitedXObjectsLen == visitedXObjectsSize) { - visitedXObjectsSize += 32; - visitedXObjects = (Ref *)grealloc(visitedXObjects, visitedXObjectsSize * sizeof(Ref)); - } - visitedXObjects[visitedXObjectsLen++] = xObj.getRef(); - } + if (visitedXObjectsLen == visitedXObjectsSize) { + visitedXObjectsSize += 32; + visitedXObjects = (Ref *)grealloc(visitedXObjects, visitedXObjectsSize * sizeof(Ref)); + } + visitedXObjects[visitedXObjectsLen++] = xObj.getRef(); + } - xObj.fetch(doc->getXRef(), &xObj2); + xObj.fetch(doc->getXRef(), &xObj2); - if (xObj2.isStream()) { - xObj2.streamGetDict()->lookup("Resources", &resObj); - if (resObj.isDict() && resObj.getDict() != resDict) { - scanFonts(resObj.getDict(), fontsList); - } - resObj.free(); + if (xObj2.isStream()) { + xObj2.streamGetDict()->lookup("Resources", &resObj); + if (resObj.isDict() && resObj.getDict() != resDict) { + scanFonts(resObj.getDict(), fontsList); + } + resObj.free(); + } + xObj.free(); + xObj2.free(); } - xObj.free(); - xObj2.free(); } + xObjDict.free(); } - xObjDict.free(); } FontInfo::FontInfo(GfxFont *font, PDFDoc *doc) { -- 1.7.1