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