1 /* 2 * Copyright 2013 Google Inc. 3 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "SkPdfType1FontDictionary_autogen.h" 9 #include "SkPdfNativeDoc.h" 10 11 SkString SkPdfType1FontDictionary::Type(SkPdfNativeDoc* doc) { 12 SkPdfNativeObject* ret = get("Type", ""); 13 if (doc) {ret = doc->resolveReference(ret);} 14 if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2(); 15 // TODO(edisonn): warn about missing required field, assert for known good pdfs 16 return SkString(); 17 } 18 19 bool SkPdfType1FontDictionary::has_Type() const { 20 return get("Type", "") != NULL; 21 } 22 23 SkString SkPdfType1FontDictionary::Subtype(SkPdfNativeDoc* doc) { 24 SkPdfNativeObject* ret = get("Subtype", ""); 25 if (doc) {ret = doc->resolveReference(ret);} 26 if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2(); 27 // TODO(edisonn): warn about missing required field, assert for known good pdfs 28 return SkString(); 29 } 30 31 bool SkPdfType1FontDictionary::has_Subtype() const { 32 return get("Subtype", "") != NULL; 33 } 34 35 SkString SkPdfType1FontDictionary::Name(SkPdfNativeDoc* doc) { 36 SkPdfNativeObject* ret = get("Name", ""); 37 if (doc) {ret = doc->resolveReference(ret);} 38 if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2(); 39 // TODO(edisonn): warn about missing default value for optional fields 40 return SkString(); 41 } 42 43 bool SkPdfType1FontDictionary::has_Name() const { 44 return get("Name", "") != NULL; 45 } 46 47 SkString SkPdfType1FontDictionary::BaseFont(SkPdfNativeDoc* doc) { 48 SkPdfNativeObject* ret = get("BaseFont", ""); 49 if (doc) {ret = doc->resolveReference(ret);} 50 if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2(); 51 // TODO(edisonn): warn about missing required field, assert for known good pdfs 52 return SkString(); 53 } 54 55 bool SkPdfType1FontDictionary::has_BaseFont() const { 56 return get("BaseFont", "") != NULL; 57 } 58 59 int64_t SkPdfType1FontDictionary::FirstChar(SkPdfNativeDoc* doc) { 60 SkPdfNativeObject* ret = get("FirstChar", ""); 61 if (doc) {ret = doc->resolveReference(ret);} 62 if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue(); 63 // TODO(edisonn): warn about missing default value for optional fields 64 return 0; 65 } 66 67 bool SkPdfType1FontDictionary::has_FirstChar() const { 68 return get("FirstChar", "") != NULL; 69 } 70 71 int64_t SkPdfType1FontDictionary::LastChar(SkPdfNativeDoc* doc) { 72 SkPdfNativeObject* ret = get("LastChar", ""); 73 if (doc) {ret = doc->resolveReference(ret);} 74 if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue(); 75 // TODO(edisonn): warn about missing default value for optional fields 76 return 0; 77 } 78 79 bool SkPdfType1FontDictionary::has_LastChar() const { 80 return get("LastChar", "") != NULL; 81 } 82 83 SkPdfArray* SkPdfType1FontDictionary::Widths(SkPdfNativeDoc* doc) { 84 SkPdfNativeObject* ret = get("Widths", ""); 85 if (doc) {ret = doc->resolveReference(ret);} 86 if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret; 87 // TODO(edisonn): warn about missing default value for optional fields 88 return NULL; 89 } 90 91 bool SkPdfType1FontDictionary::has_Widths() const { 92 return get("Widths", "") != NULL; 93 } 94 95 SkPdfFontDescriptorDictionary* SkPdfType1FontDictionary::FontDescriptor(SkPdfNativeDoc* doc) { 96 SkPdfNativeObject* ret = get("FontDescriptor", ""); 97 if (doc) {ret = doc->resolveReference(ret);} 98 if ((ret != NULL && ret->isDictionary() && ((SkPdfFontDescriptorDictionary*)ret)->valid()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfFontDescriptorDictionary*)ret; 99 // TODO(edisonn): warn about missing default value for optional fields 100 return NULL; 101 } 102 103 bool SkPdfType1FontDictionary::has_FontDescriptor() const { 104 return get("FontDescriptor", "") != NULL; 105 } 106 107 bool SkPdfType1FontDictionary::isEncodingAName(SkPdfNativeDoc* doc) { 108 SkPdfNativeObject* ret = get("Encoding", ""); 109 if (doc) {ret = doc->resolveReference(ret);} 110 return ret != NULL && ret->isName(); 111 } 112 113 SkString SkPdfType1FontDictionary::getEncodingAsName(SkPdfNativeDoc* doc) { 114 SkPdfNativeObject* ret = get("Encoding", ""); 115 if (doc) {ret = doc->resolveReference(ret);} 116 if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2(); 117 // TODO(edisonn): warn about missing default value for optional fields 118 return SkString(); 119 } 120 121 bool SkPdfType1FontDictionary::isEncodingADictionary(SkPdfNativeDoc* doc) { 122 SkPdfNativeObject* ret = get("Encoding", ""); 123 if (doc) {ret = doc->resolveReference(ret);} 124 return ret != NULL && ret->isDictionary(); 125 } 126 127 SkPdfDictionary* SkPdfType1FontDictionary::getEncodingAsDictionary(SkPdfNativeDoc* doc) { 128 SkPdfNativeObject* ret = get("Encoding", ""); 129 if (doc) {ret = doc->resolveReference(ret);} 130 if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret; 131 // TODO(edisonn): warn about missing default value for optional fields 132 return NULL; 133 } 134 135 bool SkPdfType1FontDictionary::has_Encoding() const { 136 return get("Encoding", "") != NULL; 137 } 138 139 SkPdfStream* SkPdfType1FontDictionary::ToUnicode(SkPdfNativeDoc* doc) { 140 SkPdfNativeObject* ret = get("ToUnicode", ""); 141 if (doc) {ret = doc->resolveReference(ret);} 142 if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream(); 143 // TODO(edisonn): warn about missing default value for optional fields 144 return NULL; 145 } 146 147 bool SkPdfType1FontDictionary::has_ToUnicode() const { 148 return get("ToUnicode", "") != NULL; 149 } 150