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

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

Issue 20526002: pdfviewer: set the default background to transparent (to match render_picture default), and fix a b… (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/pdf_viewer_main.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 #ifndef __DEFINED__SkPdfFont 1 #ifndef __DEFINED__SkPdfFont
2 #define __DEFINED__SkPdfFont 2 #define __DEFINED__SkPdfFont
3 3
4 #include "SkPdfHeaders_autogen.h" 4 #include "SkPdfHeaders_autogen.h"
5 #include "SkPdfMapper_autogen.h" 5 #include "SkPdfMapper_autogen.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "SkTypeface.h" 10 #include "SkTypeface.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 fFonMatrix = dict->has_FontMatrix() ? dict->FontMatrix(parsed) : SkMatri x::I(); 356 fFonMatrix = dict->has_FontMatrix() ? dict->FontMatrix(parsed) : SkMatri x::I();
357 357
358 if (dict->has_FontBBox()) { 358 if (dict->has_FontBBox()) {
359 fFontBBox = dict->FontBBox(parsed); 359 fFontBBox = dict->FontBBox(parsed);
360 } 360 }
361 361
362 fChars = new Type3FontChar[fLastChar - fFirstChar + 1]; 362 fChars = new Type3FontChar[fLastChar - fFirstChar + 1];
363 363
364 memset(fChars, 0, sizeof(fChars[0]) * (fLastChar - fFirstChar + 1)); 364 memset(fChars, 0, sizeof(fChars[0]) * (fLastChar - fFirstChar + 1));
365 365
366
367 const SkPdfArray* widths = dict->Widths(parsed); 366 const SkPdfArray* widths = dict->Widths(parsed);
368 for (unsigned int i = 0 ; i < widths->size(); i++) { 367 for (unsigned int i = 0 ; i < widths->size(); i++) {
369 if ((fFirstChar + i) < fFirstChar || (fFirstChar + i) > fLastChar) { 368 if ((fFirstChar + i) >= fFirstChar && (fFirstChar + i) <= fLastChar) {
370 printf("break; error 1\n"); 369 fChars[i].fWidth = (*widths)[i]->numberValue();
370 } else {
371 // TODO(edisonn): report pdf corruption
371 } 372 }
372 fChars[i].fWidth = (*widths)[i]->numberValue();
373 } 373 }
374 374
375 const SkPdfArray* diffs = fEncodingDict->Differences(parsed); 375 const SkPdfArray* diffs = fEncodingDict->Differences(parsed);
376 unsigned int j = fFirstChar; 376 unsigned int j = fFirstChar;
377 for (unsigned int i = 0 ; i < diffs->size(); i++) { 377 for (unsigned int i = 0 ; i < diffs->size(); i++) {
378 if ((*diffs)[i]->isInteger()) { 378 if ((*diffs)[i]->isInteger()) {
379 j = (unsigned int)(*diffs)[i]->intValue(); 379 j = (unsigned int)(*diffs)[i]->intValue();
380 } else if ((*diffs)[i]->isName()) { 380 } else if ((*diffs)[i]->isName()) {
381 if (j < fFirstChar || j > fLastChar) { 381 if (j >= fFirstChar && j <= fLastChar) {
382 printf("break; error 2\n"); 382 fChars[j - fFirstChar].fObj = fCharProcs->get((*diffs)[i]);
383 } else {
384 // TODO(edisonn): report pdf corruption
383 } 385 }
384 fChars[j - fFirstChar].fObj = fCharProcs->get((*diffs)[i]);
385 j++; 386 j++;
386 } else { 387 } else {
387 // err 388 // TODO(edisonn): report bad pdf
388 } 389 }
389 } 390 }
390 } 391 }
391 392
392 public: 393 public:
393 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC ontext, SkCanvas* canvas) { 394 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC ontext, SkCanvas* canvas) {
394 if (ch < fFirstChar || ch > fLastChar || !fChars[ch - fFirstChar].fObj) { 395 if (ch < fFirstChar || ch > fLastChar || !fChars[ch - fFirstChar].fObj) {
395 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canv as); 396 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canv as);
396 } 397 }
397 398
(...skipping 12 matching lines...) Expand all
410 SkDoubleToScalar(0.0)); 411 SkDoubleToScalar(0.0));
411 return fChars[ch - fFirstChar].fWidth; 412 return fChars[ch - fFirstChar].fWidth;
412 } 413 }
413 414
414 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { 415 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) {
415 416
416 } 417 }
417 }; 418 };
418 419
419 #endif // __DEFINED__SkPdfFont 420 #endif // __DEFINED__SkPdfFont
OLDNEW
« no previous file with comments | « no previous file | experimental/PdfViewer/pdf_viewer_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698