more work on pdf fonts, more to come
Review URL: https://codereview.chromium.org/18117005
git-svn-id: http://skia.googlecode.com/svn/trunk@9813 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/PdfViewer/SkPdfBasics.h b/experimental/PdfViewer/SkPdfBasics.h
index 5b37820..894db10 100644
--- a/experimental/PdfViewer/SkPdfBasics.h
+++ b/experimental/PdfViewer/SkPdfBasics.h
@@ -1,9 +1,6 @@
#ifndef __DEFINED__SkPdfBasics
#define __DEFINED__SkPdfBasics
-#include "podofo.h"
-using namespace PoDoFo;
-
#include "SkCanvas.h"
#include "SkPaint.h"
diff --git a/experimental/PdfViewer/SkPdfFont.cpp b/experimental/PdfViewer/SkPdfFont.cpp
index 8170453..e0cbd2c 100644
--- a/experimental/PdfViewer/SkPdfFont.cpp
+++ b/experimental/PdfViewer/SkPdfFont.cpp
@@ -203,6 +203,7 @@
PdfVecObjects& objects = (PdfVecObjects&)obj->doc()->GetObjects();
const PdfObject* podofoFont = objects[i];
SkPdfFontDescriptorDictionary* fd = NULL;
+
if (mapFontDescriptorDictionary(*obj->doc(), *podofoFont, &fd)) {
if (fd->has_FontName() && fd->FontName() == fontName) {
SkPdfFont* font = SkPdfFont::fontFromFontDescriptor(fd, false);
diff --git a/experimental/PdfViewer/SkPdfParser.cpp b/experimental/PdfViewer/SkPdfParser.cpp
index 94dd5dd..e4c545f 100644
--- a/experimental/PdfViewer/SkPdfParser.cpp
+++ b/experimental/PdfViewer/SkPdfParser.cpp
@@ -2351,6 +2351,7 @@
}
catch( PdfError & e )
{
+ e.PrintErrorMsg();
std::cout << "ERROR: PDF can't be parsed!" << inputFileName.c_str() << std::endl;
return false;
}
diff --git a/experimental/PdfViewer/autogen/SkPdfPodofoMapper_autogen.cpp b/experimental/PdfViewer/autogen/SkPdfPodofoMapper_autogen.cpp
index d2ff1c9..29727db 100644
--- a/experimental/PdfViewer/autogen/SkPdfPodofoMapper_autogen.cpp
+++ b/experimental/PdfViewer/autogen/SkPdfPodofoMapper_autogen.cpp
@@ -2565,6 +2565,7 @@
bool isTrueTypeFontDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Subtype;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Subtype", "", &Subtype)) return false;
if ((Subtype != "TrueType")) return false;
@@ -3232,6 +3233,7 @@
bool isImageDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Subtype;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Subtype", "", &Subtype)) return false;
if ((Subtype != "Image")) return false;
@@ -3270,6 +3272,7 @@
bool isType1FormDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Subtype;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Subtype", "", &Subtype)) return false;
if ((Subtype != "Form")) return false;
@@ -3342,6 +3345,7 @@
bool isType1FontDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Subtype;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Subtype", "", &Subtype)) return false;
if ((Subtype != "MMType1") && (Subtype != "TrueType") && (Subtype != "Type3") && (Subtype != "Type1")) return false;
@@ -3363,6 +3367,7 @@
bool isType3FontDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Subtype;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Subtype", "", &Subtype)) return false;
if ((Subtype != "Type3")) return false;
@@ -3418,6 +3423,7 @@
bool isCIDFontDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Subtype;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Subtype", "", &Subtype)) return false;
if ((Subtype != "CIDFontType0") && (Subtype != "CIDFontType2")) return false;
@@ -3456,6 +3462,7 @@
bool isType0FontDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Subtype;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Subtype", "", &Subtype)) return false;
if ((Subtype != "Type0")) return false;
@@ -3477,6 +3484,7 @@
bool isFontDescriptorDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Type;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Type", "", &Type)) return false;
if ((Type != "FontDescriptor")) return false;
@@ -5385,6 +5393,7 @@
bool isMultiMasterFontDictionary(const PdfMemDocument& podofoDoc, const PdfObject& podofoObj) {
std::string Subtype;
+ if (!podofoObj.IsDictionary()) return false;
if (!NameFromDictionary(&podofoDoc, podofoObj.GetDictionary(), "Subtype", "", &Subtype)) return false;
if ((Subtype != "MMType1")) return false;
diff --git a/experimental/PdfViewer/generate_code.py b/experimental/PdfViewer/generate_code.py
index 0802c5e..69e06b6 100644
--- a/experimental/PdfViewer/generate_code.py
+++ b/experimental/PdfViewer/generate_code.py
@@ -490,6 +490,7 @@
if prop.fHasMust:
cntMust = cntMust + 1
fileMapperCpp.write(' ' + knowTypes[prop.fTypes.strip()][0] + ' ' + prop.fCppName + ';\n')
+ fileMapperCpp.write(' if (!podofoObj.IsDictionary()) return false;\n')
fileMapperCpp.write(' if (!' + knowTypes[prop.fTypes.strip()][1] + '(&podofoDoc, podofoObj.GetDictionary(), \"' + prop.fName + '\", \"' + prop.fAbr + '\", &' + prop.fCppName + ')) return false;\n')
eval = '';