| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_ |
| 8 #define CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_ | 8 #define CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_ |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include <map> | 12 #include <map> |
| 13 | 13 |
| 14 #include "core/fxcrt/include/fx_basic.h" | 14 #include "core/fxcrt/include/fx_basic.h" |
| 15 #include "core/fxge/include/fx_font.h" | 15 #include "core/fxge/include/fx_font.h" |
| 16 #include "core/fxge/include/fx_freetype.h" | 16 #include "core/fxge/include/fx_freetype.h" |
| 17 | 17 |
| 18 class CFX_GlyphMap { | 18 class CFX_GlyphMap { |
| 19 public: | 19 public: |
| 20 CFX_GlyphMap(); | 20 CFX_GlyphMap(); |
| 21 ~CFX_GlyphMap(); | 21 ~CFX_GlyphMap(); |
| 22 |
| 22 void SetAt(int key, int value); | 23 void SetAt(int key, int value); |
| 23 FX_BOOL Lookup(int key, int& value); | 24 FX_BOOL Lookup(int key, int& value); |
| 24 | 25 |
| 25 protected: | 26 protected: |
| 26 CFX_BinaryBuf m_Buffer; | 27 CFX_BinaryBuf m_Buffer; |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 class CFX_CTTGSUBTable { | 30 class CFX_CTTGSUBTable { |
| 30 public: | 31 public: |
| 31 CFX_CTTGSUBTable(void) : m_bFeautureMapLoad(FALSE), loaded(false) {} | 32 CFX_CTTGSUBTable(); |
| 32 CFX_CTTGSUBTable(FT_Bytes gsub) : m_bFeautureMapLoad(FALSE), loaded(false) { | 33 explicit CFX_CTTGSUBTable(FT_Bytes gsub); |
| 33 LoadGSUBTable(gsub); | 34 virtual ~CFX_CTTGSUBTable(); |
| 34 } | 35 |
| 35 virtual ~CFX_CTTGSUBTable() {} | 36 bool IsOk(void) const; |
| 36 bool IsOk(void) const { return loaded; } | |
| 37 bool LoadGSUBTable(FT_Bytes gsub); | 37 bool LoadGSUBTable(FT_Bytes gsub); |
| 38 bool GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum); | 38 bool GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum); |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 struct tt_gsub_header { | 41 struct tt_gsub_header { |
| 42 uint32_t Version; | 42 uint32_t Version; |
| 43 uint16_t ScriptList; | 43 uint16_t ScriptList; |
| 44 uint16_t FeatureList; | 44 uint16_t FeatureList; |
| 45 uint16_t LookupList; | 45 uint16_t LookupList; |
| 46 }; | 46 }; |
| 47 struct TLangSys { | 47 struct TLangSys { |
| 48 uint16_t LookupOrder; | |
| 49 uint16_t ReqFeatureIndex; | |
| 50 uint16_t FeatureCount; | |
| 51 uint16_t* FeatureIndex; | |
| 52 TLangSys() | 48 TLangSys() |
| 53 : LookupOrder(0), | 49 : LookupOrder(0), |
| 54 ReqFeatureIndex(0), | 50 ReqFeatureIndex(0), |
| 55 FeatureCount(0), | 51 FeatureCount(0), |
| 56 FeatureIndex(nullptr) {} | 52 FeatureIndex(nullptr) {} |
| 57 ~TLangSys() { delete[] FeatureIndex; } | 53 ~TLangSys() { delete[] FeatureIndex; } |
| 58 | 54 |
| 55 uint16_t LookupOrder; |
| 56 uint16_t ReqFeatureIndex; |
| 57 uint16_t FeatureCount; |
| 58 uint16_t* FeatureIndex; |
| 59 |
| 59 private: | 60 private: |
| 60 TLangSys(const TLangSys&); | 61 TLangSys(const TLangSys&); |
| 61 TLangSys& operator=(const TLangSys&); | 62 TLangSys& operator=(const TLangSys&); |
| 62 }; | 63 }; |
| 63 struct TLangSysRecord { | 64 struct TLangSysRecord { |
| 65 TLangSysRecord() : LangSysTag(0) {} |
| 66 |
| 64 uint32_t LangSysTag; | 67 uint32_t LangSysTag; |
| 65 struct TLangSys LangSys; | 68 struct TLangSys LangSys; |
| 66 TLangSysRecord() : LangSysTag(0) {} | |
| 67 | 69 |
| 68 private: | 70 private: |
| 69 TLangSysRecord(const TLangSysRecord&); | 71 TLangSysRecord(const TLangSysRecord&); |
| 70 TLangSysRecord& operator=(const TLangSysRecord&); | 72 TLangSysRecord& operator=(const TLangSysRecord&); |
| 71 }; | 73 }; |
| 72 struct TScript { | 74 struct TScript { |
| 75 TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(nullptr) {} |
| 76 ~TScript() { delete[] LangSysRecord; } |
| 77 |
| 73 uint16_t DefaultLangSys; | 78 uint16_t DefaultLangSys; |
| 74 uint16_t LangSysCount; | 79 uint16_t LangSysCount; |
| 80 // TODO(weili): Replace with a smart pointer type, pdfium:518. |
| 75 struct TLangSysRecord* LangSysRecord; | 81 struct TLangSysRecord* LangSysRecord; |
| 76 TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(nullptr) {} | |
| 77 ~TScript() { delete[] LangSysRecord; } | |
| 78 | 82 |
| 79 private: | 83 private: |
| 80 TScript(const TScript&); | 84 TScript(const TScript&); |
| 81 TScript& operator=(const TScript&); | 85 TScript& operator=(const TScript&); |
| 82 }; | 86 }; |
| 83 struct TScriptRecord { | 87 struct TScriptRecord { |
| 88 TScriptRecord() : ScriptTag(0) {} |
| 89 |
| 84 uint32_t ScriptTag; | 90 uint32_t ScriptTag; |
| 85 struct TScript Script; | 91 struct TScript Script; |
| 86 TScriptRecord() : ScriptTag(0) {} | |
| 87 | 92 |
| 88 private: | 93 private: |
| 89 TScriptRecord(const TScriptRecord&); | 94 TScriptRecord(const TScriptRecord&); |
| 90 TScriptRecord& operator=(const TScriptRecord&); | 95 TScriptRecord& operator=(const TScriptRecord&); |
| 91 }; | 96 }; |
| 92 struct TScriptList { | 97 struct TScriptList { |
| 98 TScriptList() : ScriptCount(0), ScriptRecord(nullptr) {} |
| 99 ~TScriptList() { delete[] ScriptRecord; } |
| 100 |
| 93 uint16_t ScriptCount; | 101 uint16_t ScriptCount; |
| 94 struct TScriptRecord* ScriptRecord; | 102 struct TScriptRecord* ScriptRecord; |
| 95 TScriptList() : ScriptCount(0), ScriptRecord(nullptr) {} | |
| 96 ~TScriptList() { delete[] ScriptRecord; } | |
| 97 | 103 |
| 98 private: | 104 private: |
| 99 TScriptList(const TScriptList&); | 105 TScriptList(const TScriptList&); |
| 100 TScriptList& operator=(const TScriptList&); | 106 TScriptList& operator=(const TScriptList&); |
| 101 }; | 107 }; |
| 102 struct TFeature { | 108 struct TFeature { |
| 109 TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {} |
| 110 ~TFeature() { delete[] LookupListIndex; } |
| 111 |
| 103 uint16_t FeatureParams; | 112 uint16_t FeatureParams; |
| 104 int LookupCount; | 113 int LookupCount; |
| 105 uint16_t* LookupListIndex; | 114 uint16_t* LookupListIndex; |
| 106 TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {} | |
| 107 ~TFeature() { delete[] LookupListIndex; } | |
| 108 | 115 |
| 109 private: | 116 private: |
| 110 TFeature(const TFeature&); | 117 TFeature(const TFeature&); |
| 111 TFeature& operator=(const TFeature&); | 118 TFeature& operator=(const TFeature&); |
| 112 }; | 119 }; |
| 113 struct TFeatureRecord { | 120 struct TFeatureRecord { |
| 121 TFeatureRecord() : FeatureTag(0) {} |
| 122 |
| 114 uint32_t FeatureTag; | 123 uint32_t FeatureTag; |
| 115 struct TFeature Feature; | 124 struct TFeature Feature; |
| 116 TFeatureRecord() : FeatureTag(0) {} | |
| 117 | 125 |
| 118 private: | 126 private: |
| 119 TFeatureRecord(const TFeatureRecord&); | 127 TFeatureRecord(const TFeatureRecord&); |
| 120 TFeatureRecord& operator=(const TFeatureRecord&); | 128 TFeatureRecord& operator=(const TFeatureRecord&); |
| 121 }; | 129 }; |
| 122 struct TFeatureList { | 130 struct TFeatureList { |
| 131 TFeatureList() : FeatureCount(0), FeatureRecord(nullptr) {} |
| 132 ~TFeatureList() { delete[] FeatureRecord; } |
| 133 |
| 123 int FeatureCount; | 134 int FeatureCount; |
| 124 struct TFeatureRecord* FeatureRecord; | 135 struct TFeatureRecord* FeatureRecord; |
| 125 TFeatureList() : FeatureCount(0), FeatureRecord(nullptr) {} | |
| 126 ~TFeatureList() { delete[] FeatureRecord; } | |
| 127 | 136 |
| 128 private: | 137 private: |
| 129 TFeatureList(const TFeatureList&); | 138 TFeatureList(const TFeatureList&); |
| 130 TFeatureList& operator=(const TFeatureList&); | 139 TFeatureList& operator=(const TFeatureList&); |
| 131 }; | 140 }; |
| 132 enum TLookupFlag { | 141 enum TLookupFlag { |
| 133 LOOKUPFLAG_RightToLeft = 0x0001, | 142 LOOKUPFLAG_RightToLeft = 0x0001, |
| 134 LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002, | 143 LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002, |
| 135 LOOKUPFLAG_IgnoreLigatures = 0x0004, | 144 LOOKUPFLAG_IgnoreLigatures = 0x0004, |
| 136 LOOKUPFLAG_IgnoreMarks = 0x0008, | 145 LOOKUPFLAG_IgnoreMarks = 0x0008, |
| 137 LOOKUPFLAG_Reserved = 0x00F0, | 146 LOOKUPFLAG_Reserved = 0x00F0, |
| 138 LOOKUPFLAG_MarkAttachmentType = 0xFF00, | 147 LOOKUPFLAG_MarkAttachmentType = 0xFF00, |
| 139 }; | 148 }; |
| 140 struct TCoverageFormatBase { | 149 struct TCoverageFormatBase { |
| 150 TCoverageFormatBase() : CoverageFormat(0) {} |
| 151 virtual ~TCoverageFormatBase() {} |
| 152 |
| 141 uint16_t CoverageFormat; | 153 uint16_t CoverageFormat; |
| 142 CFX_GlyphMap m_glyphMap; | 154 CFX_GlyphMap m_glyphMap; |
| 143 TCoverageFormatBase() : CoverageFormat(0) {} | |
| 144 virtual ~TCoverageFormatBase() {} | |
| 145 | 155 |
| 146 private: | 156 private: |
| 147 TCoverageFormatBase(const TCoverageFormatBase&); | 157 TCoverageFormatBase(const TCoverageFormatBase&); |
| 148 TCoverageFormatBase& operator=(const TCoverageFormatBase&); | 158 TCoverageFormatBase& operator=(const TCoverageFormatBase&); |
| 149 }; | 159 }; |
| 150 struct TCoverageFormat1 : public TCoverageFormatBase { | 160 struct TCoverageFormat1 : public TCoverageFormatBase { |
| 161 TCoverageFormat1(); |
| 162 ~TCoverageFormat1() override; |
| 163 |
| 151 uint16_t GlyphCount; | 164 uint16_t GlyphCount; |
| 152 uint16_t* GlyphArray; | 165 uint16_t* GlyphArray; |
| 153 TCoverageFormat1() : GlyphCount(0), GlyphArray(nullptr) { | |
| 154 CoverageFormat = 1; | |
| 155 } | |
| 156 ~TCoverageFormat1() override { delete[] GlyphArray; } | |
| 157 | 166 |
| 158 private: | 167 private: |
| 159 TCoverageFormat1(const TCoverageFormat1&); | 168 TCoverageFormat1(const TCoverageFormat1&); |
| 160 TCoverageFormat1& operator=(const TCoverageFormat1&); | 169 TCoverageFormat1& operator=(const TCoverageFormat1&); |
| 161 }; | 170 }; |
| 162 struct TRangeRecord { | 171 struct TRangeRecord { |
| 172 TRangeRecord(); |
| 173 |
| 174 friend bool operator>(const TRangeRecord& r1, const TRangeRecord& r2) { |
| 175 return r1.Start > r2.Start; |
| 176 } |
| 177 |
| 163 uint16_t Start; | 178 uint16_t Start; |
| 164 uint16_t End; | 179 uint16_t End; |
| 165 uint16_t StartCoverageIndex; | 180 uint16_t StartCoverageIndex; |
| 166 TRangeRecord() : Start(0), End(0), StartCoverageIndex(0) {} | |
| 167 friend bool operator>(const TRangeRecord& r1, const TRangeRecord& r2) { | |
| 168 return r1.Start > r2.Start; | |
| 169 } | |
| 170 | 181 |
| 171 private: | 182 private: |
| 172 TRangeRecord(const TRangeRecord&); | 183 TRangeRecord(const TRangeRecord&); |
| 173 }; | 184 }; |
| 174 struct TCoverageFormat2 : public TCoverageFormatBase { | 185 struct TCoverageFormat2 : public TCoverageFormatBase { |
| 186 TCoverageFormat2(); |
| 187 ~TCoverageFormat2() override; |
| 188 |
| 175 uint16_t RangeCount; | 189 uint16_t RangeCount; |
| 176 struct TRangeRecord* RangeRecord; | 190 struct TRangeRecord* RangeRecord; |
| 177 TCoverageFormat2() : RangeCount(0), RangeRecord(nullptr) { | |
| 178 CoverageFormat = 2; | |
| 179 } | |
| 180 ~TCoverageFormat2() override { delete[] RangeRecord; } | |
| 181 | 191 |
| 182 private: | 192 private: |
| 183 TCoverageFormat2(const TCoverageFormat2&); | 193 TCoverageFormat2(const TCoverageFormat2&); |
| 184 TCoverageFormat2& operator=(const TCoverageFormat2&); | 194 TCoverageFormat2& operator=(const TCoverageFormat2&); |
| 185 }; | 195 }; |
| 186 struct TClassDefFormatBase { | 196 struct TClassDefFormatBase { |
| 187 uint16_t ClassFormat; | |
| 188 TClassDefFormatBase() : ClassFormat(0) {} | 197 TClassDefFormatBase() : ClassFormat(0) {} |
| 189 virtual ~TClassDefFormatBase() {} | 198 virtual ~TClassDefFormatBase() {} |
| 190 | 199 |
| 200 uint16_t ClassFormat; |
| 201 |
| 191 private: | 202 private: |
| 192 TClassDefFormatBase(const TClassDefFormatBase&); | 203 TClassDefFormatBase(const TClassDefFormatBase&); |
| 193 TClassDefFormatBase& operator=(const TClassDefFormatBase&); | 204 TClassDefFormatBase& operator=(const TClassDefFormatBase&); |
| 194 }; | 205 }; |
| 195 struct TClassDefFormat1 : public TClassDefFormatBase { | 206 struct TClassDefFormat1 : public TClassDefFormatBase { |
| 207 TClassDefFormat1(); |
| 208 ~TClassDefFormat1() override; |
| 209 |
| 196 uint16_t StartGlyph; | 210 uint16_t StartGlyph; |
| 197 uint16_t GlyphCount; | 211 uint16_t GlyphCount; |
| 198 uint16_t* ClassValueArray; | 212 uint16_t* ClassValueArray; |
| 199 TClassDefFormat1() | |
| 200 : StartGlyph(0), GlyphCount(0), ClassValueArray(nullptr) { | |
| 201 ClassFormat = 1; | |
| 202 } | |
| 203 ~TClassDefFormat1() override { delete[] ClassValueArray; } | |
| 204 | 213 |
| 205 private: | 214 private: |
| 206 TClassDefFormat1(const TClassDefFormat1&); | 215 TClassDefFormat1(const TClassDefFormat1&); |
| 207 TClassDefFormat1& operator=(const TClassDefFormat1&); | 216 TClassDefFormat1& operator=(const TClassDefFormat1&); |
| 208 }; | 217 }; |
| 209 struct TClassRangeRecord { | 218 struct TClassRangeRecord { |
| 219 TClassRangeRecord() : Start(0), End(0), Class(0) {} |
| 220 |
| 210 uint16_t Start; | 221 uint16_t Start; |
| 211 uint16_t End; | 222 uint16_t End; |
| 212 uint16_t Class; | 223 uint16_t Class; |
| 213 TClassRangeRecord() : Start(0), End(0), Class(0) {} | |
| 214 | 224 |
| 215 private: | 225 private: |
| 216 TClassRangeRecord(const TClassRangeRecord&); | 226 TClassRangeRecord(const TClassRangeRecord&); |
| 217 TClassRangeRecord& operator=(const TClassRangeRecord&); | 227 TClassRangeRecord& operator=(const TClassRangeRecord&); |
| 218 }; | 228 }; |
| 219 struct TClassDefFormat2 : public TClassDefFormatBase { | 229 struct TClassDefFormat2 : public TClassDefFormatBase { |
| 230 TClassDefFormat2(); |
| 231 ~TClassDefFormat2() override; |
| 232 |
| 220 uint16_t ClassRangeCount; | 233 uint16_t ClassRangeCount; |
| 221 struct TClassRangeRecord* ClassRangeRecord; | 234 struct TClassRangeRecord* ClassRangeRecord; |
| 222 TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(nullptr) { | |
| 223 ClassFormat = 2; | |
| 224 } | |
| 225 ~TClassDefFormat2() override { delete[] ClassRangeRecord; } | |
| 226 | 235 |
| 227 private: | 236 private: |
| 228 TClassDefFormat2(const TClassDefFormat2&); | 237 TClassDefFormat2(const TClassDefFormat2&); |
| 229 TClassDefFormat2& operator=(const TClassDefFormat2&); | 238 TClassDefFormat2& operator=(const TClassDefFormat2&); |
| 230 }; | 239 }; |
| 231 struct TDevice { | 240 struct TDevice { |
| 241 TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {} |
| 242 |
| 232 uint16_t StartSize; | 243 uint16_t StartSize; |
| 233 uint16_t EndSize; | 244 uint16_t EndSize; |
| 234 uint16_t DeltaFormat; | 245 uint16_t DeltaFormat; |
| 235 TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {} | |
| 236 | 246 |
| 237 private: | 247 private: |
| 238 TDevice(const TDevice&); | 248 TDevice(const TDevice&); |
| 239 TDevice& operator=(const TDevice&); | 249 TDevice& operator=(const TDevice&); |
| 240 }; | 250 }; |
| 241 struct TSubTableBase { | 251 struct TSubTableBase { |
| 242 uint16_t SubstFormat; | |
| 243 TSubTableBase() : SubstFormat(0) {} | 252 TSubTableBase() : SubstFormat(0) {} |
| 244 virtual ~TSubTableBase() {} | 253 virtual ~TSubTableBase() {} |
| 245 | 254 |
| 255 uint16_t SubstFormat; |
| 256 |
| 246 private: | 257 private: |
| 247 TSubTableBase(const TSubTableBase&); | 258 TSubTableBase(const TSubTableBase&); |
| 248 TSubTableBase& operator=(const TSubTableBase&); | 259 TSubTableBase& operator=(const TSubTableBase&); |
| 249 }; | 260 }; |
| 250 struct TSingleSubstFormat1 : public TSubTableBase { | 261 struct TSingleSubstFormat1 : public TSubTableBase { |
| 262 TSingleSubstFormat1(); |
| 263 ~TSingleSubstFormat1() override; |
| 264 |
| 251 TCoverageFormatBase* Coverage; | 265 TCoverageFormatBase* Coverage; |
| 252 int16_t DeltaGlyphID; | 266 int16_t DeltaGlyphID; |
| 253 TSingleSubstFormat1() : Coverage(nullptr), DeltaGlyphID(0) { | |
| 254 SubstFormat = 1; | |
| 255 } | |
| 256 ~TSingleSubstFormat1() override { delete Coverage; } | |
| 257 | 267 |
| 258 private: | 268 private: |
| 259 TSingleSubstFormat1(const TSingleSubstFormat1&); | 269 TSingleSubstFormat1(const TSingleSubstFormat1&); |
| 260 TSingleSubstFormat1& operator=(const TSingleSubstFormat1&); | 270 TSingleSubstFormat1& operator=(const TSingleSubstFormat1&); |
| 261 }; | 271 }; |
| 262 struct TSingleSubstFormat2 : public TSubTableBase { | 272 struct TSingleSubstFormat2 : public TSubTableBase { |
| 273 TSingleSubstFormat2(); |
| 274 ~TSingleSubstFormat2() override; |
| 275 |
| 263 TCoverageFormatBase* Coverage; | 276 TCoverageFormatBase* Coverage; |
| 264 uint16_t GlyphCount; | 277 uint16_t GlyphCount; |
| 265 uint16_t* Substitute; | 278 uint16_t* Substitute; |
| 266 TSingleSubstFormat2() | |
| 267 : Coverage(nullptr), GlyphCount(0), Substitute(nullptr) { | |
| 268 SubstFormat = 2; | |
| 269 } | |
| 270 ~TSingleSubstFormat2() override { | |
| 271 delete Coverage; | |
| 272 delete[] Substitute; | |
| 273 } | |
| 274 | 279 |
| 275 private: | 280 private: |
| 276 TSingleSubstFormat2(const TSingleSubstFormat2&); | 281 TSingleSubstFormat2(const TSingleSubstFormat2&); |
| 277 TSingleSubstFormat2& operator=(const TSingleSubstFormat2&); | 282 TSingleSubstFormat2& operator=(const TSingleSubstFormat2&); |
| 278 }; | 283 }; |
| 279 struct TLookup { | 284 struct TLookup { |
| 285 TLookup(); |
| 286 ~TLookup(); |
| 287 |
| 280 uint16_t LookupType; | 288 uint16_t LookupType; |
| 281 uint16_t LookupFlag; | 289 uint16_t LookupFlag; |
| 282 uint16_t SubTableCount; | 290 uint16_t SubTableCount; |
| 283 struct TSubTableBase** SubTable; | 291 struct TSubTableBase** SubTable; |
| 284 TLookup() | |
| 285 : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(nullptr) {} | |
| 286 ~TLookup() { | |
| 287 if (SubTable) { | |
| 288 for (int i = 0; i < SubTableCount; ++i) | |
| 289 delete SubTable[i]; | |
| 290 delete[] SubTable; | |
| 291 } | |
| 292 } | |
| 293 | 292 |
| 294 private: | 293 private: |
| 295 TLookup(const TLookup&); | 294 TLookup(const TLookup&); |
| 296 TLookup& operator=(const TLookup&); | 295 TLookup& operator=(const TLookup&); |
| 297 }; | 296 }; |
| 298 struct TLookupList { | 297 struct TLookupList { |
| 298 TLookupList() : LookupCount(0), Lookup(nullptr) {} |
| 299 ~TLookupList() { delete[] Lookup; } |
| 300 |
| 299 int LookupCount; | 301 int LookupCount; |
| 300 struct TLookup* Lookup; | 302 struct TLookup* Lookup; |
| 301 TLookupList() : LookupCount(0), Lookup(nullptr) {} | |
| 302 ~TLookupList() { delete[] Lookup; } | |
| 303 | 303 |
| 304 private: | 304 private: |
| 305 TLookupList(const TLookupList&); | 305 TLookupList(const TLookupList&); |
| 306 TLookupList& operator=(const TLookupList&); | 306 TLookupList& operator=(const TLookupList&); |
| 307 }; | 307 }; |
| 308 |
| 308 bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist); | 309 bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist); |
| 309 void ParseScriptList(FT_Bytes raw, TScriptList* rec); | 310 void ParseScriptList(FT_Bytes raw, TScriptList* rec); |
| 310 void ParseScript(FT_Bytes raw, TScript* rec); | 311 void ParseScript(FT_Bytes raw, TScript* rec); |
| 311 void ParseLangSys(FT_Bytes raw, TLangSys* rec); | 312 void ParseLangSys(FT_Bytes raw, TLangSys* rec); |
| 312 void ParseFeatureList(FT_Bytes raw, TFeatureList* rec); | 313 void ParseFeatureList(FT_Bytes raw, TFeatureList* rec); |
| 313 void ParseFeature(FT_Bytes raw, TFeature* rec); | 314 void ParseFeature(FT_Bytes raw, TFeature* rec); |
| 314 void ParseLookupList(FT_Bytes raw, TLookupList* rec); | 315 void ParseLookupList(FT_Bytes raw, TLookupList* rec); |
| 315 void ParseLookup(FT_Bytes raw, TLookup* rec); | 316 void ParseLookup(FT_Bytes raw, TLookup* rec); |
| 316 void ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec); | 317 void ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec); |
| 317 void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec); | 318 void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec); |
| 318 void ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2* rec); | 319 void ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2* rec); |
| 319 void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec); | 320 void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec); |
| 320 void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec); | 321 void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec); |
| 321 void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec); | 322 void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec); |
| 323 |
| 322 bool GetVerticalGlyphSub(uint32_t glyphnum, | 324 bool GetVerticalGlyphSub(uint32_t glyphnum, |
| 323 uint32_t* vglyphnum, | 325 uint32_t* vglyphnum, |
| 324 struct TFeature* Feature); | 326 struct TFeature* Feature) const; |
| 325 bool GetVerticalGlyphSub2(uint32_t glyphnum, | 327 bool GetVerticalGlyphSub2(uint32_t glyphnum, |
| 326 uint32_t* vglyphnum, | 328 uint32_t* vglyphnum, |
| 327 struct TLookup* Lookup); | 329 struct TLookup* Lookup) const; |
| 328 int GetCoverageIndex(struct TCoverageFormatBase* Coverage, uint32_t g); | 330 int GetCoverageIndex(struct TCoverageFormatBase* Coverage, uint32_t g) const; |
| 329 uint8_t GetUInt8(FT_Bytes& p) const { | 331 |
| 330 uint8_t ret = p[0]; | 332 uint8_t GetUInt8(FT_Bytes& p) const; |
| 331 p += 1; | 333 int16_t GetInt16(FT_Bytes& p) const; |
| 332 return ret; | 334 uint16_t GetUInt16(FT_Bytes& p) const; |
| 333 } | 335 int32_t GetInt32(FT_Bytes& p) const; |
| 334 int16_t GetInt16(FT_Bytes& p) const { | 336 uint32_t GetUInt32(FT_Bytes& p) const; |
| 335 uint16_t ret = p[0] << 8 | p[1]; | 337 |
| 336 p += 2; | |
| 337 return *(int16_t*)&ret; | |
| 338 } | |
| 339 uint16_t GetUInt16(FT_Bytes& p) const { | |
| 340 uint16_t ret = p[0] << 8 | p[1]; | |
| 341 p += 2; | |
| 342 return ret; | |
| 343 } | |
| 344 int32_t GetInt32(FT_Bytes& p) const { | |
| 345 uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; | |
| 346 p += 4; | |
| 347 return *(int32_t*)&ret; | |
| 348 } | |
| 349 uint32_t GetUInt32(FT_Bytes& p) const { | |
| 350 uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; | |
| 351 p += 4; | |
| 352 return ret; | |
| 353 } | |
| 354 std::map<uint32_t, uint32_t> m_featureMap; | 338 std::map<uint32_t, uint32_t> m_featureMap; |
| 355 FX_BOOL m_bFeautureMapLoad; | 339 FX_BOOL m_bFeautureMapLoad; |
| 356 bool loaded; | 340 bool loaded; |
| 357 struct tt_gsub_header header; | 341 struct tt_gsub_header header; |
| 358 struct TScriptList ScriptList; | 342 struct TScriptList ScriptList; |
| 359 struct TFeatureList FeatureList; | 343 struct TFeatureList FeatureList; |
| 360 struct TLookupList LookupList; | 344 struct TLookupList LookupList; |
| 361 }; | 345 }; |
| 362 | 346 |
| 363 #endif // CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_ | 347 #endif // CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_ |
| OLD | NEW |