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

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

Issue 23258004: pdfviewer: code cleanup - remove STL usage (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/SkPdfFont.h ('k') | experimental/PdfViewer/SkPdfGraphicsState.h » ('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 SkTDict<SkPdfStandardFontEntry>& getStandardFonts() {
8 static std::map<std::string, SkPdfStandardFontEntry> gPdfStandardFonts; 8 static SkTDict<SkPdfStandardFontEntry> gPdfStandardFonts(100);
9 9
10 // TODO (edisonn): , vs - ? what does it mean? 10 // TODO (edisonn): , vs - ? what does it mean?
11 // TODO (edisonn): MT, PS, Oblique=italic?, ... what does it mean? 11 // TODO (edisonn): MT, PS, Oblique=italic?, ... what does it mean?
12 if (gPdfStandardFonts.empty()) { 12 if (gPdfStandardFonts.count() == 0) {
13 gPdfStandardFonts["Arial"] = SkPdfStandardFontEntry("Arial", false, fals e); 13 gPdfStandardFonts.set("Arial", SkPdfStandardFontEntry("Arial", false, fa lse));
14 gPdfStandardFonts["Arial,Bold"] = SkPdfStandardFontEntry("Arial", true, false); 14 gPdfStandardFonts.set("Arial,Bold", SkPdfStandardFontEntry("Arial", true , false));
15 gPdfStandardFonts["Arial,BoldItalic"] = SkPdfStandardFontEntry("Arial", true, true); 15 gPdfStandardFonts.set("Arial,BoldItalic", SkPdfStandardFontEntry("Arial" , true, true));
16 gPdfStandardFonts["Arial,Italic"] = SkPdfStandardFontEntry("Arial", fals e, true); 16 gPdfStandardFonts.set("Arial,Italic", SkPdfStandardFontEntry("Arial", fa lse, true));
17 gPdfStandardFonts["Arial-Bold"] = SkPdfStandardFontEntry("Arial", true, false); 17 gPdfStandardFonts.set("Arial-Bold", SkPdfStandardFontEntry("Arial", true , false));
18 gPdfStandardFonts["Arial-BoldItalic"] = SkPdfStandardFontEntry("Arial", true, true); 18 gPdfStandardFonts.set("Arial-BoldItalic", SkPdfStandardFontEntry("Arial" , true, true));
19 gPdfStandardFonts["Arial-BoldItalicMT"] = SkPdfStandardFontEntry("Arial" , true, true); 19 gPdfStandardFonts.set("Arial-BoldItalicMT", SkPdfStandardFontEntry("Aria l", true, true));
20 gPdfStandardFonts["Arial-BoldMT"] = SkPdfStandardFontEntry("Arial", true , false); 20 gPdfStandardFonts.set("Arial-BoldMT", SkPdfStandardFontEntry("Arial", tr ue, false));
21 gPdfStandardFonts["Arial-Italic"] = SkPdfStandardFontEntry("Arial", fals e, true); 21 gPdfStandardFonts.set("Arial-Italic", SkPdfStandardFontEntry("Arial", fa lse, true));
22 gPdfStandardFonts["Arial-ItalicMT"] = SkPdfStandardFontEntry("Arial", fa lse, true); 22 gPdfStandardFonts.set("Arial-ItalicMT", SkPdfStandardFontEntry("Arial", false, true));
23 gPdfStandardFonts["ArialMT"] = SkPdfStandardFontEntry("Arial", false, fa lse); 23 gPdfStandardFonts.set("ArialMT", SkPdfStandardFontEntry("Arial", false, false));
24 gPdfStandardFonts["Courier"] = SkPdfStandardFontEntry("Courier New", fal se, false); 24 gPdfStandardFonts.set("Courier", SkPdfStandardFontEntry("Courier New", f alse, false));
25 gPdfStandardFonts["Courier,Bold"] = SkPdfStandardFontEntry("Courier New" , true, false); 25 gPdfStandardFonts.set("Courier,Bold", SkPdfStandardFontEntry("Courier Ne w", true, false));
26 gPdfStandardFonts["Courier,BoldItalic"] = SkPdfStandardFontEntry("Courie r New", true, true); 26 gPdfStandardFonts.set("Courier,BoldItalic", SkPdfStandardFontEntry("Cour ier New", true, true));
27 gPdfStandardFonts["Courier,Italic"] = SkPdfStandardFontEntry("Courier Ne w", false, true); 27 gPdfStandardFonts.set("Courier,Italic", SkPdfStandardFontEntry("Courier New", false, true));
28 gPdfStandardFonts["Courier-Bold"] = SkPdfStandardFontEntry("Courier New" , true, false); 28 gPdfStandardFonts.set("Courier-Bold", SkPdfStandardFontEntry("Courier Ne w", true, false));
29 gPdfStandardFonts["Courier-BoldOblique"] = SkPdfStandardFontEntry("Couri er New", true, true); 29 gPdfStandardFonts.set("Courier-BoldOblique", SkPdfStandardFontEntry("Cou rier New", true, true));
30 gPdfStandardFonts["Courier-Oblique"] = SkPdfStandardFontEntry("Courier N ew", false, true); 30 gPdfStandardFonts.set("Courier-Oblique", SkPdfStandardFontEntry("Courier New", false, true));
31 gPdfStandardFonts["CourierNew"] = SkPdfStandardFontEntry("Courier New", false, false); 31 gPdfStandardFonts.set("CourierNew", SkPdfStandardFontEntry("Courier New" , false, false));
32 gPdfStandardFonts["CourierNew,Bold"] = SkPdfStandardFontEntry("Courier N ew", true, false); 32 gPdfStandardFonts.set("CourierNew,Bold", SkPdfStandardFontEntry("Courier New", true, false));
33 gPdfStandardFonts["CourierNew,BoldItalic"] = SkPdfStandardFontEntry("Cou rier New", true, true); 33 gPdfStandardFonts.set("CourierNew,BoldItalic", SkPdfStandardFontEntry("C ourier New", true, true));
34 gPdfStandardFonts["CourierNew,Italic"] = SkPdfStandardFontEntry("Courier New", false, true); 34 gPdfStandardFonts.set("CourierNew,Italic", SkPdfStandardFontEntry("Couri er New", false, true));
35 gPdfStandardFonts["CourierNew-Bold"] = SkPdfStandardFontEntry("Courier N ew", true, false); 35 gPdfStandardFonts.set("CourierNew-Bold", SkPdfStandardFontEntry("Courier New", true, false));
36 gPdfStandardFonts["CourierNew-BoldItalic"] = SkPdfStandardFontEntry("Cou rier New", true, true); 36 gPdfStandardFonts.set("CourierNew-BoldItalic", SkPdfStandardFontEntry("C ourier New", true, true));
37 gPdfStandardFonts["CourierNew-Italic"] = SkPdfStandardFontEntry("Courier New", false, true); 37 gPdfStandardFonts.set("CourierNew-Italic", SkPdfStandardFontEntry("Couri er New", false, true));
38 gPdfStandardFonts["CourierNewPS-BoldItalicMT"] = SkPdfStandardFontEntry( "Courier New", true, true); 38 gPdfStandardFonts.set("CourierNewPS-BoldItalicMT", SkPdfStandardFontEntr y("Courier New", true, true));
39 gPdfStandardFonts["CourierNewPS-BoldMT"] = SkPdfStandardFontEntry("Couri er New", true, false); 39 gPdfStandardFonts.set("CourierNewPS-BoldMT", SkPdfStandardFontEntry("Cou rier New", true, false));
40 gPdfStandardFonts["CourierNewPS-ItalicMT"] = SkPdfStandardFontEntry("Cou rier New", false, true); 40 gPdfStandardFonts.set("CourierNewPS-ItalicMT", SkPdfStandardFontEntry("C ourier New", false, true));
41 gPdfStandardFonts["CourierNewPSMT"] = SkPdfStandardFontEntry("Courier Ne w", false, false); 41 gPdfStandardFonts.set("CourierNewPSMT", SkPdfStandardFontEntry("Courier New", false, false));
42 gPdfStandardFonts["Helvetica"] = SkPdfStandardFontEntry("Helvetica", fal se, false); 42 gPdfStandardFonts.set("Helvetica", SkPdfStandardFontEntry("Helvetica", f alse, false));
43 gPdfStandardFonts["Helvetica,Bold"] = SkPdfStandardFontEntry("Helvetica" , true, false); 43 gPdfStandardFonts.set("Helvetica,Bold", SkPdfStandardFontEntry("Helvetic a", true, false));
44 gPdfStandardFonts["Helvetica,BoldItalic"] = SkPdfStandardFontEntry("Helv etica", true, true); 44 gPdfStandardFonts.set("Helvetica,BoldItalic", SkPdfStandardFontEntry("He lvetica", true, true));
45 gPdfStandardFonts["Helvetica,Italic"] = SkPdfStandardFontEntry("Helvetic a", false, true); 45 gPdfStandardFonts.set("Helvetica,Italic", SkPdfStandardFontEntry("Helvet ica", false, true));
46 gPdfStandardFonts["Helvetica-Bold"] = SkPdfStandardFontEntry("Helvetica" , true, false); 46 gPdfStandardFonts.set("Helvetica-Bold", SkPdfStandardFontEntry("Helvetic a", true, false));
47 gPdfStandardFonts["Helvetica-BoldItalic"] = SkPdfStandardFontEntry("Helv etica", true, true); 47 gPdfStandardFonts.set("Helvetica-BoldItalic", SkPdfStandardFontEntry("He lvetica", true, true));
48 gPdfStandardFonts["Helvetica-BoldOblique"] = SkPdfStandardFontEntry("Hel vetica", true, true); 48 gPdfStandardFonts.set("Helvetica-BoldOblique", SkPdfStandardFontEntry("H elvetica", true, true));
49 gPdfStandardFonts["Helvetica-Italic"] = SkPdfStandardFontEntry("Helvetic a", false, true); 49 gPdfStandardFonts.set("Helvetica-Italic", SkPdfStandardFontEntry("Helvet ica", false, true));
50 gPdfStandardFonts["Helvetica-Oblique"] = SkPdfStandardFontEntry("Helveti ca", false, true); 50 gPdfStandardFonts.set("Helvetica-Oblique", SkPdfStandardFontEntry("Helve tica", false, true));
51 gPdfStandardFonts["Times-Bold"] = SkPdfStandardFontEntry("Times New Roma n", true, false); 51 gPdfStandardFonts.set("Times-Bold", SkPdfStandardFontEntry("Times New Ro man", true, false));
52 gPdfStandardFonts["Times-BoldItalic"] = SkPdfStandardFontEntry("Times Ne w Roman", true, true); 52 gPdfStandardFonts.set("Times-BoldItalic", SkPdfStandardFontEntry("Times New Roman", true, true));
53 gPdfStandardFonts["Times-Italic"] = SkPdfStandardFontEntry("Times New Ro man", false, true); 53 gPdfStandardFonts.set("Times-Italic", SkPdfStandardFontEntry("Times New Roman", false, true));
54 gPdfStandardFonts["Times-Roman"] = SkPdfStandardFontEntry("Times New Rom an", false, false); 54 gPdfStandardFonts.set("Times-Roman", SkPdfStandardFontEntry("Times New R oman", false, false));
55 gPdfStandardFonts["TimesNewRoman"] = SkPdfStandardFontEntry("Times New R oman", false, false); 55 gPdfStandardFonts.set("TimesNewRoman", SkPdfStandardFontEntry("Times New Roman", false, false));
56 gPdfStandardFonts["TimesNewRoman,Bold"] = SkPdfStandardFontEntry("Times New Roman", true, false); 56 gPdfStandardFonts.set("TimesNewRoman,Bold", SkPdfStandardFontEntry("Time s New Roman", true, false));
57 gPdfStandardFonts["TimesNewRoman,BoldItalic"] = SkPdfStandardFontEntry(" Times New Roman", true, true); 57 gPdfStandardFonts.set("TimesNewRoman,BoldItalic", SkPdfStandardFontEntry ("Times New Roman", true, true));
58 gPdfStandardFonts["TimesNewRoman,Italic"] = SkPdfStandardFontEntry("Time s New Roman", false, true); 58 gPdfStandardFonts.set("TimesNewRoman,Italic", SkPdfStandardFontEntry("Ti mes New Roman", false, true));
59 gPdfStandardFonts["TimesNewRoman-Bold"] = SkPdfStandardFontEntry("Times New Roman", true, false); 59 gPdfStandardFonts.set("TimesNewRoman-Bold", SkPdfStandardFontEntry("Time s New Roman", true, false));
60 gPdfStandardFonts["TimesNewRoman-BoldItalic"] = SkPdfStandardFontEntry(" Times New Roman", true, true); 60 gPdfStandardFonts.set("TimesNewRoman-BoldItalic", SkPdfStandardFontEntry ("Times New Roman", true, true));
61 gPdfStandardFonts["TimesNewRoman-Italic"] = SkPdfStandardFontEntry("Time s New Roman", false, true); 61 gPdfStandardFonts.set("TimesNewRoman-Italic", SkPdfStandardFontEntry("Ti mes New Roman", false, true));
62 gPdfStandardFonts["TimesNewRomanPS"] = SkPdfStandardFontEntry("Times New Roman", false, false); 62 gPdfStandardFonts.set("TimesNewRomanPS", SkPdfStandardFontEntry("Times N ew Roman", false, false));
63 gPdfStandardFonts["TimesNewRomanPS-Bold"] = SkPdfStandardFontEntry("Time s New Roman", true, false); 63 gPdfStandardFonts.set("TimesNewRomanPS-Bold", SkPdfStandardFontEntry("Ti mes New Roman", true, false));
64 gPdfStandardFonts["TimesNewRomanPS-BoldItalic"] = SkPdfStandardFontEntry ("Times New Roman", true, true); 64 gPdfStandardFonts.set("TimesNewRomanPS-BoldItalic", SkPdfStandardFontEnt ry("Times New Roman", true, true));
65 gPdfStandardFonts["TimesNewRomanPS-BoldItalicMT"] = SkPdfStandardFontEnt ry("Times New Roman", true, true); 65 gPdfStandardFonts.set("TimesNewRomanPS-BoldItalicMT", SkPdfStandardFontE ntry("Times New Roman", true, true));
66 gPdfStandardFonts["TimesNewRomanPS-BoldMT"] = SkPdfStandardFontEntry("Ti mes New Roman", true, false); 66 gPdfStandardFonts.set("TimesNewRomanPS-BoldMT", SkPdfStandardFontEntry(" Times New Roman", true, false));
67 gPdfStandardFonts["TimesNewRomanPS-Italic"] = SkPdfStandardFontEntry("Ti mes New Roman", false, true); 67 gPdfStandardFonts.set("TimesNewRomanPS-Italic", SkPdfStandardFontEntry(" Times New Roman", false, true));
68 gPdfStandardFonts["TimesNewRomanPS-ItalicMT"] = SkPdfStandardFontEntry(" Times New Roman", false, true); 68 gPdfStandardFonts.set("TimesNewRomanPS-ItalicMT", SkPdfStandardFontEntry ("Times New Roman", false, true));
69 gPdfStandardFonts["TimesNewRomanPSMT"] = SkPdfStandardFontEntry("Times N ew Roman", false, false); 69 gPdfStandardFonts.set("TimesNewRomanPSMT", SkPdfStandardFontEntry("Times New Roman", false, false));
70 gPdfStandardFonts["Symbol"] = SkPdfStandardFontEntry("Symbol", false, fa lse); 70 gPdfStandardFonts.set("Symbol", SkPdfStandardFontEntry("Symbol", false, false));
71 gPdfStandardFonts["ZapfDingbats"] = SkPdfStandardFontEntry("ZapfDingbats ", false, false); 71 gPdfStandardFonts.set("ZapfDingbats", SkPdfStandardFontEntry("ZapfDingba ts", false, false));
72 72
73 // TODO(edisonn): these are hacks. Load Post Script font name. 73 // TODO(edisonn): these are hacks. Load Post Script font name.
74 // see FT_Get_Postscript_Name 74 // see FT_Get_Postscript_Name
75 // Font config is not using it, yet. 75 // Font config is not using it, yet.
76 //https://bugs.freedesktop.org/show_bug.cgi?id=18095 76 //https://bugs.freedesktop.org/show_bug.cgi?id=18095
77 77
78 gPdfStandardFonts["Arial-Black"] = SkPdfStandardFontEntry("Arial", true, false); 78 gPdfStandardFonts.set("Arial-Black", SkPdfStandardFontEntry("Arial", tru e, false));
79 gPdfStandardFonts["DejaVuSans"] = SkPdfStandardFontEntry("DejaVu Sans", false, false); 79 gPdfStandardFonts.set("DejaVuSans", SkPdfStandardFontEntry("DejaVu Sans" , false, false));
80 gPdfStandardFonts["DejaVuSansMono"] = SkPdfStandardFontEntry("DejaVuSans Mono", false, false); 80 gPdfStandardFonts.set("DejaVuSansMono", SkPdfStandardFontEntry("DejaVuSa ns Mono", false, false));
81 gPdfStandardFonts["DejaVuSansMono-Bold"] = SkPdfStandardFontEntry("DejaV uSans Mono", true, false); 81 gPdfStandardFonts.set("DejaVuSansMono-Bold", SkPdfStandardFontEntry("Dej aVuSans Mono", true, false));
82 gPdfStandardFonts["DejaVuSansMono-Oblique"] = SkPdfStandardFontEntry("De jaVuSans Mono", false, true); 82 gPdfStandardFonts.set("DejaVuSansMono-Oblique", SkPdfStandardFontEntry(" DejaVuSans Mono", false, true));
83 gPdfStandardFonts["Georgia-Bold"] = SkPdfStandardFontEntry("Georgia", tr ue, false); 83 gPdfStandardFonts.set("Georgia-Bold", SkPdfStandardFontEntry("Georgia", true, false));
84 gPdfStandardFonts["Georgia-BoldItalic"] = SkPdfStandardFontEntry("Georgi a", true, true); 84 gPdfStandardFonts.set("Georgia-BoldItalic", SkPdfStandardFontEntry("Geor gia", true, true));
85 gPdfStandardFonts["Georgia-Italic"] = SkPdfStandardFontEntry("Georgia", false, true); 85 gPdfStandardFonts.set("Georgia-Italic", SkPdfStandardFontEntry("Georgia" , false, true));
86 gPdfStandardFonts["TrebuchetMS"] = SkPdfStandardFontEntry("Trebuchet MS" , false, false); 86 gPdfStandardFonts.set("TrebuchetMS", SkPdfStandardFontEntry("Trebuchet M S", false, false));
87 gPdfStandardFonts["TrebuchetMS-Bold"] = SkPdfStandardFontEntry("Trebuche t MS", true, false); 87 gPdfStandardFonts.set("TrebuchetMS-Bold", SkPdfStandardFontEntry("Trebuc het MS", true, false));
88 gPdfStandardFonts["Verdana-Bold"] = SkPdfStandardFontEntry("Verdana", tr ue, false); 88 gPdfStandardFonts.set("Verdana-Bold", SkPdfStandardFontEntry("Verdana", true, false));
89 gPdfStandardFonts["WenQuanYiMicroHei"] = SkPdfStandardFontEntry("WenQuan Yi Micro Hei", false, false); 89 gPdfStandardFonts.set("WenQuanYiMicroHei", SkPdfStandardFontEntry("WenQu anYi Micro Hei", false, false));
90 90
91 // TODO(edisonn): list all phonts available, builf post script name as i n pdf spec 91 // TODO(edisonn): list all phonts available, builf post script name as i n pdf spec
92 /* 92 /*
93 * The PostScript name for the value of BaseFontis determined in one of two ways: 93 * The PostScript name for the value of BaseFontis determined in one of two ways:
94 • Use the PostScript name that is an optional entry in the “name” table of the 94 • Use the PostScript name that is an optional entry in the “name” table of the
95 TrueType font itself. 95 TrueType font itself.
96 • In the absence of such an entry in the “name” table, derive a PostScript name 96 • In the absence of such an entry in the “name” table, derive a PostScript name
97 from the name by which the font is known in the host operating system: on a 97 from the name by which the font is known in the host operating system: on a
98 Windows system, it is based on the lfFaceName field in a LOGFONT structure; in 98 Windows system, it is based on the lfFaceName field in a LOGFONT structure; in
99 the Mac OS, it is based on the name of the FONDresource. If the name contains 99 the Mac OS, it is based on the name of the FONDresource. If the name contains
(...skipping 14 matching lines...) Expand all
114 114
115 // might not work on all oses ? 115 // might not work on all oses ?
116 // 116 //
117 117
118 } 118 }
119 119
120 return gPdfStandardFonts; 120 return gPdfStandardFonts;
121 } 121 }
122 122
123 SkTypeface* SkTypefaceFromPdfStandardFont(const char* fontName, bool bold, bool italic) { 123 SkTypeface* SkTypefaceFromPdfStandardFont(const char* fontName, bool bold, bool italic) {
124 std::map<std::string, SkPdfStandardFontEntry>& standardFontMap = getStandard Fonts(); 124 SkTDict<SkPdfStandardFontEntry>& standardFontMap = getStandardFonts();
125 125
126 SkTypeface* typeface = NULL; 126 SkTypeface* typeface = NULL;
127 if (standardFontMap.find(fontName) != standardFontMap.end()) { 127 SkPdfStandardFontEntry fontData;
128 SkPdfStandardFontEntry fontData = standardFontMap[fontName];
129 128
129 if (standardFontMap.find(fontName, &fontData)) {
130 // TODO(edisonn): How does the bold/italic specified in standard definit ion combines with 130 // TODO(edisonn): How does the bold/italic specified in standard definit ion combines with
131 // the one in /font key? use OR for now. 131 // the one in /font key? use OR for now.
132 bold = bold || fontData.fIsBold; 132 bold = bold || fontData.fIsBold;
133 italic = italic || fontData.fIsItalic; 133 italic = italic || fontData.fIsItalic;
134 134
135 typeface = SkTypeface::CreateFromName( 135 typeface = SkTypeface::CreateFromName(
136 fontData.fName, 136 fontData.fName,
137 SkTypeface::Style((bold ? SkTypeface::kBold : 0) | 137 SkTypeface::Style((bold ? SkTypeface::kBold : 0) |
138 (italic ? SkTypeface::kItalic : 0))); 138 (italic ? SkTypeface::kItalic : 0)));
139 } else { 139 } else {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 if (!obj || !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).equals(fontName)) {
211 SkPdfFont* font = SkPdfFont::fontFromFontDescriptor(doc, fd, false); 211 SkPdfFont* font = SkPdfFont::fontFromFontDescriptor(doc, fd, false);
212 if (font) { 212 if (font) {
213 return font; 213 return font;
214 } else { 214 } else {
215 // failed to load font descriptor 215 // failed to load font descriptor
216 break; 216 break;
217 } 217 }
218 } 218 }
219 } 219 }
220 220
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } else { 425 } else {
426 // TODO(edisonn): error ... warning .. assert? 426 // TODO(edisonn): error ... warning .. assert?
427 } 427 }
428 } 428 }
429 429
430 if (dict->has_ToUnicode()) { 430 if (dict->has_ToUnicode()) {
431 fToUnicode = new SkPdfToUnicode(doc, dict->ToUnicode(doc)); 431 fToUnicode = new SkPdfToUnicode(doc, dict->ToUnicode(doc));
432 } 432 }
433 } 433 }
434 434
435 std::map<std::string, SkPdfEncoding*>& getStandardEncodings() { 435 SkTDict<SkPdfEncoding*>& getStandardEncodings() {
436 static std::map<std::string, SkPdfEncoding*> encodings; 436 static SkTDict<SkPdfEncoding*> encodings(10);
437 if (encodings.empty()) { 437 if (encodings.count() == 0) {
438 encodings["Identity-H"] = SkPdfIdentityHEncoding::instance(); 438 encodings.set("Identity-H", SkPdfIdentityHEncoding::instance());
439 } 439 }
440 440
441 return encodings; 441 return encodings;
442 } 442 }
443 443
444
445 SkPdfEncoding* SkPdfEncoding::fromName(const char* name) { 444 SkPdfEncoding* SkPdfEncoding::fromName(const char* name) {
446 SkPdfEncoding* encoding = getStandardEncodings()[name]; 445 SkPdfEncoding* encoding = NULL;
446 if (!getStandardEncodings().find(name, &encoding)) {
447 // TODO(edisonn): if the function return false, and we a guaranteed that the value is not
448 // changed, delete this set to null
449 encoding = NULL;
450 }
447 451
448 #ifdef PDF_TRACE 452 #ifdef PDF_TRACE
449 if (encoding == NULL) { 453 if (encoding == NULL) {
450 printf("Encoding not found: %s\n", name); 454 printf("Encoding not found: %s\n", name);
451 } 455 }
452 #endif 456 #endif
453 return encoding; 457 return encoding;
454 } 458 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfFont.h ('k') | experimental/PdfViewer/SkPdfGraphicsState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698