OLD | NEW |
(Empty) | |
| 1 #ifndef __DEFINED__SkPdfType0FontDictionary |
| 2 #define __DEFINED__SkPdfType0FontDictionary |
| 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 Type 0 font dictionary |
| 10 class SkPdfType0FontDictionary : public SkPdfFontDictionary { |
| 11 public: |
| 12 virtual SkPdfObjectType getType() const { return kType0FontDictionary_SkPdfObj
ectType;} |
| 13 virtual SkPdfObjectType getTypeEnd() const { return (SkPdfObjectType)(kType0Fo
ntDictionary_SkPdfObjectType + 1);} |
| 14 public: |
| 15 virtual SkPdfType0FontDictionary* asType0FontDictionary() {return this;} |
| 16 virtual const SkPdfType0FontDictionary* asType0FontDictionary() const {return
this;} |
| 17 |
| 18 private: |
| 19 virtual SkPdfCIDFontDictionary* asCIDFontDictionary() {return NULL;} |
| 20 virtual const SkPdfCIDFontDictionary* asCIDFontDictionary() 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 SkPdfType0FontDictionary(const PdfMemDocument* podofoDoc = NULL, const PdfObje
ct* podofoObj = NULL) : SkPdfFontDictionary(podofoDoc, podofoObj) {} |
| 38 |
| 39 SkPdfType0FontDictionary(const SkPdfType0FontDictionary& from) : SkPdfFontDict
ionary(from.fPodofoDoc, from.fPodofoObj) {} |
| 40 |
| 41 virtual bool valid() const {return true;} |
| 42 |
| 43 SkPdfType0FontDictionary& operator=(const SkPdfType0FontDictionary& from) {thi
s->fPodofoDoc = from.fPodofoDoc; this->fPodofoObj = from.fPodofoObj; return *thi
s;} |
| 44 |
| 45 /** (Required) The type of PDF object that this dictionary describes; must be |
| 46 * Font for a font 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 font; must be Type0 for a Type 0 font. |
| 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 font. In principle, this is an arbitra
ry |
| 73 * name, since there is no font program associated directly with a Type 0 font |
| 74 * dictionary. The conventions described here ensure maximum compatibility |
| 75 * with existing Acrobat products. |
| 76 * If the descendant is a Type 0 CIDFont, this name should be the concatenation |
| 77 * of the CIDFont's BaseFont name, a hyphen, and the CMap name given in the |
| 78 * Encoding entry (or the CMapName entry in the CMap program itself). If the |
| 79 * descendant is a Type 2 CIDFont, this name should be the same as the |
| 80 * CIDFont's BaseFont name. |
| 81 **/ |
| 82 bool has_BaseFont() const { |
| 83 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BaseF
ont", "", NULL)); |
| 84 } |
| 85 |
| 86 std::string BaseFont() const { |
| 87 std::string ret; |
| 88 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BaseFont",
"", &ret)) return ret; |
| 89 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 90 return ""; |
| 91 } |
| 92 |
| 93 /** (Required) The name of a predefined CMap, or a stream containing a CMap |
| 94 * program, that maps character codes to font numbers and CIDs. If the descen- |
| 95 * dant is a Type 2 CIDFont whose associated TrueType font program is not em- |
| 96 * bedded in the PDF file, the Encoding entry must be a predefined CMap name |
| 97 * (see "Glyph Selection in CIDFonts" on page 339). |
| 98 **/ |
| 99 bool has_Encoding() const { |
| 100 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encod
ing", "", NULL)); |
| 101 } |
| 102 |
| 103 bool isEncodingAName() const { |
| 104 SkPdfObject* ret = NULL; |
| 105 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding
", "", &ret)) return false; |
| 106 return ret->podofo()->GetDataType() == ePdfDataType_Name; |
| 107 } |
| 108 |
| 109 std::string getEncodingAsName() const { |
| 110 std::string ret = ""; |
| 111 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding",
"", &ret)) return ret; |
| 112 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 113 return ""; |
| 114 } |
| 115 |
| 116 bool isEncodingAStream() const { |
| 117 SkPdfObject* ret = NULL; |
| 118 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding
", "", &ret)) return false; |
| 119 return ret->podofo()->HasStream(); |
| 120 } |
| 121 |
| 122 SkPdfStream* getEncodingAsStream() const { |
| 123 SkPdfStream* ret = NULL; |
| 124 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Encoding"
, "", &ret)) return ret; |
| 125 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 126 return NULL; |
| 127 } |
| 128 |
| 129 /** (Required) An array specifying one or more fonts or CIDFonts that are |
| 130 * descendants of this composite font. This array is indexed by the font number |
| 131 * that is obtained by mapping a character code through the CMap specified in |
| 132 * the Encoding entry. |
| 133 * Note: In all PDF versions up to and including PDF 1.4, DescendantFonts must |
| 134 * be a one-element array containing a CIDFont dictionary. |
| 135 **/ |
| 136 bool has_DescendantFonts() const { |
| 137 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Desce
ndantFonts", "", NULL)); |
| 138 } |
| 139 |
| 140 SkPdfArray* DescendantFonts() const { |
| 141 SkPdfArray* ret; |
| 142 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Descendant
Fonts", "", &ret)) return ret; |
| 143 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 144 return NULL; |
| 145 } |
| 146 |
| 147 /** (Optional) A stream containing a CMap file that maps character codes to |
| 148 * Unicode values (see Section 5.9, "ToUnicode CMaps"). |
| 149 **/ |
| 150 bool has_ToUnicode() const { |
| 151 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ToUni
code", "", NULL)); |
| 152 } |
| 153 |
| 154 SkPdfStream* ToUnicode() const { |
| 155 SkPdfStream* ret; |
| 156 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ToUnicode
", "", &ret)) return ret; |
| 157 // TODO(edisonn): warn about missing required field, assert for known good p
dfs |
| 158 return NULL; |
| 159 } |
| 160 |
| 161 }; |
| 162 |
| 163 #endif // __DEFINED__SkPdfType0FontDictionary |
OLD | NEW |