edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 1 | #ifndef __DEFINED__SkPdfCIDFontDictionary |
| 2 | #define __DEFINED__SkPdfCIDFontDictionary |
| 3 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 4 | #include "SkPdfUtils.h" |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 5 | #include "SkPdfEnums_autogen.h" |
| 6 | #include "SkPdfArray_autogen.h" |
| 7 | #include "SkPdfFontDictionary_autogen.h" |
| 8 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 9 | // Entries in a CIDFont dictionary |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 10 | class SkPdfCIDFontDictionary : public SkPdfFontDictionary { |
| 11 | public: |
edisonn@google.com | 59543d3 | 2013-06-18 22:00:40 +0000 | [diff] [blame] | 12 | virtual SkPdfObjectType getType() const { return kCIDFontDictionary_SkPdfObjectType;} |
| 13 | virtual SkPdfObjectType getTypeEnd() const { return (SkPdfObjectType)(kCIDFontDictionary_SkPdfObjectType + 1);} |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 14 | public: |
| 15 | virtual SkPdfCIDFontDictionary* asCIDFontDictionary() {return this;} |
| 16 | virtual const SkPdfCIDFontDictionary* asCIDFontDictionary() const {return this;} |
| 17 | |
| 18 | private: |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 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() const {return NULL;} |
| 27 | |
edisonn@google.com | ff27844 | 2013-06-21 21:03:15 +0000 | [diff] [blame] | 28 | virtual SkPdfTrueTypeFontDictionary* asTrueTypeFontDictionary() {return NULL;} |
| 29 | virtual const SkPdfTrueTypeFontDictionary* asTrueTypeFontDictionary() const {return NULL;} |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 30 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 31 | virtual SkPdfType3FontDictionary* asType3FontDictionary() {return NULL;} |
| 32 | virtual const SkPdfType3FontDictionary* asType3FontDictionary() const {return NULL;} |
| 33 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 34 | public: |
| 35 | private: |
| 36 | public: |
| 37 | SkPdfCIDFontDictionary(const PdfMemDocument* podofoDoc = NULL, const PdfObject* podofoObj = NULL) : SkPdfFontDictionary(podofoDoc, podofoObj) {} |
| 38 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 39 | SkPdfCIDFontDictionary(const SkPdfCIDFontDictionary& from) : SkPdfFontDictionary(from.fPodofoDoc, from.fPodofoObj) {} |
| 40 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 41 | virtual bool valid() const {return true;} |
| 42 | |
| 43 | SkPdfCIDFontDictionary& operator=(const SkPdfCIDFontDictionary& from) {this->fPodofoDoc = from.fPodofoDoc; this->fPodofoObj = from.fPodofoObj; return *this;} |
| 44 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 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 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 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 pdfs |
| 56 | return ""; |
| 57 | } |
| 58 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 59 | /** (Required) The type of CIDFont; CIDFontType0 or CIDFontType2. |
| 60 | **/ |
| 61 | bool has_Subtype() const { |
| 62 | return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subtype", "", NULL)); |
| 63 | } |
| 64 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 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 pdfs |
| 69 | return ""; |
| 70 | } |
| 71 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 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(), "BaseFont", "", NULL)); |
| 80 | } |
| 81 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 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 pdfs |
| 86 | return ""; |
| 87 | } |
| 88 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 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(), "CIDSystemInfo", "", NULL)); |
| 94 | } |
| 95 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 96 | SkPdfDictionary* CIDSystemInfo() const { |
| 97 | SkPdfDictionary* ret; |
| 98 | if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDSystemInfo", "", &ret)) return ret; |
| 99 | // TODO(edisonn): warn about missing required field, assert for known good pdfs |
| 100 | return NULL; |
| 101 | } |
| 102 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 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(), "FontDescriptor", "", NULL)); |
| 109 | } |
| 110 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 111 | SkPdfDictionary* FontDescriptor() const { |
| 112 | SkPdfDictionary* ret; |
| 113 | if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "FontDescriptor", "", &ret)) return ret; |
| 114 | // TODO(edisonn): warn about missing required field, assert for known good pdfs |
| 115 | return NULL; |
| 116 | } |
| 117 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 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 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 125 | long DW() const { |
| 126 | long ret; |
| 127 | if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "DW", "", &ret)) return ret; |
| 128 | // TODO(edisonn): warn about missing required field, assert for known good pdfs |
| 129 | return 0; |
| 130 | } |
| 131 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 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 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 142 | SkPdfArray* W() const { |
| 143 | SkPdfArray* ret; |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 144 | if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "W", "", &ret)) return ret; |
| 145 | // TODO(edisonn): warn about missing required field, assert for known good pdfs |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 146 | return NULL; |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 147 | } |
| 148 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 149 | /** (Optional; applies only to CIDFonts used for vertical writing) An array of two |
| 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 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 157 | SkPdfArray* DW2() const { |
| 158 | SkPdfArray* ret; |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 159 | if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "DW2", "", &ret)) return ret; |
| 160 | // TODO(edisonn): warn about missing required field, assert for known good pdfs |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 161 | return NULL; |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 162 | } |
| 163 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 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 | |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 173 | SkPdfArray* W2() const { |
| 174 | SkPdfArray* ret; |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 175 | if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "W2", "", &ret)) return ret; |
| 176 | // TODO(edisonn): warn about missing required field, assert for known good pdfs |
edisonn@google.com | b857a0c | 2013-06-25 20:45:40 +0000 | [diff] [blame^] | 177 | return NULL; |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 178 | } |
| 179 | |
edisonn@google.com | afe5e9e | 2013-06-19 17:42:17 +0000 | [diff] [blame] | 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 first |
| 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(), "CIDToGIDMap", "", NULL)); |
| 192 | } |
| 193 | |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 194 | bool isCIDToGIDMapAStream() const { |
| 195 | SkPdfObject* ret = NULL; |
| 196 | if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDToGIDMap", "", &ret)) return false; |
| 197 | return ret->podofo()->HasStream(); |
| 198 | } |
| 199 | |
edisonn@google.com | ff27844 | 2013-06-21 21:03:15 +0000 | [diff] [blame] | 200 | SkPdfStream* getCIDToGIDMapAsStream() const { |
| 201 | SkPdfStream* ret = NULL; |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 202 | if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDToGIDMap", "", &ret)) return ret; |
| 203 | // TODO(edisonn): warn about missing required field, assert for known good pdfs |
edisonn@google.com | ff27844 | 2013-06-21 21:03:15 +0000 | [diff] [blame] | 204 | return NULL; |
edisonn@google.com | 2924762 | 2013-06-18 16:28:29 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | bool isCIDToGIDMapAName() const { |
| 208 | SkPdfObject* ret = NULL; |
| 209 | if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "CIDToGIDMap", "", &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 pdfs |
| 217 | return ""; |
| 218 | } |
| 219 | |
| 220 | }; |
| 221 | |
| 222 | #endif // __DEFINED__SkPdfCIDFontDictionary |