OLD | NEW |
| (Empty) |
1 #ifndef __DEFINED__SkPdfType1FontDictionary | |
2 #define __DEFINED__SkPdfType1FontDictionary | |
3 | |
4 #include "SkPdfEnums_autogen.h" | |
5 #include "SkPdfArray_autogen.h" | |
6 #include "SkPdfFontDictionary_autogen.h" | |
7 | |
8 // Entries in a Type 1 font dictionary | |
9 class SkPdfType1FontDictionary : public SkPdfFontDictionary { | |
10 public: | |
11 virtual SkPdfObjectType getType() const { return kType1FontDictionary_SkPdfObj
ectType;} | |
12 virtual SkPdfObjectType getTypeEnd() const { return kType1FontDictionary__End_
SkPdfObjectType;} | |
13 public: | |
14 virtual SkPdfType1FontDictionary* asType1FontDictionary() {return this;} | |
15 virtual const SkPdfType1FontDictionary* asType1FontDictionary() const {return
this;} | |
16 | |
17 private: | |
18 virtual SkPdfCIDFontDictionary* asCIDFontDictionary() {return NULL;} | |
19 virtual const SkPdfCIDFontDictionary* asCIDFontDictionary() const {return NULL
;} | |
20 | |
21 virtual SkPdfType0FontDictionary* asType0FontDictionary() {return NULL;} | |
22 virtual const SkPdfType0FontDictionary* asType0FontDictionary() const {return
NULL;} | |
23 | |
24 virtual SkPdfType3FontDictionary* asType3FontDictionary() {return NULL;} | |
25 virtual const SkPdfType3FontDictionary* asType3FontDictionary() const {return
NULL;} | |
26 | |
27 public: | |
28 private: | |
29 public: | |
30 SkPdfType1FontDictionary(const PdfMemDocument* podofoDoc = NULL, const PdfObje
ct* podofoObj = NULL) : SkPdfFontDictionary(podofoDoc, podofoObj) {} | |
31 | |
32 virtual bool valid() const {return true;} | |
33 | |
34 SkPdfType1FontDictionary& operator=(const SkPdfType1FontDictionary& from) {thi
s->fPodofoDoc = from.fPodofoDoc; this->fPodofoObj = from.fPodofoObj; return *thi
s;} | |
35 | |
36 /** (Required) The type of PDF object that this dictionary describes; must be | |
37 * Font for a font dictionary. | |
38 **/ | |
39 bool has_Type() const { | |
40 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Type"
, "", NULL)); | |
41 } | |
42 | |
43 std::string Type() const { | |
44 std::string ret; | |
45 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Type", "",
&ret)) return ret; | |
46 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
47 return ""; | |
48 } | |
49 | |
50 /** (Required) The type of font; must be Type1 for a Type 1 font. | |
51 **/ | |
52 bool has_Subtype() const { | |
53 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subty
pe", "", NULL)); | |
54 } | |
55 | |
56 std::string Subtype() const { | |
57 std::string ret; | |
58 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subtype", "
", &ret)) return ret; | |
59 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
60 return ""; | |
61 } | |
62 | |
63 /** (Required in PDF 1.0; optional otherwise) The name by which this font is ref
- | |
64 * erenced in the Font subdictionary of the current resource dictionary. | |
65 * Note: This entry is obsolescent and its use is no longer recommended. (See | |
66 * implementation note 42 in Appendix H.) | |
67 **/ | |
68 bool has_Name() const { | |
69 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Name"
, "", NULL)); | |
70 } | |
71 | |
72 std::string Name() const { | |
73 std::string ret; | |
74 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Name", "",
&ret)) return ret; | |
75 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
76 return ""; | |
77 } | |
78 | |
79 /** (Required) The PostScript name of the font. For Type 1 fonts, this is usuall
y | |
80 * the value of the FontName entry in the font program; for more information, | |
81 * see Section 5.2 of the PostScript Language Reference, Third Edition. The Pos
t- | |
82 * Script name of the font can be used to find the font's definition in the vie
wer | |
83 * application or its environment. It is also the name that will be used when | |
84 * printing to a PostScript output device. | |
85 **/ | |
86 bool has_BaseFont() const { | |
87 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BaseF
ont", "", NULL)); | |
88 } | |
89 | |
90 std::string BaseFont() const { | |
91 std::string ret; | |
92 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BaseFont",
"", &ret)) return ret; | |
93 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
94 return ""; | |
95 } | |
96 | |
97 /** (Required except for the standard 14 fonts) The first character code defined
in | |
98 * the font's Widths array. | |
99 **/ | |
100 bool has_FirstChar() const { | |
101 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "First
Char", "", NULL)); | |
102 } | |
103 | |
104 long FirstChar() const { | |
105 long ret; | |
106 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FirstChar",
"", &ret)) return ret; | |
107 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
108 return 0; | |
109 } | |
110 | |
111 /** (Required except for the standard 14 fonts) The last character code defined
in | |
112 * the font's Widths array. | |
113 **/ | |
114 bool has_LastChar() const { | |
115 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "LastC
har", "", NULL)); | |
116 } | |
117 | |
118 long LastChar() const { | |
119 long ret; | |
120 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "LastChar",
"", &ret)) return ret; | |
121 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
122 return 0; | |
123 } | |
124 | |
125 /** (Required except for the standard 14 fonts; indirect reference preferred) An
array | |
126 * of (LastChar - FirstChar + 1) widths, each element being the glyph width for | |
127 * the character whose code is FirstChar plus the array index. For character | |
128 * codes outside the range FirstChar to LastChar, the value of MissingWidth fro
m | |
129 * the FontDescriptor entry for this font is used. The glyph widths are measure
d | |
130 * in units in which 1000 units corresponds to 1 unit in text space. These widt
hs | |
131 * must be consistent with the actual widths given in the font program itself. | |
132 * (See implementation note 43 in Appendix H.) For more information on | |
133 * glyph widths and other glyph metrics, see Section 5.1.3, "Glyph Positioning | |
134 * and Metrics." | |
135 **/ | |
136 bool has_Widths() const { | |
137 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Width
s", "", NULL)); | |
138 } | |
139 | |
140 SkPdfArray Widths() const { | |
141 SkPdfArray ret; | |
142 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Widths", "
", &ret)) return ret; | |
143 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
144 return SkPdfArray(); | |
145 } | |
146 | |
147 /** (Required except for the standard 14 fonts; must be an indirect reference) A
font | |
148 * descriptor describing the font's metrics other than its glyph widths (see Se
c- | |
149 * tion 5.7, "Font Descriptors"). | |
150 * Note: For the standard 14 fonts, the entries FirstChar, LastChar, Widths,
and | |
151 * FontDescriptor must either all be present or all absent. Ordinarily, they
are ab- | |
152 * sent; specifying them enables a standard font to be overridden (see "Stan
dard | |
153 * Type 1 Fonts," below). | |
154 **/ | |
155 bool has_FontDescriptor() const { | |
156 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontD
escriptor", "", NULL)); | |
157 } | |
158 | |
159 SkPdfDictionary* FontDescriptor() const { | |
160 SkPdfDictionary* ret; | |
161 if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontD
escriptor", "", &ret)) return ret; | |
162 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
163 return NULL; | |
164 } | |
165 | |
166 /** (Optional) A specification of the font's character encoding, if different fr
om | |
167 * its built-in encoding. The value of Encoding may be either the name of a pre
- | |
168 * defined encoding (MacRomanEncoding, MacExpertEncoding, or WinAnsi- | |
169 * Encoding, as described in Appendix D) or an encoding dictionary that | |
170 * specifies differences from the font's built-in encoding or from a specified
pre- | |
171 * defined encoding (see Section 5.5.5, "Character Encoding"). | |
172 **/ | |
173 bool has_Encoding() const { | |
174 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encod
ing", "", NULL)); | |
175 } | |
176 | |
177 bool isEncodingAName() const { | |
178 SkPdfObject* ret = NULL; | |
179 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding
", "", &ret)) return false; | |
180 return ret->podofo()->GetDataType() == ePdfDataType_Name; | |
181 } | |
182 | |
183 std::string getEncodingAsName() const { | |
184 std::string ret = ""; | |
185 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding",
"", &ret)) return ret; | |
186 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
187 return ""; | |
188 } | |
189 | |
190 bool isEncodingADictionary() const { | |
191 SkPdfObject* ret = NULL; | |
192 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding
", "", &ret)) return false; | |
193 return ret->podofo()->GetDataType() == ePdfDataType_Dictionary; | |
194 } | |
195 | |
196 SkPdfDictionary* getEncodingAsDictionary() const { | |
197 SkPdfDictionary* ret = NULL; | |
198 if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encod
ing", "", &ret)) return ret; | |
199 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
200 return NULL; | |
201 } | |
202 | |
203 /** (Optional; PDF 1.2) A stream containing a CMap file that maps character | |
204 * codes to Unicode values (see Section 5.9, "ToUnicode CMaps"). | |
205 **/ | |
206 bool has_ToUnicode() const { | |
207 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ToUni
code", "", NULL)); | |
208 } | |
209 | |
210 SkPdfStream* ToUnicode() const { | |
211 SkPdfStream* ret; | |
212 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ToUnicode
", "", &ret)) return ret; | |
213 // TODO(edisonn): warn about missing required field, assert for known good p
dfs | |
214 return NULL; | |
215 } | |
216 | |
217 }; | |
218 | |
219 #endif // __DEFINED__SkPdfType1FontDictionary | |
OLD | NEW |