OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 | 23 |
24 struct SkPdfStandardFontEntry { | 24 struct SkPdfStandardFontEntry { |
25 const char* fName; | 25 const char* fName; |
26 bool fIsBold; | 26 bool fIsBold; |
27 bool fIsItalic; | 27 bool fIsItalic; |
28 }; | 28 }; |
29 | 29 |
30 std::map<std::string, SkPdfStandardFontEntry>& getStandardFonts(); | 30 std::map<std::string, SkPdfStandardFontEntry>& getStandardFonts(); |
31 SkTypeface* SkTypefaceFromPdfStandardFont(const char* fontName, bool bold, bool
italic); | 31 SkTypeface* SkTypefaceFromPdfStandardFont(const char* fontName, bool bold, bool
italic); |
32 SkPdfFont* fontFromName(SkPdfObject* obj, const char* fontName); | 32 SkPdfFont* fontFromName(SkNativeParsedPDF* doc, SkPdfObject* obj, const char* fo
ntName); |
33 | 33 |
34 struct SkUnencodedText { | 34 struct SkUnencodedText { |
35 void* text; | 35 void* text; |
36 int len; | 36 int len; |
37 | 37 |
38 public: | 38 public: |
39 SkUnencodedText(const SkPdfString* obj) { | 39 SkUnencodedText(const SkPdfString* obj) { |
40 text = (void*)obj->c_str(); | 40 text = (void*)obj->c_str(); |
41 len = obj->len(); | 41 len = obj->len(); |
42 } | 42 } |
(...skipping 18 matching lines...) Expand all Loading... |
61 | 61 |
62 class SkPdfEncoding { | 62 class SkPdfEncoding { |
63 public: | 63 public: |
64 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu
t) const = 0; | 64 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu
t) const = 0; |
65 static SkPdfEncoding* fromName(const char* name); | 65 static SkPdfEncoding* fromName(const char* name); |
66 }; | 66 }; |
67 | 67 |
68 std::map<std::string, SkPdfEncoding*>& getStandardEncodings(); | 68 std::map<std::string, SkPdfEncoding*>& getStandardEncodings(); |
69 | 69 |
70 class SkPdfToUnicode { | 70 class SkPdfToUnicode { |
| 71 SkNativeParsedPDF* fParsed; |
71 // TODO(edisonn): hide public members | 72 // TODO(edisonn): hide public members |
72 public: | 73 public: |
73 unsigned short* fCMapEncoding; | 74 unsigned short* fCMapEncoding; |
74 unsigned char* fCMapEncodingFlag; | 75 unsigned char* fCMapEncodingFlag; |
75 | 76 |
76 SkPdfToUnicode(const SkPdfStream* stream); | 77 SkPdfToUnicode(SkNativeParsedPDF* parsed, SkPdfStream* stream); |
77 }; | 78 }; |
78 | 79 |
79 | 80 |
80 class SkPdfIdentityHEncoding : public SkPdfEncoding { | 81 class SkPdfIdentityHEncoding : public SkPdfEncoding { |
81 public: | 82 public: |
82 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu
t) const { | 83 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu
t) const { |
83 // TODO(edisonn): SkASSERT(textIn.len % 2 == 0); or report error? | 84 // TODO(edisonn): SkASSERT(textIn.len % 2 == 0); or report error? |
84 | 85 |
85 uint16_t* text = (uint16_t*)textIn.text; | 86 uint16_t* text = (uint16_t*)textIn.text; |
86 textOut->text = new uint16_t[textIn.len / 2]; | 87 textOut->text = new uint16_t[textIn.len / 2]; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 static SkPdfDefaultEncoding* inst = new SkPdfDefaultEncoding(); | 121 static SkPdfDefaultEncoding* inst = new SkPdfDefaultEncoding(); |
121 return inst; | 122 return inst; |
122 } | 123 } |
123 }; | 124 }; |
124 | 125 |
125 class SkPdfCIDToGIDMapIdentityEncoding : public SkPdfEncoding { | 126 class SkPdfCIDToGIDMapIdentityEncoding : public SkPdfEncoding { |
126 public: | 127 public: |
127 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu
t) const { | 128 virtual bool decodeText(const SkUnencodedText& textIn, SkDecodedText* textOu
t) const { |
128 // TODO(edisonn): SkASSERT(textIn.len % 2 == 0); or report error? | 129 // TODO(edisonn): SkASSERT(textIn.len % 2 == 0); or report error? |
129 | 130 |
130 unsigned char* text = (unsigned char*)textIn.text; | 131 uint16_t* text = (uint16_t*)textIn.text; |
131 textOut->text = new uint16_t[textIn.len]; | 132 textOut->text = new uint16_t[textIn.len / 2]; |
132 textOut->len = textIn.len; | 133 textOut->len = textIn.len / 2; |
133 | 134 |
134 for (int i = 0; i < textOut->len; i++) { | 135 for (int i = 0; i < textOut->len; i++) { |
135 textOut->text[i] = text[i]; | 136 textOut->text[i] = ((text[i] << 8) & 0xff00) | ((text[i] >> 8) & 0x0
0ff); |
136 } | 137 } |
137 | 138 |
138 return true; | 139 return true; |
139 } | 140 } |
140 | 141 |
141 static SkPdfCIDToGIDMapIdentityEncoding* instance() { | 142 static SkPdfCIDToGIDMapIdentityEncoding* instance() { |
142 static SkPdfCIDToGIDMapIdentityEncoding* inst = new SkPdfCIDToGIDMapIden
tityEncoding(); | 143 static SkPdfCIDToGIDMapIdentityEncoding* inst = new SkPdfCIDToGIDMapIden
tityEncoding(); |
143 return inst; | 144 return inst; |
144 } | 145 } |
145 }; | 146 }; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 }; | 179 }; |
179 | 180 |
180 inline unsigned int ToUnicode(unsigned int ch) const { | 181 inline unsigned int ToUnicode(unsigned int ch) const { |
181 if (fToUnicode) { | 182 if (fToUnicode) { |
182 return fToUnicode->fCMapEncoding[ch]; | 183 return fToUnicode->fCMapEncoding[ch]; |
183 } else { | 184 } else { |
184 return ch; | 185 return ch; |
185 } | 186 } |
186 }; | 187 }; |
187 | 188 |
188 static SkPdfFont* fontFromPdfDictionary(SkPdfFontDictionary* dict); | 189 static SkPdfFont* fontFromPdfDictionary(SkNativeParsedPDF* doc, SkPdfFontDic
tionary* dict); |
189 static SkPdfFont* Default() {return fontFromName(NULL, "TimesNewRoman");} | 190 static SkPdfFont* Default() {return fontFromName(NULL, NULL, "TimesNewRoman"
);} |
190 | 191 |
191 static SkPdfType0Font* fontFromType0FontDictionary(SkPdfType0FontDictionary*
dict); | 192 static SkPdfType0Font* fontFromType0FontDictionary(SkNativeParsedPDF* doc, S
kPdfType0FontDictionary* dict); |
192 static SkPdfType1Font* fontFromType1FontDictionary(SkPdfType1FontDictionary*
dict); | 193 static SkPdfType1Font* fontFromType1FontDictionary(SkNativeParsedPDF* doc, S
kPdfType1FontDictionary* dict); |
193 static SkPdfType3Font* fontFromType3FontDictionary(SkPdfType3FontDictionary*
dict); | 194 static SkPdfType3Font* fontFromType3FontDictionary(SkNativeParsedPDF* doc, S
kPdfType3FontDictionary* dict); |
194 static SkPdfTrueTypeFont* fontFromTrueTypeFontDictionary(SkPdfTrueTypeFontDi
ctionary* dict); | 195 static SkPdfTrueTypeFont* fontFromTrueTypeFontDictionary(SkNativeParsedPDF*
doc, SkPdfTrueTypeFontDictionary* dict); |
195 static SkPdfMultiMasterFont* fontFromMultiMasterFontDictionary(SkPdfMultiMas
terFontDictionary* dict); | 196 static SkPdfMultiMasterFont* fontFromMultiMasterFontDictionary(SkNativeParse
dPDF* doc, SkPdfMultiMasterFontDictionary* dict); |
196 | 197 |
197 static SkPdfFont* fontFromFontDescriptor(SkPdfFontDescriptorDictionary* fd,
bool loadFromName = true); | 198 static SkPdfFont* fontFromFontDescriptor(SkNativeParsedPDF* doc, SkPdfFontDe
scriptorDictionary* fd, bool loadFromName = true); |
198 | 199 |
199 public: | 200 public: |
200 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC
ontext, SkCanvas* canvas) = 0; | 201 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC
ontext, SkCanvas* canvas) = 0; |
201 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) = 0; | 202 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) = 0; |
| 203 |
| 204 private: |
| 205 static SkPdfFont* fontFromPdfDictionaryOnce(SkNativeParsedPDF* doc, SkPdfFon
tDictionary* dict); |
202 }; | 206 }; |
203 | 207 |
204 class SkPdfStandardFont : public SkPdfFont { | 208 class SkPdfStandardFont : public SkPdfFont { |
205 SkTypeface* fTypeface; | 209 SkTypeface* fTypeface; |
206 | 210 |
207 public: | 211 public: |
208 SkPdfStandardFont(SkTypeface* typeface) : fTypeface(typeface) {} | 212 SkPdfStandardFont(SkTypeface* typeface) : fTypeface(typeface) {} |
209 | 213 |
210 public: | 214 public: |
211 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC
ontext, SkCanvas* canvas) { | 215 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC
ontext, SkCanvas* canvas) { |
212 paint->setTypeface(fTypeface); | 216 paint->setTypeface(fTypeface); |
213 paint->setTextEncoding(SkPaint::kUTF8_TextEncoding); | 217 paint->setTextEncoding(SkPaint::kUTF8_TextEncoding); |
214 | 218 |
215 unsigned long ch4 = ch; | 219 unsigned long ch4 = ch; |
216 char utf8[10]; | 220 char utf8[10]; |
217 int len = SkUTF8_FromUnichar(ch4, utf8); | 221 int len = SkUTF8_FromUnichar(ch4, utf8); |
218 | 222 |
219 canvas->drawText(utf8, len, SkDoubleToScalar(0), SkDoubleToScalar(0), *p
aint); | 223 canvas->drawText(utf8, len, SkDoubleToScalar(0), SkDoubleToScalar(0), *p
aint); |
220 | 224 |
221 SkScalar textWidth = paint->measureText(utf8, len); | 225 SkScalar textWidth = paint->measureText(utf8, len); |
222 return SkScalarToDouble(textWidth); | 226 return SkScalarToDouble(textWidth); |
223 } | 227 } |
224 | 228 |
225 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) {} | 229 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) {} |
226 }; | 230 }; |
227 | 231 |
228 class SkPdfType0Font : public SkPdfFont { | 232 class SkPdfType0Font : public SkPdfFont { |
229 public: | 233 public: |
230 SkPdfType0Font(SkPdfType0FontDictionary* dict); | 234 SkPdfType0Font(SkNativeParsedPDF* doc, SkPdfType0FontDictionary* dict); |
231 | 235 |
232 public: | 236 public: |
233 | 237 |
234 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC
ontext, SkCanvas* canvas) { | 238 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC
ontext, SkCanvas* canvas) { |
235 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas); | 239 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas); |
236 } | 240 } |
237 | 241 |
238 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { | 242 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { |
239 } | 243 } |
240 }; | 244 }; |
241 | 245 |
242 class SkPdfType1Font : public SkPdfFont { | 246 class SkPdfType1Font : public SkPdfFont { |
243 public: | 247 public: |
244 SkPdfType1Font(SkPdfType1FontDictionary* dict) { | 248 SkPdfType1Font(SkNativeParsedPDF* doc, SkPdfType1FontDictionary* dict) { |
245 if (dict->has_FontDescriptor()) { | 249 if (dict->has_FontDescriptor()) { |
246 fBaseFont = SkPdfFont::fontFromFontDescriptor(dict->FontDescriptor()
); | 250 fBaseFont = SkPdfFont::fontFromFontDescriptor(doc, dict->FontDescrip
tor(doc)); |
247 } else { | 251 } else { |
248 fBaseFont = fontFromName(dict, dict->BaseFont().c_str()); | 252 fBaseFont = fontFromName(doc, dict, dict->BaseFont(doc).c_str()); |
249 } | 253 } |
250 } | 254 } |
251 | 255 |
252 public: | 256 public: |
253 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pd
fContext, SkCanvas* canvas) { | 257 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pd
fContext, SkCanvas* canvas) { |
254 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas
); | 258 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas
); |
255 } | 259 } |
256 | 260 |
257 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { | 261 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { |
258 | 262 |
259 } | 263 } |
260 }; | 264 }; |
261 | 265 |
262 class SkPdfTrueTypeFont : public SkPdfType1Font { | 266 class SkPdfTrueTypeFont : public SkPdfType1Font { |
263 public: | 267 public: |
264 SkPdfTrueTypeFont(SkPdfTrueTypeFontDictionary* dict) : SkPdfType1Font(dict)
{ | 268 SkPdfTrueTypeFont(SkNativeParsedPDF* doc, SkPdfTrueTypeFontDictionary* dict)
: SkPdfType1Font(doc, dict) { |
265 } | 269 } |
266 }; | 270 }; |
267 | 271 |
268 class SkPdfMultiMasterFont : public SkPdfType1Font { | 272 class SkPdfMultiMasterFont : public SkPdfType1Font { |
269 public: | 273 public: |
270 SkPdfMultiMasterFont(SkPdfMultiMasterFontDictionary* dict) : SkPdfType1Font(
dict) { | 274 SkPdfMultiMasterFont(SkNativeParsedPDF* doc, SkPdfMultiMasterFontDictionary*
dict) : SkPdfType1Font(doc, dict) { |
271 } | 275 } |
272 }; | 276 }; |
273 /* | 277 /* |
274 class CIDToGIDMap { | 278 class CIDToGIDMap { |
275 virtual unsigned int map(unsigned int cid) = 0; | 279 virtual unsigned int map(unsigned int cid) = 0; |
276 static CIDToGIDMap* fromName(const char* name); | 280 static CIDToGIDMap* fromName(const char* name); |
277 }; | 281 }; |
278 | 282 |
279 class CIDToGIDMap_Identity { | 283 class CIDToGIDMap_Identity { |
280 virtual unsigned int map(unsigned int cid) { return cid; } | 284 virtual unsigned int map(unsigned int cid) { return cid; } |
(...skipping 14 matching lines...) Expand all Loading... |
295 // TODO(edisonn): warning/report | 299 // TODO(edisonn): warning/report |
296 printf("Unknown CIDToGIDMap: %s\n", name); | 300 printf("Unknown CIDToGIDMap: %s\n", name); |
297 #endif | 301 #endif |
298 return NULL; | 302 return NULL; |
299 } | 303 } |
300 CIDToGIDMap* fCidToGid; | 304 CIDToGIDMap* fCidToGid; |
301 */ | 305 */ |
302 | 306 |
303 class SkPdfType3Font : public SkPdfFont { | 307 class SkPdfType3Font : public SkPdfFont { |
304 struct Type3FontChar { | 308 struct Type3FontChar { |
305 SkPdfObject* fObj; | 309 const SkPdfObject* fObj; |
306 double fWidth; | 310 double fWidth; |
307 }; | 311 }; |
308 | 312 |
309 SkPdfDictionary* fCharProcs; | 313 SkPdfDictionary* fCharProcs; |
310 SkPdfEncodingDictionary* fEncodingDict; | 314 SkPdfEncodingDictionary* fEncodingDict; |
311 unsigned int fFirstChar; | 315 unsigned int fFirstChar; |
312 unsigned int fLastChar; | 316 unsigned int fLastChar; |
313 | 317 |
314 SkRect fFontBBox; | 318 SkRect fFontBBox; |
315 SkMatrix fFonMatrix; | 319 SkMatrix fFonMatrix; |
316 | 320 |
317 Type3FontChar* fChars; | 321 Type3FontChar* fChars; |
318 | 322 |
319 public: | 323 public: |
320 SkPdfType3Font(SkPdfType3FontDictionary* dict) { | 324 SkPdfType3Font(SkNativeParsedPDF* parsed, SkPdfType3FontDictionary* dict) { |
321 fBaseFont = fontFromName(dict, dict->BaseFont().c_str()); | 325 fBaseFont = fontFromName(parsed, dict, dict->BaseFont(parsed).c_str()); |
322 | 326 |
323 if (dict->has_Encoding()) { | 327 if (dict->has_Encoding()) { |
324 if (dict->isEncodingAName()) { | 328 if (dict->isEncodingAName(parsed)) { |
325 fEncoding = SkPdfEncoding::fromName(dict->getEncodingAsName().c
_str()); | 329 fEncoding = SkPdfEncoding::fromName(dict->getEncodingAsName(par
sed).c_str()); |
326 } else if (dict->isEncodingAEncodingdictionary()) { | 330 } else if (dict->isEncodingAEncodingdictionary(parsed)) { |
327 // technically, there is no encoding. | 331 // technically, there is no encoding. |
328 fEncoding = SkPdfCIDToGIDMapIdentityEncoding::instance(); | 332 fEncoding = SkPdfCIDToGIDMapIdentityEncoding::instance(); |
329 fEncodingDict = dict->getEncodingAsEncodingdictionary(); | 333 fEncodingDict = dict->getEncodingAsEncodingdictionary(parsed); |
330 } | 334 } |
331 } | 335 } |
332 | 336 |
333 // null? | 337 // null? |
334 fCharProcs = dict->CharProcs(); | 338 fCharProcs = dict->CharProcs(parsed); |
335 | 339 |
336 fToUnicode = NULL; | 340 fToUnicode = NULL; |
337 if (dict->has_ToUnicode()) { | 341 if (dict->has_ToUnicode()) { |
338 fToUnicode = new SkPdfToUnicode(dict->ToUnicode()); | 342 fToUnicode = new SkPdfToUnicode(parsed, dict->ToUnicode(parsed)); |
339 } | 343 } |
340 | 344 |
341 fFirstChar = dict->FirstChar(); | 345 fFirstChar = dict->FirstChar(parsed); |
342 fLastChar = dict->LastChar(); | 346 fLastChar = dict->LastChar(parsed); |
343 fFonMatrix = dict->has_FontMatrix() ? *dict->FontMatrix() : SkMatrix::I(
); | 347 fFonMatrix = dict->has_FontMatrix() ? dict->FontMatrix(parsed) : SkMatri
x::I(); |
344 | 348 |
345 if (dict->FontBBox()) { | 349 if (dict->has_FontBBox()) { |
346 fFontBBox = *dict->FontBBox(); | 350 fFontBBox = dict->FontBBox(parsed); |
347 } | 351 } |
348 | 352 |
349 fChars = new Type3FontChar[fLastChar - fFirstChar + 1]; | 353 fChars = new Type3FontChar[fLastChar - fFirstChar + 1]; |
350 | 354 |
351 memset(fChars, 0, sizeof(fChars[0]) * (fLastChar - fFirstChar + 1)); | 355 memset(fChars, 0, sizeof(fChars[0]) * (fLastChar - fFirstChar + 1)); |
352 | 356 |
353 | 357 |
354 SkPdfArray* widths = dict->Widths(); | 358 const SkPdfArray* widths = dict->Widths(parsed); |
355 for (int i = 0 ; i < widths->size(); i++) { | 359 for (unsigned int i = 0 ; i < widths->size(); i++) { |
356 if ((fFirstChar + i) < fFirstChar || (fFirstChar + i) > fLastChar) { | 360 if ((fFirstChar + i) < fFirstChar || (fFirstChar + i) > fLastChar) { |
357 printf("break; error 1\n"); | 361 printf("break; error 1\n"); |
358 } | 362 } |
359 fChars[i].fWidth = (*widths)[i]->asNumber()->value(); | 363 fChars[i].fWidth = (*widths)[i]->numberValue(); |
360 } | 364 } |
361 | 365 |
362 SkPdfArray* diffs = fEncodingDict->Differences(); | 366 const SkPdfArray* diffs = fEncodingDict->Differences(parsed); |
363 int j = fFirstChar; | 367 unsigned int j = fFirstChar; |
364 for (int i = 0 ; i < diffs->size(); i++) { | 368 for (unsigned int i = 0 ; i < diffs->size(); i++) { |
365 if ((*diffs)[i]->asInteger()) { | 369 if ((*diffs)[i]->isInteger()) { |
366 j = (*diffs)[i]->asInteger()->value(); | 370 j = (*diffs)[i]->intValue(); |
367 } else if ((*diffs)[i]->asName()) { | 371 } else if ((*diffs)[i]->isName()) { |
368 if (j < fFirstChar || j > fLastChar) { | 372 if (j < fFirstChar || j > fLastChar) { |
369 printf("break; error 2\n"); | 373 printf("break; error 2\n"); |
370 } | 374 } |
371 fChars[j - fFirstChar].fObj = fCharProcs->get((*diffs)[i]->asNam
e()->value().c_str()); | 375 fChars[j - fFirstChar].fObj = fCharProcs->get((*diffs)[i]->nameV
alue()); |
372 j++; | 376 j++; |
373 } else { | 377 } else { |
374 // err | 378 // err |
375 } | 379 } |
376 } | 380 } |
377 } | 381 } |
378 | 382 |
379 public: | 383 public: |
380 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC
ontext, SkCanvas* canvas) { | 384 virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfC
ontext, SkCanvas* canvas) { |
381 if (ch < fFirstChar || ch > fLastChar || !fChars[ch - fFirstChar].fObj)
{ | 385 if (ch < fFirstChar || ch > fLastChar || !fChars[ch - fFirstChar].fObj)
{ |
382 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canv
as); | 386 return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canv
as); |
383 } | 387 } |
384 | 388 |
385 #ifdef PDF_TRACE | 389 #ifdef PDF_TRACE |
386 printf("Type 3 char to unicode: %c\n", ToUnicode(ch)); | 390 printf("Type 3 char to unicode: %c\n", ToUnicode(ch)); |
387 if (ToUnicode(ch) == 'A') { | 391 if (ToUnicode(ch) == 'A') { |
388 printf("break;\n"); | 392 printf("break;\n"); |
389 } | 393 } |
390 #endif | 394 #endif |
391 | 395 |
392 doType3Char(pdfContext, canvas, fChars[ch - fFirstChar].fObj, fFontBBox,
fFonMatrix, pdfContext->fGraphicsState.fCurFontSize); | 396 // TODO(edisonn): is it better to resolve the reference at load time, or
now? |
| 397 doType3Char(pdfContext, canvas, pdfContext->fPdfDoc->resolveReference(fC
hars[ch - fFirstChar].fObj), fFontBBox, fFonMatrix, pdfContext->fGraphicsState.f
CurFontSize); |
393 | 398 |
394 // TODO(edisonn): verify/test translate code, not tested yet | 399 // TODO(edisonn): verify/test translate code, not tested yet |
395 pdfContext->fGraphicsState.fMatrixTm.preTranslate(SkDoubleToScalar(pdfCo
ntext->fGraphicsState.fCurFontSize * fChars[ch - fFirstChar].fWidth), | 400 pdfContext->fGraphicsState.fMatrixTm.preTranslate(SkDoubleToScalar(pdfCo
ntext->fGraphicsState.fCurFontSize * fChars[ch - fFirstChar].fWidth), |
396 SkDoubleToScalar(0.0)); | 401 SkDoubleToScalar(0.0)); |
| 402 return fChars[ch - fFirstChar].fWidth; |
397 } | 403 } |
398 | 404 |
399 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { | 405 virtual void afterWord(SkPaint* paint, SkMatrix* matrix) { |
400 | 406 |
401 } | 407 } |
402 }; | 408 }; |
403 | 409 |
404 #endif // __DEFINED__SkPdfFont | 410 #endif // __DEFINED__SkPdfFont |
OLD | NEW |