OLD | NEW |
(Empty) | |
| 1 #ifndef __DEFINED__SkPdfType3FontDictionary |
| 2 #define __DEFINED__SkPdfType3FontDictionary |
| 3 |
| 4 #include "SkPdfUtils.h" |
| 5 #include "SkPdfEnums_autogen.h" |
| 6 #include "SkPdfArray_autogen.h" |
| 7 #include "SkPdfType1FontDictionary_autogen.h" |
| 8 |
| 9 // Entries in a Type 3 font dictionary |
| 10 class SkPdfType3FontDictionary : public SkPdfType1FontDictionary { |
| 11 public: |
| 12 virtual SkPdfObjectType getType() const { return kType3FontDictionary_SkPdfObj
ectType;} |
| 13 virtual SkPdfObjectType getTypeEnd() const { return (SkPdfObjectType)(kType3Fo
ntDictionary_SkPdfObjectType + 1);} |
| 14 public: |
| 15 virtual SkPdfType3FontDictionary* asType3FontDictionary() {return this;} |
| 16 virtual const SkPdfType3FontDictionary* asType3FontDictionary() const {return
this;} |
| 17 |
| 18 private: |
| 19 virtual SkPdfMultiMasterFontDictionary* asMultiMasterFontDictionary() {return
NULL;} |
| 20 virtual const SkPdfMultiMasterFontDictionary* asMultiMasterFontDictionary() co
nst {return NULL;} |
| 21 |
| 22 virtual SkPdfTrueTypeFontDictionary* asTrueTypeFontDictionary() {return NULL;} |
| 23 virtual const SkPdfTrueTypeFontDictionary* asTrueTypeFontDictionary() const {r
eturn NULL;} |
| 24 |
| 25 public: |
| 26 private: |
| 27 public: |
| 28 SkPdfType3FontDictionary(const PdfMemDocument* podofoDoc = NULL, const PdfObje
ct* podofoObj = NULL) : SkPdfType1FontDictionary(podofoDoc, podofoObj) {} |
| 29 |
| 30 SkPdfType3FontDictionary(const SkPdfType3FontDictionary& from) : SkPdfType1Fon
tDictionary(from.fPodofoDoc, from.fPodofoObj) {} |
| 31 |
| 32 virtual bool valid() const {return true;} |
| 33 |
| 34 SkPdfType3FontDictionary& operator=(const SkPdfType3FontDictionary& 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 Type3 for a Type 3 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) See Table 5.8 on page 317. |
| 64 **/ |
| 65 bool has_Name() const { |
| 66 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Name"
, "", NULL)); |
| 67 } |
| 68 |
| 69 std::string Name() const { |
| 70 std::string ret; |
| 71 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Name", "",
&ret)) return ret; |
| 72 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 73 return ""; |
| 74 } |
| 75 |
| 76 /** (Required) A rectangle (see Section 3.8.3, "Rectangles"), expressed in the |
| 77 * glyph coordinate system, specifying the font bounding box. This is the small
- |
| 78 * est rectangle enclosing the shape that would result if all of the glyphs of
the |
| 79 * font were placed with their origins coincident and then filled. |
| 80 * If all four elements of the rectangle are zero, no assumptions are made base
d |
| 81 * on the font bounding box. If any element is nonzero, it is essential that th
e |
| 82 * font bounding box be accurate; if any glyph's marks fall outside this bound- |
| 83 * ing box, incorrect behavior may result. |
| 84 **/ |
| 85 bool has_FontBBox() const { |
| 86 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontB
Box", "", NULL)); |
| 87 } |
| 88 |
| 89 SkRect* FontBBox() const { |
| 90 SkRect* ret; |
| 91 if (SkRectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontBBox"
, "", &ret)) return ret; |
| 92 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 93 return NULL; |
| 94 } |
| 95 |
| 96 /** (Required) An array of six numbers specifying the font matrix, mapping |
| 97 * glyph space to text space (see Section 5.1.3, "Glyph Positioning and |
| 98 * Metrics"). A common practice is to define glyphs in terms of a 1000-unit |
| 99 * glyph coordinate system, in which case the font matrix
is |
| 100 * [0.001 0 0 0.001 0 0]. |
| 101 **/ |
| 102 bool has_FontMatrix() const { |
| 103 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontM
atrix", "", NULL)); |
| 104 } |
| 105 |
| 106 SkMatrix* FontMatrix() const { |
| 107 SkMatrix* ret; |
| 108 if (SkMatrixFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontMat
rix", "", &ret)) return ret; |
| 109 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 110 return NULL; |
| 111 } |
| 112 |
| 113 /** (Required) A dictionary in which each key is a character name and the value |
| 114 * associated with that key is a content stream that constructs and paints the |
| 115 * glyph for that character. The stream must include as its first operator eith
er |
| 116 * d0 or d1. This is followed by operators describing one or more graphics |
| 117 * objects, which may include path, text, or image objects. See below for more |
| 118 * details about Type 3 glyph descriptions. |
| 119 **/ |
| 120 bool has_CharProcs() const { |
| 121 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CharP
rocs", "", NULL)); |
| 122 } |
| 123 |
| 124 SkPdfDictionary* CharProcs() const { |
| 125 SkPdfDictionary* ret; |
| 126 if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CharP
rocs", "", &ret)) return ret; |
| 127 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 128 return NULL; |
| 129 } |
| 130 |
| 131 /** (Required) An encoding dictionary whose Differences array specifies the |
| 132 * complete character encoding for this font (see Section 5.5.5, "Character |
| 133 * Encoding"; also see implementation note 46 in Appendix H). |
| 134 **/ |
| 135 bool has_Encoding() const { |
| 136 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encod
ing", "", NULL)); |
| 137 } |
| 138 |
| 139 bool isEncodingAName() const { |
| 140 SkPdfObject* ret = NULL; |
| 141 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding
", "", &ret)) return false; |
| 142 return ret->podofo()->GetDataType() == ePdfDataType_Name; |
| 143 } |
| 144 |
| 145 std::string getEncodingAsName() const { |
| 146 std::string ret = ""; |
| 147 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding",
"", &ret)) return ret; |
| 148 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 149 return ""; |
| 150 } |
| 151 |
| 152 bool isEncodingAEncodingdictionary() const { |
| 153 SkPdfObject* ret = NULL; |
| 154 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding
", "", &ret)) return false; |
| 155 return ret->podofo()->GetDataType() == ePdfDataType_Dictionary; |
| 156 } |
| 157 |
| 158 SkPdfEncodingDictionary* getEncodingAsEncodingdictionary() const { |
| 159 SkPdfEncodingDictionary* ret = NULL; |
| 160 if (DictionaryFromDictionary2(fPodofoDoc, fPodofoObj->GetDictionary(), "Enco
ding", "", &ret)) return ret; |
| 161 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 162 return NULL; |
| 163 } |
| 164 |
| 165 /** (Required) The first character code defined in the font's Widths array. |
| 166 **/ |
| 167 bool has_FirstChar() const { |
| 168 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "First
Char", "", NULL)); |
| 169 } |
| 170 |
| 171 long FirstChar() const { |
| 172 long ret; |
| 173 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FirstChar",
"", &ret)) return ret; |
| 174 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 175 return 0; |
| 176 } |
| 177 |
| 178 /** (Required) The last character code defined in the font's Widths array. |
| 179 **/ |
| 180 bool has_LastChar() const { |
| 181 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "LastC
har", "", NULL)); |
| 182 } |
| 183 |
| 184 long LastChar() const { |
| 185 long ret; |
| 186 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "LastChar",
"", &ret)) return ret; |
| 187 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 188 return 0; |
| 189 } |
| 190 |
| 191 /** (Required; indirect reference preferred) An array of (LastChar - FirstChar +
1) |
| 192 * widths, each element being the glyph width for the character whose code is |
| 193 * FirstChar plus the array index. For character codes outside the range FirstC
har |
| 194 * to LastChar, the width is 0. These widths are interpreted in glyph space as |
| 195 * specified by FontMatrix (unlike the widths of a Type 1 font, which are in |
| 196 * thousandths of a unit of text space). |
| 197 * Note: If FontMatrix specifies a rotation, only the horizontal component of t
he |
| 198 * transformed width is used. That is, the resulting displacement is always hor
izon- |
| 199 * tal in text space, as is the case for all simple fonts. |
| 200 **/ |
| 201 bool has_Widths() const { |
| 202 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Width
s", "", NULL)); |
| 203 } |
| 204 |
| 205 SkPdfArray* Widths() const { |
| 206 SkPdfArray* ret; |
| 207 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Widths", "
", &ret)) return ret; |
| 208 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 209 return NULL; |
| 210 } |
| 211 |
| 212 /** (Optional but strongly recommended; PDF 1.2) A list of the named resources, |
| 213 * such as fonts and images, required by the glyph descriptions in this font (s
ee |
| 214 * Section 3.7.2, "Resource Dictionaries"). If any glyph descriptions refer to |
| 215 * named resources but this dictionary is absent, the names are looked up in th
e |
| 216 * resource dictionary of the page on which the font is used. (See implementa- |
| 217 * tion note 47 in Appendix H.) |
| 218 **/ |
| 219 bool has_Resources() const { |
| 220 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Resou
rces", "", NULL)); |
| 221 } |
| 222 |
| 223 SkPdfDictionary* Resources() const { |
| 224 SkPdfDictionary* ret; |
| 225 if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Resou
rces", "", &ret)) return ret; |
| 226 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 227 return NULL; |
| 228 } |
| 229 |
| 230 /** (Optional; PDF 1.2) A stream containing a CMap file that maps character |
| 231 * codes to Unicode values (see Section 5.9, "ToUnicode CMaps"). |
| 232 **/ |
| 233 bool has_ToUnicode() const { |
| 234 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ToUni
code", "", NULL)); |
| 235 } |
| 236 |
| 237 SkPdfStream* ToUnicode() const { |
| 238 SkPdfStream* ret; |
| 239 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ToUnicode
", "", &ret)) return ret; |
| 240 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 241 return NULL; |
| 242 } |
| 243 |
| 244 }; |
| 245 |
| 246 #endif // __DEFINED__SkPdfType3FontDictionary |
OLD | NEW |