OLD | NEW |
(Empty) | |
| 1 #ifndef __DEFINED__SkPdfCIDFontDictionary |
| 2 #define __DEFINED__SkPdfCIDFontDictionary |
| 3 |
| 4 #include "SkPdfUtils.h" |
| 5 #include "SkPdfEnums_autogen.h" |
| 6 #include "SkPdfArray_autogen.h" |
| 7 #include "SkPdfFontDictionary_autogen.h" |
| 8 |
| 9 // Entries in a CIDFont dictionary |
| 10 class SkPdfCIDFontDictionary : public SkPdfFontDictionary { |
| 11 public: |
| 12 virtual SkPdfObjectType getType() const { return kCIDFontDictionary_SkPdfObjec
tType;} |
| 13 virtual SkPdfObjectType getTypeEnd() const { return (SkPdfObjectType)(kCIDFont
Dictionary_SkPdfObjectType + 1);} |
| 14 public: |
| 15 virtual SkPdfCIDFontDictionary* asCIDFontDictionary() {return this;} |
| 16 virtual const SkPdfCIDFontDictionary* asCIDFontDictionary() const {return this
;} |
| 17 |
| 18 private: |
| 19 virtual SkPdfType0FontDictionary* asType0FontDictionary() {return NULL;} |
| 20 virtual const SkPdfType0FontDictionary* asType0FontDictionary() const {return
NULL;} |
| 21 |
| 22 virtual SkPdfType1FontDictionary* asType1FontDictionary() {return NULL;} |
| 23 virtual const SkPdfType1FontDictionary* asType1FontDictionary() const {return
NULL;} |
| 24 |
| 25 virtual SkPdfMultiMasterFontDictionary* asMultiMasterFontDictionary() {return
NULL;} |
| 26 virtual const SkPdfMultiMasterFontDictionary* asMultiMasterFontDictionary() co
nst {return NULL;} |
| 27 |
| 28 virtual SkPdfTrueTypeFontDictionary* asTrueTypeFontDictionary() {return NULL;} |
| 29 virtual const SkPdfTrueTypeFontDictionary* asTrueTypeFontDictionary() const {r
eturn NULL;} |
| 30 |
| 31 virtual SkPdfType3FontDictionary* asType3FontDictionary() {return NULL;} |
| 32 virtual const SkPdfType3FontDictionary* asType3FontDictionary() const {return
NULL;} |
| 33 |
| 34 public: |
| 35 private: |
| 36 public: |
| 37 SkPdfCIDFontDictionary(const PdfMemDocument* podofoDoc = NULL, const PdfObject
* podofoObj = NULL) : SkPdfFontDictionary(podofoDoc, podofoObj) {} |
| 38 |
| 39 SkPdfCIDFontDictionary(const SkPdfCIDFontDictionary& from) : SkPdfFontDictiona
ry(from.fPodofoDoc, from.fPodofoObj) {} |
| 40 |
| 41 virtual bool valid() const {return true;} |
| 42 |
| 43 SkPdfCIDFontDictionary& operator=(const SkPdfCIDFontDictionary& from) {this->f
PodofoDoc = from.fPodofoDoc; this->fPodofoObj = from.fPodofoObj; return *this;} |
| 44 |
| 45 /** (Required) The type of PDF object that this dictionary describes; must be |
| 46 * Font for a CIDFont dictionary. |
| 47 **/ |
| 48 bool has_Type() const { |
| 49 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Type"
, "", NULL)); |
| 50 } |
| 51 |
| 52 std::string Type() const { |
| 53 std::string ret; |
| 54 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Type", "",
&ret)) return ret; |
| 55 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 56 return ""; |
| 57 } |
| 58 |
| 59 /** (Required) The type of CIDFont; CIDFontType0 or CIDFontType2. |
| 60 **/ |
| 61 bool has_Subtype() const { |
| 62 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subty
pe", "", NULL)); |
| 63 } |
| 64 |
| 65 std::string Subtype() const { |
| 66 std::string ret; |
| 67 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subtype", "
", &ret)) return ret; |
| 68 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 69 return ""; |
| 70 } |
| 71 |
| 72 /** (Required) The PostScript name of the CIDFont. For Type 0 CIDFonts, this |
| 73 * is usually the value of the CIDFontName entry in the CIDFont program. For |
| 74 * Type 2 CIDFonts, it is derived the same way as for a simple TrueType font; |
| 75 * see Section 5.5.2, "TrueType Fonts." In either case, the name can have a sub
- |
| 76 * set prefix if appropriate; see Section 5.5.3, "Font Subsets." |
| 77 **/ |
| 78 bool has_BaseFont() const { |
| 79 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BaseF
ont", "", NULL)); |
| 80 } |
| 81 |
| 82 std::string BaseFont() const { |
| 83 std::string ret; |
| 84 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BaseFont",
"", &ret)) return ret; |
| 85 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 86 return ""; |
| 87 } |
| 88 |
| 89 /** (Required) A dictionary containing entries that define the character collec- |
| 90 * tion of the CIDFont. See Table 5.12 on page 337. |
| 91 **/ |
| 92 bool has_CIDSystemInfo() const { |
| 93 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDSy
stemInfo", "", NULL)); |
| 94 } |
| 95 |
| 96 SkPdfDictionary* CIDSystemInfo() const { |
| 97 SkPdfDictionary* ret; |
| 98 if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDSy
stemInfo", "", &ret)) return ret; |
| 99 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 100 return NULL; |
| 101 } |
| 102 |
| 103 /** (Required; must be an indirect reference) A font descriptor describing the |
| 104 * CIDFont's default metrics other than its glyph widths (see Section 5.7, |
| 105 * "Font Descriptors"). |
| 106 **/ |
| 107 bool has_FontDescriptor() const { |
| 108 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontD
escriptor", "", NULL)); |
| 109 } |
| 110 |
| 111 SkPdfDictionary* FontDescriptor() const { |
| 112 SkPdfDictionary* ret; |
| 113 if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontD
escriptor", "", &ret)) return ret; |
| 114 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 115 return NULL; |
| 116 } |
| 117 |
| 118 /** (Optional) The default width for glyphs in the CIDFont (see "Glyph Met- |
| 119 * rics in CIDFonts" on page 340). Default value: 1000. |
| 120 **/ |
| 121 bool has_DW() const { |
| 122 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "DW",
"", NULL)); |
| 123 } |
| 124 |
| 125 long DW() const { |
| 126 long ret; |
| 127 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "DW", "", &r
et)) return ret; |
| 128 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 129 return 0; |
| 130 } |
| 131 |
| 132 /** (Optional) A description of the widths for the glyphs in the CIDFont. The |
| 133 * array's elements have a variable format that can specify individual widths |
| 134 * for consecutive CIDs or one width for a range of CIDs (see "Glyph Metrics |
| 135 * in CIDFonts" on page 340). Default value: none (the DW value is used for |
| 136 * all glyphs). |
| 137 **/ |
| 138 bool has_W() const { |
| 139 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "W", "
", NULL)); |
| 140 } |
| 141 |
| 142 SkPdfArray* W() const { |
| 143 SkPdfArray* ret; |
| 144 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "W", "", &r
et)) return ret; |
| 145 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 146 return NULL; |
| 147 } |
| 148 |
| 149 /** (Optional; applies only to CIDFonts used for vertical writing) An array of t
wo |
| 150 * numbers specifying the default metrics for vertical writing (see "Glyph |
| 151 * Metrics in CIDFonts" on page 340). Default value: [880 -1000]. |
| 152 **/ |
| 153 bool has_DW2() const { |
| 154 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "DW2",
"", NULL)); |
| 155 } |
| 156 |
| 157 SkPdfArray* DW2() const { |
| 158 SkPdfArray* ret; |
| 159 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "DW2", "",
&ret)) return ret; |
| 160 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 161 return NULL; |
| 162 } |
| 163 |
| 164 /** (Optional; applies only to CIDFonts used for vertical writing) A description
of |
| 165 * the metrics for vertical writing for the glyphs in the CIDFont (see "Glyph |
| 166 * Metrics in CIDFonts" on page 340). Default value: none (the DW2 value is |
| 167 * used for all glyphs). |
| 168 **/ |
| 169 bool has_W2() const { |
| 170 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "W2",
"", NULL)); |
| 171 } |
| 172 |
| 173 SkPdfArray* W2() const { |
| 174 SkPdfArray* ret; |
| 175 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "W2", "", &
ret)) return ret; |
| 176 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 177 return NULL; |
| 178 } |
| 179 |
| 180 /** (Optional; Type 2 CIDFonts only) A specification of the mapping from CIDs |
| 181 * to glyph indices. If the value is a stream, the bytes in the stream contain
the |
| 182 * mapping from CIDs to glyph indices: the glyph index for a particular CID |
| 183 * value c is a 2-byte value stored in bytes 2 x c and 2 x c + 1, where the fir
st |
| 184 * byte is the high-order byte. If the value of CIDToGIDMap is a name, it must |
| 185 * be Identity, indicating that the mapping between CIDs and glyph indices is |
| 186 * the identity mapping. Default value: Identity. |
| 187 * This entry may appear only in a Type 2 CIDFont whose associated True- |
| 188 * Type font program is embedded in the PDF file (see the next section). |
| 189 **/ |
| 190 bool has_CIDToGIDMap() const { |
| 191 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDTo
GIDMap", "", NULL)); |
| 192 } |
| 193 |
| 194 bool isCIDToGIDMapAStream() const { |
| 195 SkPdfObject* ret = NULL; |
| 196 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDToGID
Map", "", &ret)) return false; |
| 197 return ret->podofo()->HasStream(); |
| 198 } |
| 199 |
| 200 SkPdfStream* getCIDToGIDMapAsStream() const { |
| 201 SkPdfStream* ret = NULL; |
| 202 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDToGIDM
ap", "", &ret)) return ret; |
| 203 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 204 return NULL; |
| 205 } |
| 206 |
| 207 bool isCIDToGIDMapAName() const { |
| 208 SkPdfObject* ret = NULL; |
| 209 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDToGID
Map", "", &ret)) return false; |
| 210 return ret->podofo()->GetDataType() == ePdfDataType_Name; |
| 211 } |
| 212 |
| 213 std::string getCIDToGIDMapAsName() const { |
| 214 std::string ret = ""; |
| 215 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDToGIDMap
", "", &ret)) return ret; |
| 216 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 217 return ""; |
| 218 } |
| 219 |
| 220 }; |
| 221 |
| 222 #endif // __DEFINED__SkPdfCIDFontDictionary |
OLD | NEW |