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

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

Issue 23020003: pdfviewer: debug code for drawText (show magenta background for text, to show text even when we fai… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 | « experimental/PdfViewer/SkPdfConfig.h ('k') | experimental/PdfViewer/SkPdfFont.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"
11 #include "SkUtils.h" 11 #include "SkUtils.h"
12 #include "SkPdfBasics.h" 12 #include "SkPdfGraphicsState.h"
13 #include "SkPdfUtils.h" 13 #include "SkPdfUtils.h"
14 14
15 15
16 class SkPdfType0Font; 16 class SkPdfType0Font;
17 class SkPdfType1Font; 17 class SkPdfType1Font;
18 class SkPdfType3Font; 18 class SkPdfType3Font;
19 class SkPdfTrueTypeFont; 19 class SkPdfTrueTypeFont;
20 class SkPdfMultiMasterFont; 20 class SkPdfMultiMasterFont;
21 class SkPdfFont; 21 class SkPdfFont;
22 22
23 struct SkPdfStandardFontEntry { 23 struct SkPdfStandardFontEntry {
24 // We don't own this pointer! 24 // We don't own this pointer!
25 const char* fName; 25 const char* fName;
26 bool fIsBold; 26 bool fIsBold;
27 bool fIsItalic; 27 bool fIsItalic;
28 SkPdfStandardFontEntry() 28 SkPdfStandardFontEntry()
29 : fName(NULL), 29 : fName(NULL),
30 fIsBold(false), 30 fIsBold(false),
31 fIsItalic(false) {} 31 fIsItalic(false) {}
32 32
33 SkPdfStandardFontEntry(const char* name, bool bold, bool italic) 33 SkPdfStandardFontEntry(const char* name, bool bold, bool italic)
34 : fName(name), 34 : fName(name),
35 fIsBold(bold), 35 fIsBold(bold),
36 fIsItalic(italic) {} 36 fIsItalic(italic) {}
37 }; 37 };
38 38
39 std::map<std::string, SkPdfStandardFontEntry>& getStandardFonts(); 39 std::map<std::string, SkPdfStandardFontEntry>& getStandardFonts();
40 SkTypeface* SkTypefaceFromPdfStandardFont(const char* fontName, bool bold, bool italic); 40 SkTypeface* SkTypefaceFromPdfStandardFont(const char* fontName, bool bold, bool italic);
41 SkPdfFont* fontFromName(SkNativeParsedPDF* doc, SkPdfObject* obj, const char* fo ntName); 41 SkPdfFont* fontFromName(SkPdfNativeDoc* doc, SkPdfNativeObject* obj, const char* fontName);
42 42
43 struct SkUnencodedText { 43 struct SkUnencodedText {
44 void* text; 44 void* text;
45 int len; 45 int len;
46 46
47 public: 47 public:
48 SkUnencodedText(const SkPdfString* obj) { 48 SkUnencodedText(const SkPdfString* obj) {
49 text = (void*)obj->c_str(); 49 text = (void*)obj->c_str();
50 len = obj->lenstr(); 50 len = obj->lenstr();
51 } 51 }
(...skipping 18 matching lines...) Expand all
70 70
71 class SkPdfEncoding { 71 class SkPdfEncoding {
72 public: 72 public:
73 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu t) const = 0; 73 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu t) const = 0;
74 static SkPdfEncoding* fromName(const char* name); 74 static SkPdfEncoding* fromName(const char* name);
75 }; 75 };
76 76
77 std::map<std::string, SkPdfEncoding*>& getStandardEncodings(); 77 std::map<std::string, SkPdfEncoding*>& getStandardEncodings();
78 78
79 class SkPdfToUnicode { 79 class SkPdfToUnicode {
80 SkNativeParsedPDF* fParsed; 80 SkPdfNativeDoc* fParsed;
81 // TODO(edisonn): hide public members 81 // TODO(edisonn): hide public members
82 public: 82 public:
83 unsigned short* fCMapEncoding; 83 unsigned short* fCMapEncoding;
84 unsigned char* fCMapEncodingFlag; 84 unsigned char* fCMapEncodingFlag;
85 85
86 SkPdfToUnicode(SkNativeParsedPDF* parsed, SkPdfStream* stream); 86 SkPdfToUnicode(SkPdfNativeDoc* parsed, SkPdfStream* stream);
87 }; 87 };
88 88
89 89
90 class SkPdfIdentityHEncoding : public SkPdfEncoding { 90 class SkPdfIdentityHEncoding : public SkPdfEncoding {
91 public: 91 public:
92 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu t) const { 92 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu t) const {
93 // TODO(edisonn): SkASSERT(textIn.len % 2 == 0); or report error? 93 // TODO(edisonn): SkASSERT(textIn.len % 2 == 0); or report error?
94 94
95 uint16_t* text = (uint16_t*)textIn.text; 95 uint16_t* text = (uint16_t*)textIn.text;
96 textOut->text = new uint16_t[textIn.len / 2]; 96 textOut->text = new uint16_t[textIn.len / 2];
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 public: 164 public:
165 SkPdfFont() : fBaseFont(NULL), fEncoding(SkPdfDefaultEncoding::instance()), fToUnicode(NULL) {} 165 SkPdfFont() : fBaseFont(NULL), fEncoding(SkPdfDefaultEncoding::instance()), fToUnicode(NULL) {}
166 166
167 virtual ~SkPdfFont() { 167 virtual ~SkPdfFont() {
168 // TODO(edisonn): NYI (will leak for now) 168 // TODO(edisonn): NYI (will leak for now)
169 } 169 }
170 170
171 const SkPdfEncoding* encoding() const {return fEncoding;} 171 const SkPdfEncoding* encoding() const {return fEncoding;}
172 172
173 void drawText(const SkDecodedText& text, SkPaint* paint, PdfContext* pdfCont ext, SkCanvas* canvas) { 173 void drawText(const SkDecodedText& text, SkPaint* paint, SkPdfContext* pdfCo ntext, SkCanvas* canvas) {
174 for (int i = 0 ; i < text.size(); i++) { 174 for (int i = 0 ; i < text.size(); i++) {
175 canvas->setMatrix(pdfContext->fGraphicsState.fMatrixTm); 175 canvas->setMatrix(pdfContext->fGraphicsState.fMatrixTm);
176 #ifdef PDF_TRACE 176 #ifdef PDF_TRACE
177 SkPoint point = SkPoint::Make(SkDoubleToScalar(0), SkDoubleToScalar( 0)); 177 SkPoint point = SkPoint::Make(SkDoubleToScalar(0), SkDoubleToScalar( 0));
178 pdfContext->fGraphicsState.fMatrixTm.mapPoints(&point, 1); 178 pdfContext->fGraphicsState.fMatrixTm.mapPoints(&point, 1);
179 printf("DrawText at (%f, %f)\n", SkScalarToDouble(point.x()), SkScal arToDouble(point.y())); 179 printf("DrawText at (%f, %f)\n", SkScalarToDouble(point.x()), SkScal arToDouble(point.y()));
180 #endif // PDF_TRACE 180 #endif // PDF_TRACE
181
182 #ifdef PDF_TRACE_DRAWTEXT
183 SkPaint col;
184 col.setColor(SK_ColorMAGENTA);
185 SkRect rect = SkRect::MakeXYWH(SkDoubleToScalar(0.0), SkDoubleToScal ar(0.0), SkDoubleToScalar(10.0), SkDoubleToScalar(10.0));
186 canvas->save();
187 canvas->setMatrix(pdfContext->fGraphicsState.fMatrixTm);
188 canvas->drawRect(rect, col);
189 canvas->restore();
190 #endif
181 double width = drawOneChar(text[i], paint, pdfContext, canvas); 191 double width = drawOneChar(text[i], paint, pdfContext, canvas);
182 pdfContext->fGraphicsState.fMatrixTm.preTranslate(SkDoubleToScalar(w idth), SkDoubleToScalar(0.0)); 192 pdfContext->fGraphicsState.fMatrixTm.preTranslate(SkDoubleToScalar(w idth), SkDoubleToScalar(0.0));
183 } 193 }
184 } 194 }
185 195
186 void ToUnicode(const SkDecodedText& textIn, SkUnicodeText* textOut) const { 196 void ToUnicode(const SkDecodedText& textIn, SkUnicodeText* textOut) const {
187 if (fToUnicode) { 197 if (fToUnicode) {
188 textOut->text = new uint16_t[textIn.len]; 198 textOut->text = new uint16_t[textIn.len];
189 textOut->len = textIn.len; 199 textOut->len = textIn.len;
190 for (int i = 0; i < textIn.len; i++) { 200 for (int i = 0; i < textIn.len; i++) {
191 textOut->text[i] = fToUnicode->fCMapEncoding[textIn.text[i]]; 201 textOut->text[i] = fToUnicode->fCMapEncoding[textIn.text[i]];
192 } 202 }
193 } else { 203 } else {
194 textOut->text = textIn.text; 204 textOut->text = textIn.text;
195 textOut->len = textIn.len; 205 textOut->len = textIn.len;
196 } 206 }
197 }; 207 };
198 208
199 inline unsigned int ToUnicode(unsigned int ch) const { 209 inline unsigned int ToUnicode(unsigned int ch) const {
200 if (fToUnicode) { 210 if (fToUnicode) {
201 return fToUnicode->fCMapEncoding[ch]; 211 return fToUnicode->fCMapEncoding[ch];
202 } else { 212 } else {
203 return ch; 213 return ch;
204 } 214 }
205 }; 215 };
206 216
207 static SkPdfFont* fontFromPdfDictionary(SkNativeParsedPDF* doc, SkPdfFontDic tionary* dict); 217 static SkPdfFont* fontFromPdfDictionary(SkPdfNativeDoc* doc, SkPdfFontDictio nary* dict);
208 static SkPdfFont* Default() {return fontFromName(NULL, NULL, "TimesNewRoman" );} 218 static SkPdfFont* Default() {return fontFromName(NULL, NULL, "TimesNewRoman" );}
209 219
210 static SkPdfType0Font* fontFromType0FontDictionary(SkNativeParsedPDF* doc, S kPdfType0FontDictionary* dict); 220 static SkPdfType0Font* fontFromType0FontDictionary(SkPdfNativeDoc* doc, SkPd fType0FontDictionary* dict);
211 static SkPdfType1Font* fontFromType1FontDictionary(SkNativeParsedPDF* doc, S kPdfType1FontDictionary* dict); 221 static SkPdfType1Font* fontFromType1FontDictionary(SkPdfNativeDoc* doc, SkPd fType1FontDictionary* dict);
212 static SkPdfType3Font* fontFromType3FontDictionary(SkNativeParsedPDF* doc, S kPdfType3FontDictionary* dict); 222 static SkPdfType3Font* fontFromType3FontDictionary(SkPdfNativeDoc* doc, SkPd fType3FontDictionary* dict);
213 static SkPdfTrueTypeFont* fontFromTrueTypeFontDictionary(SkNativeParsedPDF* doc, SkPdfTrueTypeFontDictionary* dict); 223 static SkPdfTrueTypeFont* fontFromTrueTypeFontDictionary(SkPdfNativeDoc* doc , SkPdfTrueTypeFontDictionary* dict);
214 static SkPdfMultiMasterFont* fontFromMultiMasterFontDictionary(SkNativeParse dPDF* doc, SkPdfMultiMasterFontDictionary* dict); 224 static SkPdfMultiMasterFont* fontFromMultiMasterFontDictionary(SkPdfNativeDo c* doc, SkPdfMultiMasterFontDictionary* dict);
215 225
216 static SkPdfFont* fontFromFontDescriptor(SkNativeParsedPDF* doc, SkPdfFontDe scriptorDictionary* fd, bool loadFromName = true); 226 static SkPdfFont* fontFromFontDescriptor(SkPdfNativeDoc* doc, SkPdfFontDescr iptorDictionary* fd, bool loadFromName = true);
217 227
218 public: 228 public:
219 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC ontext, SkCanvas* canvas) = 0; 229 virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pd fContext, SkCanvas* canvas) = 0;
220 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) = 0; 230 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) = 0;
221 231
222 private: 232 private:
223 static SkPdfFont* fontFromPdfDictionaryOnce(SkNativeParsedPDF* doc, SkPdfFon tDictionary* dict); 233 static SkPdfFont* fontFromPdfDictionaryOnce(SkPdfNativeDoc* doc, SkPdfFontDi ctionary* dict);
224 }; 234 };
225 235
226 class SkPdfStandardFont : public SkPdfFont { 236 class SkPdfStandardFont : public SkPdfFont {
227 SkTypeface* fTypeface; 237 SkTypeface* fTypeface;
228 238
229 public: 239 public:
230 SkPdfStandardFont(SkTypeface* typeface) : fTypeface(typeface) {} 240 SkPdfStandardFont(SkTypeface* typeface) : fTypeface(typeface) {}
231 241
232 public: 242 public:
233 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC ontext, SkCanvas* canvas) { 243 virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pd fContext, SkCanvas* canvas) {
234 paint->setTypeface(fTypeface); 244 paint->setTypeface(fTypeface);
235 paint->setTextEncoding(SkPaint::kUTF8_TextEncoding); 245 paint->setTextEncoding(SkPaint::kUTF8_TextEncoding);
236 246
237 unsigned long ch4 = ch; 247 unsigned long ch4 = ch;
238 char utf8[10]; 248 char utf8[10];
239 int len = SkUTF8_FromUnichar(ch4, utf8); 249 int len = SkUTF8_FromUnichar(ch4, utf8);
240 250
241 canvas->drawText(utf8, len, SkDoubleToScalar(0), SkDoubleToScalar(0), *p aint); 251 canvas->drawText(utf8, len, SkDoubleToScalar(0), SkDoubleToScalar(0), *p aint);
242 252
243 SkScalar textWidth = paint->measureText(utf8, len); 253 SkScalar textWidth = paint->measureText(utf8, len);
244 return SkScalarToDouble(textWidth); 254 return SkScalarToDouble(textWidth);
245 } 255 }
246 256
247 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) {} 257 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) {}
248 }; 258 };
249 259
250 class SkPdfType0Font : public SkPdfFont { 260 class SkPdfType0Font : public SkPdfFont {
251 public: 261 public:
252 SkPdfType0Font(SkNativeParsedPDF* doc, SkPdfType0FontDictionary* dict); 262 SkPdfType0Font(SkPdfNativeDoc* doc, SkPdfType0FontDictionary* dict);
253 263
254 public: 264 public:
255 265
256 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC ontext, SkCanvas* canvas) { 266 virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pd fContext, SkCanvas* canvas) {
257 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas); 267 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas);
258 } 268 }
259 269
260 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { 270 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) {
261 } 271 }
262 }; 272 };
263 273
264 class SkPdfType1Font : public SkPdfFont { 274 class SkPdfType1Font : public SkPdfFont {
265 public: 275 public:
266 SkPdfType1Font(SkNativeParsedPDF* doc, SkPdfType1FontDictionary* dict) { 276 SkPdfType1Font(SkPdfNativeDoc* doc, SkPdfType1FontDictionary* dict) {
267 if (dict->has_FontDescriptor()) { 277 if (dict->has_FontDescriptor()) {
268 fBaseFont = SkPdfFont::fontFromFontDescriptor(doc, dict->FontDescrip tor(doc)); 278 fBaseFont = SkPdfFont::fontFromFontDescriptor(doc, dict->FontDescrip tor(doc));
269 } else { 279 } else {
270 fBaseFont = fontFromName(doc, dict, dict->BaseFont(doc).c_str()); 280 fBaseFont = fontFromName(doc, dict, dict->BaseFont(doc).c_str());
271 } 281 }
282
283 if (dict->isEncodingAName(doc)) {
284 fEncoding = SkPdfEncoding::fromName(dict->getEncodingAsName(doc).c_s tr());
285 } else if (dict->isEncodingADictionary(doc)) {
286 //SkPdfDictionary* dictEnc = dict->getEncodingAsDictionary(doc);
287 }
288 dict->FontDescriptor(doc);
272 } 289 }
273 290
274 public: 291 public:
275 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pd fContext, SkCanvas* canvas) { 292 virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pdfContext, SkCanvas* canvas) {
276 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas ); 293 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas );
277 } 294 }
278 295
279 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { 296 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) {
280 297
281 } 298 }
282 }; 299 };
283 300
284 class SkPdfTrueTypeFont : public SkPdfType1Font { 301 class SkPdfTrueTypeFont : public SkPdfType1Font {
285 public: 302 public:
286 SkPdfTrueTypeFont(SkNativeParsedPDF* doc, SkPdfTrueTypeFontDictionary* dict) : SkPdfType1Font(doc, dict) { 303 SkPdfTrueTypeFont(SkPdfNativeDoc* doc, SkPdfTrueTypeFontDictionary* dict) : SkPdfType1Font(doc, dict) {
287 } 304 }
288 }; 305 };
289 306
290 class SkPdfMultiMasterFont : public SkPdfType1Font { 307 class SkPdfMultiMasterFont : public SkPdfType1Font {
291 public: 308 public:
292 SkPdfMultiMasterFont(SkNativeParsedPDF* doc, SkPdfMultiMasterFontDictionary* dict) : SkPdfType1Font(doc, dict) { 309 SkPdfMultiMasterFont(SkPdfNativeDoc* doc, SkPdfMultiMasterFontDictionary* di ct) : SkPdfType1Font(doc, dict) {
293 } 310 }
294 }; 311 };
295 /* 312 /*
296 class CIDToGIDMap { 313 class CIDToGIDMap {
297 virtual unsigned int map(unsigned int cid) = 0; 314 virtual unsigned int map(unsigned int cid) = 0;
298 static CIDToGIDMap* fromName(const char* name); 315 static CIDToGIDMap* fromName(const char* name);
299 }; 316 };
300 317
301 class CIDToGIDMap_Identity { 318 class CIDToGIDMap_Identity {
302 virtual unsigned int map(unsigned int cid) { return cid; } 319 virtual unsigned int map(unsigned int cid) { return cid; }
(...skipping 14 matching lines...) Expand all
317 // TODO(edisonn): warning/report 334 // TODO(edisonn): warning/report
318 printf("Unknown CIDToGIDMap: %s\n", name); 335 printf("Unknown CIDToGIDMap: %s\n", name);
319 #endif 336 #endif
320 return NULL; 337 return NULL;
321 } 338 }
322 CIDToGIDMap* fCidToGid; 339 CIDToGIDMap* fCidToGid;
323 */ 340 */
324 341
325 class SkPdfType3Font : public SkPdfFont { 342 class SkPdfType3Font : public SkPdfFont {
326 struct Type3FontChar { 343 struct Type3FontChar {
327 SkPdfObject* fObj; 344 SkPdfNativeObject* fObj;
328 double fWidth; 345 double fWidth;
329 }; 346 };
330 347
331 SkPdfDictionary* fCharProcs; 348 SkPdfDictionary* fCharProcs;
332 SkPdfEncodingDictionary* fEncodingDict; 349 SkPdfEncodingDictionary* fEncodingDict;
333 unsigned int fFirstChar; 350 unsigned int fFirstChar;
334 unsigned int fLastChar; 351 unsigned int fLastChar;
335 352
336 SkRect fFontBBox; 353 SkRect fFontBBox;
337 SkMatrix fFonMatrix; 354 SkMatrix fFonMatrix;
338 355
339 Type3FontChar* fChars; 356 Type3FontChar* fChars;
340 357
341 public: 358 public:
342 SkPdfType3Font(SkNativeParsedPDF* parsed, SkPdfType3FontDictionary* dict) { 359 SkPdfType3Font(SkPdfNativeDoc* parsed, SkPdfType3FontDictionary* dict) {
343 fBaseFont = fontFromName(parsed, dict, dict->BaseFont(parsed).c_str()); 360 fBaseFont = fontFromName(parsed, dict, dict->BaseFont(parsed).c_str());
344 361
345 if (dict->has_Encoding()) { 362 if (dict->has_Encoding()) {
346 if (dict->isEncodingAName(parsed)) { 363 if (dict->isEncodingAName(parsed)) {
347 fEncoding = SkPdfEncoding::fromName(dict->getEncodingAsName(par sed).c_str()); 364 fEncoding = SkPdfEncoding::fromName(dict->getEncodingAsName(par sed).c_str());
348 } else if (dict->isEncodingAEncodingdictionary(parsed)) { 365 } else if (dict->isEncodingAEncodingdictionary(parsed)) {
349 // No encoding. 366 // No encoding.
350 fEncoding = SkPdfDefaultEncoding::instance(); 367 fEncoding = SkPdfDefaultEncoding::instance();
351 fEncodingDict = dict->getEncodingAsEncodingdictionary(parsed); 368 fEncodingDict = dict->getEncodingAsEncodingdictionary(parsed);
352 } 369 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // TODO(edisonn): report pdf corruption 410 // TODO(edisonn): report pdf corruption
394 } 411 }
395 j++; 412 j++;
396 } else { 413 } else {
397 // TODO(edisonn): report bad pdf 414 // TODO(edisonn): report bad pdf
398 } 415 }
399 } 416 }
400 } 417 }
401 418
402 public: 419 public:
403 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC ontext, SkCanvas* canvas) { 420 virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pd fContext, SkCanvas* canvas) {
404 if (ch < fFirstChar || ch > fLastChar || !fChars[ch - fFirstChar].fObj) { 421 if (ch < fFirstChar || ch > fLastChar || !fChars[ch - fFirstChar].fObj) {
405 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canv as); 422 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canv as);
406 } 423 }
407 424
408 #ifdef PDF_TRACE 425 #ifdef PDF_TRACE
409 printf("Type 3 char to unicode: %c\n", ToUnicode(ch)); 426 printf("Type 3 char to unicode: %c\n", ToUnicode(ch));
410 if (ToUnicode(ch) == 'A') { 427 if (ToUnicode(ch) == 'A') {
411 printf("break;\n"); 428 printf("break;\n");
412 } 429 }
413 #endif 430 #endif
414 431
415 // TODO(edisonn): is it better to resolve the reference at load time, or now? 432 // TODO(edisonn): is it better to resolve the reference at load time, or now?
416 doType3Char(pdfContext, canvas, pdfContext->fPdfDoc->resolveReference(fC hars[ch - fFirstChar].fObj), fFontBBox, fFonMatrix, pdfContext->fGraphicsState.f CurFontSize); 433 doType3Char(pdfContext, canvas, pdfContext->fPdfDoc->resolveReference(fC hars[ch - fFirstChar].fObj), fFontBBox, fFonMatrix, pdfContext->fGraphicsState.f CurFontSize);
417 434
418 // TODO(edisonn): verify/test translate code, not tested yet 435 // TODO(edisonn): verify/test translate code, not tested yet
419 pdfContext->fGraphicsState.fMatrixTm.preTranslate(SkDoubleToScalar(pdfCo ntext->fGraphicsState.fCurFontSize * fChars[ch - fFirstChar].fWidth), 436 pdfContext->fGraphicsState.fMatrixTm.preTranslate(SkDoubleToScalar(pdfCo ntext->fGraphicsState.fCurFontSize * fChars[ch - fFirstChar].fWidth),
420 SkDoubleToScalar(0.0)); 437 SkDoubleToScalar(0.0));
421 return fChars[ch - fFirstChar].fWidth; 438 return fChars[ch - fFirstChar].fWidth;
422 } 439 }
423 440
424 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { 441 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) {
425 442
426 } 443 }
427 }; 444 };
428 445
429 #endif // __DEFINED__SkPdfFont 446 #endif // __DEFINED__SkPdfFont
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfConfig.h ('k') | experimental/PdfViewer/SkPdfFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698