Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Side by Side Diff: experimental/PdfViewer/SkPdfFont.cpp

Issue 20004007: pdfviewer: don't crash if the xref is corrupted. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "SkPdfFont.h" 1 #include "SkPdfFont.h"
2 2
3 #include "SkStream.h" 3 #include "SkStream.h"
4 #include "SkTypeface.h" 4 #include "SkTypeface.h"
5 #include "SkPdfNativeTokenizer.h" 5 #include "SkPdfNativeTokenizer.h"
6 6
7 std::map<std::string, SkPdfStandardFontEntry>& getStandardFonts() { 7 std::map<std::string, SkPdfStandardFontEntry>& getStandardFonts() {
8 static std::map<std::string, SkPdfStandardFontEntry> gPdfStandardFonts; 8 static std::map<std::string, SkPdfStandardFontEntry> gPdfStandardFonts;
9 9
10 // TODO (edisonn): , vs - ? what does it mean? 10 // TODO (edisonn): , vs - ? what does it mean?
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 SkPdfFont* fontFromName(SkNativeParsedPDF* doc, SkPdfObject* obj, const char* fo ntName) { 191 SkPdfFont* fontFromName(SkNativeParsedPDF* doc, SkPdfObject* obj, const char* fo ntName) {
192 SkTypeface* typeface = SkTypefaceFromPdfStandardFont(fontName, false, false) ; 192 SkTypeface* typeface = SkTypefaceFromPdfStandardFont(fontName, false, false) ;
193 if (typeface != NULL) { 193 if (typeface != NULL) {
194 return new SkPdfStandardFont(typeface); 194 return new SkPdfStandardFont(typeface);
195 } 195 }
196 196
197 // TODO(edisonn): perf - make a map 197 // TODO(edisonn): perf - make a map
198 for (unsigned int i = 0 ; i < doc->objects(); i++) { 198 for (unsigned int i = 0 ; i < doc->objects(); i++) {
199 SkPdfObject* obj = doc->object(i); 199 SkPdfObject* obj = doc->object(i);
200 if (!obj->isDictionary()) { 200 if (!obj || !obj->isDictionary()) {
201 continue; 201 continue;
202 } 202 }
203 203
204 SkPdfFontDescriptorDictionary* fd = obj->asDictionary()->asFontDescripto rDictionary(); 204 SkPdfFontDescriptorDictionary* fd = obj->asDictionary()->asFontDescripto rDictionary();
205 205
206 if (!fd->valid()) { 206 if (!fd->valid()) {
207 continue; 207 continue;
208 } 208 }
209 209
210 if (fd->has_FontName() && fd->FontName(doc) == fontName) { 210 if (fd->has_FontName() && fd->FontName(doc) == fontName) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 SkPdfEncoding* SkPdfEncoding::fromName(const char* name) { 444 SkPdfEncoding* SkPdfEncoding::fromName(const char* name) {
445 SkPdfEncoding* encoding = getStandardEncodings()[name]; 445 SkPdfEncoding* encoding = getStandardEncodings()[name];
446 446
447 #ifdef PDF_TRACE 447 #ifdef PDF_TRACE
448 if (encoding == NULL) { 448 if (encoding == NULL) {
449 printf("Encoding not found: %s\n", name); 449 printf("Encoding not found: %s\n", name);
450 } 450 }
451 #endif 451 #endif
452 return encoding; 452 return encoding;
453 } 453 }
OLDNEW
« no previous file with comments | « no previous file | experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698