Chromium Code Reviews| 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(void); |
|
dsinclair
2016/06/13 20:24:08
nit: void not needed.
Lei Zhang
2016/06/13 20:44:28
We probably should do a sweep for these separately
Wei Li
2016/06/13 21:38:03
Done.
Wei Li
2016/06/13 21:38:03
Created bug 519 to track the efforts.
| |
| 32 CFX_CTTGSUBTable(FT_Bytes gsub) : m_bFeautureMapLoad(FALSE), loaded(false) { | 33 CFX_CTTGSUBTable(FT_Bytes gsub); |
|
dsinclair
2016/06/13 20:24:08
nit: explicit
Wei Li
2016/06/13 21:38:03
Done.
| |
| 33 LoadGSUBTable(gsub); | 34 virtual ~CFX_CTTGSUBTable(); |
|
Lei Zhang
2016/06/13 20:44:28
Does this need to be virtual?
Wei Li
2016/06/13 21:38:03
Probably not needed since this class is not inheri
| |
| 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; } | |
|
dsinclair
2016/06/13 20:24:08
Can we add a todo to go through and update these t
Wei Li
2016/06/13 21:38:03
Done.
| |
| 77 | |
| 73 uint16_t DefaultLangSys; | 78 uint16_t DefaultLangSys; |
| 74 uint16_t LangSysCount; | 79 uint16_t LangSysCount; |
| 75 struct TLangSysRecord* LangSysRecord; | 80 struct TLangSysRecord* LangSysRecord; |
| 76 TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(nullptr) {} | |
| 77 ~TScript() { delete[] LangSysRecord; } | |
| 78 | 81 |
| 79 private: | 82 private: |
| 80 TScript(const TScript&); | 83 TScript(const TScript&); |
| 81 TScript& operator=(const TScript&); | 84 TScript& operator=(const TScript&); |
| 82 }; | 85 }; |
| 83 struct TScriptRecord { | 86 struct TScriptRecord { |
| 87 TScriptRecord() : ScriptTag(0) {} | |
| 88 | |
| 84 uint32_t ScriptTag; | 89 uint32_t ScriptTag; |
| 85 struct TScript Script; | 90 struct TScript Script; |
| 86 TScriptRecord() : ScriptTag(0) {} | |
| 87 | 91 |
| 88 private: | 92 private: |
| 89 TScriptRecord(const TScriptRecord&); | 93 TScriptRecord(const TScriptRecord&); |
| 90 TScriptRecord& operator=(const TScriptRecord&); | 94 TScriptRecord& operator=(const TScriptRecord&); |
| 91 }; | 95 }; |
| 92 struct TScriptList { | 96 struct TScriptList { |
| 97 TScriptList() : ScriptCount(0), ScriptRecord(nullptr) {} | |
| 98 ~TScriptList() { delete[] ScriptRecord; } | |
| 99 | |
| 93 uint16_t ScriptCount; | 100 uint16_t ScriptCount; |
| 94 struct TScriptRecord* ScriptRecord; | 101 struct TScriptRecord* ScriptRecord; |
| 95 TScriptList() : ScriptCount(0), ScriptRecord(nullptr) {} | |
| 96 ~TScriptList() { delete[] ScriptRecord; } | |
| 97 | 102 |
| 98 private: | 103 private: |
| 99 TScriptList(const TScriptList&); | 104 TScriptList(const TScriptList&); |
| 100 TScriptList& operator=(const TScriptList&); | 105 TScriptList& operator=(const TScriptList&); |
| 101 }; | 106 }; |
| 102 struct TFeature { | 107 struct TFeature { |
| 108 TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {} | |
| 109 ~TFeature() { delete[] LookupListIndex; } | |
| 110 | |
| 103 uint16_t FeatureParams; | 111 uint16_t FeatureParams; |
| 104 int LookupCount; | 112 int LookupCount; |
| 105 uint16_t* LookupListIndex; | 113 uint16_t* LookupListIndex; |
| 106 TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {} | |
| 107 ~TFeature() { delete[] LookupListIndex; } | |
| 108 | 114 |
| 109 private: | 115 private: |
| 110 TFeature(const TFeature&); | 116 TFeature(const TFeature&); |
| 111 TFeature& operator=(const TFeature&); | 117 TFeature& operator=(const TFeature&); |
| 112 }; | 118 }; |
| 113 struct TFeatureRecord { | 119 struct TFeatureRecord { |
| 120 TFeatureRecord() : FeatureTag(0) {} | |
| 121 | |
| 114 uint32_t FeatureTag; | 122 uint32_t FeatureTag; |
| 115 struct TFeature Feature; | 123 struct TFeature Feature; |
| 116 TFeatureRecord() : FeatureTag(0) {} | |
| 117 | 124 |
| 118 private: | 125 private: |
| 119 TFeatureRecord(const TFeatureRecord&); | 126 TFeatureRecord(const TFeatureRecord&); |
| 120 TFeatureRecord& operator=(const TFeatureRecord&); | 127 TFeatureRecord& operator=(const TFeatureRecord&); |
| 121 }; | 128 }; |
| 122 struct TFeatureList { | 129 struct TFeatureList { |
| 130 TFeatureList() : FeatureCount(0), FeatureRecord(nullptr) {} | |
| 131 ~TFeatureList() { delete[] FeatureRecord; } | |
| 132 | |
| 123 int FeatureCount; | 133 int FeatureCount; |
| 124 struct TFeatureRecord* FeatureRecord; | 134 struct TFeatureRecord* FeatureRecord; |
| 125 TFeatureList() : FeatureCount(0), FeatureRecord(nullptr) {} | |
| 126 ~TFeatureList() { delete[] FeatureRecord; } | |
| 127 | 135 |
| 128 private: | 136 private: |
| 129 TFeatureList(const TFeatureList&); | 137 TFeatureList(const TFeatureList&); |
| 130 TFeatureList& operator=(const TFeatureList&); | 138 TFeatureList& operator=(const TFeatureList&); |
| 131 }; | 139 }; |
| 132 enum TLookupFlag { | 140 enum TLookupFlag { |
| 133 LOOKUPFLAG_RightToLeft = 0x0001, | 141 LOOKUPFLAG_RightToLeft = 0x0001, |
| 134 LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002, | 142 LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002, |
| 135 LOOKUPFLAG_IgnoreLigatures = 0x0004, | 143 LOOKUPFLAG_IgnoreLigatures = 0x0004, |
| 136 LOOKUPFLAG_IgnoreMarks = 0x0008, | 144 LOOKUPFLAG_IgnoreMarks = 0x0008, |
| 137 LOOKUPFLAG_Reserved = 0x00F0, | 145 LOOKUPFLAG_Reserved = 0x00F0, |
| 138 LOOKUPFLAG_MarkAttachmentType = 0xFF00, | 146 LOOKUPFLAG_MarkAttachmentType = 0xFF00, |
| 139 }; | 147 }; |
| 140 struct TCoverageFormatBase { | 148 struct TCoverageFormatBase { |
| 149 TCoverageFormatBase() : CoverageFormat(0) {} | |
| 150 virtual ~TCoverageFormatBase() {} | |
| 151 | |
| 141 uint16_t CoverageFormat; | 152 uint16_t CoverageFormat; |
| 142 CFX_GlyphMap m_glyphMap; | 153 CFX_GlyphMap m_glyphMap; |
| 143 TCoverageFormatBase() : CoverageFormat(0) {} | |
| 144 virtual ~TCoverageFormatBase() {} | |
| 145 | 154 |
| 146 private: | 155 private: |
| 147 TCoverageFormatBase(const TCoverageFormatBase&); | 156 TCoverageFormatBase(const TCoverageFormatBase&); |
| 148 TCoverageFormatBase& operator=(const TCoverageFormatBase&); | 157 TCoverageFormatBase& operator=(const TCoverageFormatBase&); |
| 149 }; | 158 }; |
| 150 struct TCoverageFormat1 : public TCoverageFormatBase { | 159 struct TCoverageFormat1 : public TCoverageFormatBase { |
| 160 TCoverageFormat1(); | |
| 161 ~TCoverageFormat1() override; | |
| 162 | |
| 151 uint16_t GlyphCount; | 163 uint16_t GlyphCount; |
| 152 uint16_t* GlyphArray; | 164 uint16_t* GlyphArray; |
| 153 TCoverageFormat1() : GlyphCount(0), GlyphArray(nullptr) { | |
| 154 CoverageFormat = 1; | |
| 155 } | |
| 156 ~TCoverageFormat1() override { delete[] GlyphArray; } | |
| 157 | 165 |
| 158 private: | 166 private: |
| 159 TCoverageFormat1(const TCoverageFormat1&); | 167 TCoverageFormat1(const TCoverageFormat1&); |
| 160 TCoverageFormat1& operator=(const TCoverageFormat1&); | 168 TCoverageFormat1& operator=(const TCoverageFormat1&); |
| 161 }; | 169 }; |
| 162 struct TRangeRecord { | 170 struct TRangeRecord { |
| 171 TRangeRecord(); | |
| 172 | |
| 173 friend bool operator>(const TRangeRecord& r1, const TRangeRecord& r2) { | |
| 174 return r1.Start > r2.Start; | |
| 175 } | |
| 176 | |
| 163 uint16_t Start; | 177 uint16_t Start; |
| 164 uint16_t End; | 178 uint16_t End; |
| 165 uint16_t StartCoverageIndex; | 179 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 | 180 |
| 171 private: | 181 private: |
| 172 TRangeRecord(const TRangeRecord&); | 182 TRangeRecord(const TRangeRecord&); |
| 173 }; | 183 }; |
| 174 struct TCoverageFormat2 : public TCoverageFormatBase { | 184 struct TCoverageFormat2 : public TCoverageFormatBase { |
| 185 TCoverageFormat2(); | |
| 186 ~TCoverageFormat2() override; | |
| 187 | |
| 175 uint16_t RangeCount; | 188 uint16_t RangeCount; |
| 176 struct TRangeRecord* RangeRecord; | 189 struct TRangeRecord* RangeRecord; |
| 177 TCoverageFormat2() : RangeCount(0), RangeRecord(nullptr) { | |
| 178 CoverageFormat = 2; | |
| 179 } | |
| 180 ~TCoverageFormat2() override { delete[] RangeRecord; } | |
| 181 | 190 |
| 182 private: | 191 private: |
| 183 TCoverageFormat2(const TCoverageFormat2&); | 192 TCoverageFormat2(const TCoverageFormat2&); |
| 184 TCoverageFormat2& operator=(const TCoverageFormat2&); | 193 TCoverageFormat2& operator=(const TCoverageFormat2&); |
| 185 }; | 194 }; |
| 186 struct TClassDefFormatBase { | 195 struct TClassDefFormatBase { |
| 187 uint16_t ClassFormat; | |
| 188 TClassDefFormatBase() : ClassFormat(0) {} | 196 TClassDefFormatBase() : ClassFormat(0) {} |
| 189 virtual ~TClassDefFormatBase() {} | 197 virtual ~TClassDefFormatBase() {} |
| 190 | 198 |
| 199 uint16_t ClassFormat; | |
| 200 | |
| 191 private: | 201 private: |
| 192 TClassDefFormatBase(const TClassDefFormatBase&); | 202 TClassDefFormatBase(const TClassDefFormatBase&); |
| 193 TClassDefFormatBase& operator=(const TClassDefFormatBase&); | 203 TClassDefFormatBase& operator=(const TClassDefFormatBase&); |
| 194 }; | 204 }; |
| 195 struct TClassDefFormat1 : public TClassDefFormatBase { | 205 struct TClassDefFormat1 : public TClassDefFormatBase { |
| 206 TClassDefFormat1(); | |
| 207 ~TClassDefFormat1() override; | |
| 208 | |
| 196 uint16_t StartGlyph; | 209 uint16_t StartGlyph; |
| 197 uint16_t GlyphCount; | 210 uint16_t GlyphCount; |
| 198 uint16_t* ClassValueArray; | 211 uint16_t* ClassValueArray; |
| 199 TClassDefFormat1() | |
| 200 : StartGlyph(0), GlyphCount(0), ClassValueArray(nullptr) { | |
| 201 ClassFormat = 1; | |
| 202 } | |
| 203 ~TClassDefFormat1() override { delete[] ClassValueArray; } | |
| 204 | 212 |
| 205 private: | 213 private: |
| 206 TClassDefFormat1(const TClassDefFormat1&); | 214 TClassDefFormat1(const TClassDefFormat1&); |
| 207 TClassDefFormat1& operator=(const TClassDefFormat1&); | 215 TClassDefFormat1& operator=(const TClassDefFormat1&); |
| 208 }; | 216 }; |
| 209 struct TClassRangeRecord { | 217 struct TClassRangeRecord { |
| 218 TClassRangeRecord() : Start(0), End(0), Class(0) {} | |
| 219 | |
| 210 uint16_t Start; | 220 uint16_t Start; |
| 211 uint16_t End; | 221 uint16_t End; |
| 212 uint16_t Class; | 222 uint16_t Class; |
| 213 TClassRangeRecord() : Start(0), End(0), Class(0) {} | |
| 214 | 223 |
| 215 private: | 224 private: |
| 216 TClassRangeRecord(const TClassRangeRecord&); | 225 TClassRangeRecord(const TClassRangeRecord&); |
| 217 TClassRangeRecord& operator=(const TClassRangeRecord&); | 226 TClassRangeRecord& operator=(const TClassRangeRecord&); |
| 218 }; | 227 }; |
| 219 struct TClassDefFormat2 : public TClassDefFormatBase { | 228 struct TClassDefFormat2 : public TClassDefFormatBase { |
| 229 TClassDefFormat2(); | |
| 230 ~TClassDefFormat2() override; | |
| 231 | |
| 220 uint16_t ClassRangeCount; | 232 uint16_t ClassRangeCount; |
| 221 struct TClassRangeRecord* ClassRangeRecord; | 233 struct TClassRangeRecord* ClassRangeRecord; |
| 222 TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(nullptr) { | |
| 223 ClassFormat = 2; | |
| 224 } | |
| 225 ~TClassDefFormat2() override { delete[] ClassRangeRecord; } | |
| 226 | 234 |
| 227 private: | 235 private: |
| 228 TClassDefFormat2(const TClassDefFormat2&); | 236 TClassDefFormat2(const TClassDefFormat2&); |
| 229 TClassDefFormat2& operator=(const TClassDefFormat2&); | 237 TClassDefFormat2& operator=(const TClassDefFormat2&); |
| 230 }; | 238 }; |
| 231 struct TDevice { | 239 struct TDevice { |
| 240 TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {} | |
| 241 | |
| 232 uint16_t StartSize; | 242 uint16_t StartSize; |
| 233 uint16_t EndSize; | 243 uint16_t EndSize; |
| 234 uint16_t DeltaFormat; | 244 uint16_t DeltaFormat; |
| 235 TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {} | |
| 236 | 245 |
| 237 private: | 246 private: |
| 238 TDevice(const TDevice&); | 247 TDevice(const TDevice&); |
| 239 TDevice& operator=(const TDevice&); | 248 TDevice& operator=(const TDevice&); |
| 240 }; | 249 }; |
| 241 struct TSubTableBase { | 250 struct TSubTableBase { |
| 242 uint16_t SubstFormat; | |
| 243 TSubTableBase() : SubstFormat(0) {} | 251 TSubTableBase() : SubstFormat(0) {} |
| 244 virtual ~TSubTableBase() {} | 252 virtual ~TSubTableBase() {} |
| 245 | 253 |
| 254 uint16_t SubstFormat; | |
| 255 | |
| 246 private: | 256 private: |
| 247 TSubTableBase(const TSubTableBase&); | 257 TSubTableBase(const TSubTableBase&); |
| 248 TSubTableBase& operator=(const TSubTableBase&); | 258 TSubTableBase& operator=(const TSubTableBase&); |
| 249 }; | 259 }; |
| 250 struct TSingleSubstFormat1 : public TSubTableBase { | 260 struct TSingleSubstFormat1 : public TSubTableBase { |
| 261 TSingleSubstFormat1(); | |
| 262 ~TSingleSubstFormat1() override; | |
| 263 | |
| 251 TCoverageFormatBase* Coverage; | 264 TCoverageFormatBase* Coverage; |
| 252 int16_t DeltaGlyphID; | 265 int16_t DeltaGlyphID; |
| 253 TSingleSubstFormat1() : Coverage(nullptr), DeltaGlyphID(0) { | |
| 254 SubstFormat = 1; | |
| 255 } | |
| 256 ~TSingleSubstFormat1() override { delete Coverage; } | |
| 257 | 266 |
| 258 private: | 267 private: |
| 259 TSingleSubstFormat1(const TSingleSubstFormat1&); | 268 TSingleSubstFormat1(const TSingleSubstFormat1&); |
| 260 TSingleSubstFormat1& operator=(const TSingleSubstFormat1&); | 269 TSingleSubstFormat1& operator=(const TSingleSubstFormat1&); |
| 261 }; | 270 }; |
| 262 struct TSingleSubstFormat2 : public TSubTableBase { | 271 struct TSingleSubstFormat2 : public TSubTableBase { |
| 272 TSingleSubstFormat2(); | |
| 273 ~TSingleSubstFormat2() override; | |
| 274 | |
| 263 TCoverageFormatBase* Coverage; | 275 TCoverageFormatBase* Coverage; |
| 264 uint16_t GlyphCount; | 276 uint16_t GlyphCount; |
| 265 uint16_t* Substitute; | 277 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 | 278 |
| 275 private: | 279 private: |
| 276 TSingleSubstFormat2(const TSingleSubstFormat2&); | 280 TSingleSubstFormat2(const TSingleSubstFormat2&); |
| 277 TSingleSubstFormat2& operator=(const TSingleSubstFormat2&); | 281 TSingleSubstFormat2& operator=(const TSingleSubstFormat2&); |
| 278 }; | 282 }; |
| 279 struct TLookup { | 283 struct TLookup { |
| 284 TLookup(); | |
| 285 ~TLookup(); | |
| 286 | |
| 280 uint16_t LookupType; | 287 uint16_t LookupType; |
| 281 uint16_t LookupFlag; | 288 uint16_t LookupFlag; |
| 282 uint16_t SubTableCount; | 289 uint16_t SubTableCount; |
| 283 struct TSubTableBase** SubTable; | 290 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 | 291 |
| 294 private: | 292 private: |
| 295 TLookup(const TLookup&); | 293 TLookup(const TLookup&); |
| 296 TLookup& operator=(const TLookup&); | 294 TLookup& operator=(const TLookup&); |
| 297 }; | 295 }; |
| 298 struct TLookupList { | 296 struct TLookupList { |
| 297 TLookupList() : LookupCount(0), Lookup(nullptr) {} | |
| 298 ~TLookupList() { delete[] Lookup; } | |
| 299 | |
| 299 int LookupCount; | 300 int LookupCount; |
| 300 struct TLookup* Lookup; | 301 struct TLookup* Lookup; |
| 301 TLookupList() : LookupCount(0), Lookup(nullptr) {} | |
| 302 ~TLookupList() { delete[] Lookup; } | |
| 303 | 302 |
| 304 private: | 303 private: |
| 305 TLookupList(const TLookupList&); | 304 TLookupList(const TLookupList&); |
| 306 TLookupList& operator=(const TLookupList&); | 305 TLookupList& operator=(const TLookupList&); |
| 307 }; | 306 }; |
| 307 | |
| 308 bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist); | 308 bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist); |
| 309 void ParseScriptList(FT_Bytes raw, TScriptList* rec); | 309 void ParseScriptList(FT_Bytes raw, TScriptList* rec); |
| 310 void ParseScript(FT_Bytes raw, TScript* rec); | 310 void ParseScript(FT_Bytes raw, TScript* rec); |
| 311 void ParseLangSys(FT_Bytes raw, TLangSys* rec); | 311 void ParseLangSys(FT_Bytes raw, TLangSys* rec); |
| 312 void ParseFeatureList(FT_Bytes raw, TFeatureList* rec); | 312 void ParseFeatureList(FT_Bytes raw, TFeatureList* rec); |
| 313 void ParseFeature(FT_Bytes raw, TFeature* rec); | 313 void ParseFeature(FT_Bytes raw, TFeature* rec); |
| 314 void ParseLookupList(FT_Bytes raw, TLookupList* rec); | 314 void ParseLookupList(FT_Bytes raw, TLookupList* rec); |
| 315 void ParseLookup(FT_Bytes raw, TLookup* rec); | 315 void ParseLookup(FT_Bytes raw, TLookup* rec); |
| 316 void ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec); | 316 void ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec); |
| 317 void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec); | 317 void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec); |
| 318 void ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2* rec); | 318 void ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2* rec); |
| 319 void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec); | 319 void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec); |
| 320 void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec); | 320 void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec); |
| 321 void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec); | 321 void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec); |
| 322 | |
| 322 bool GetVerticalGlyphSub(uint32_t glyphnum, | 323 bool GetVerticalGlyphSub(uint32_t glyphnum, |
| 323 uint32_t* vglyphnum, | 324 uint32_t* vglyphnum, |
| 324 struct TFeature* Feature); | 325 struct TFeature* Feature) const; |
| 325 bool GetVerticalGlyphSub2(uint32_t glyphnum, | 326 bool GetVerticalGlyphSub2(uint32_t glyphnum, |
| 326 uint32_t* vglyphnum, | 327 uint32_t* vglyphnum, |
| 327 struct TLookup* Lookup); | 328 struct TLookup* Lookup) const; |
| 328 int GetCoverageIndex(struct TCoverageFormatBase* Coverage, uint32_t g); | 329 int GetCoverageIndex(struct TCoverageFormatBase* Coverage, uint32_t g) const; |
| 329 uint8_t GetUInt8(FT_Bytes& p) const { | 330 |
| 330 uint8_t ret = p[0]; | 331 uint8_t GetUInt8(FT_Bytes& p) const; |
| 331 p += 1; | 332 int16_t GetInt16(FT_Bytes& p) const; |
| 332 return ret; | 333 uint16_t GetUInt16(FT_Bytes& p) const; |
| 333 } | 334 int32_t GetInt32(FT_Bytes& p) const; |
| 334 int16_t GetInt16(FT_Bytes& p) const { | 335 uint32_t GetUInt32(FT_Bytes& p) const; |
| 335 uint16_t ret = p[0] << 8 | p[1]; | 336 |
| 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; | 337 std::map<uint32_t, uint32_t> m_featureMap; |
| 355 FX_BOOL m_bFeautureMapLoad; | 338 FX_BOOL m_bFeautureMapLoad; |
| 356 bool loaded; | 339 bool loaded; |
| 357 struct tt_gsub_header header; | 340 struct tt_gsub_header header; |
| 358 struct TScriptList ScriptList; | 341 struct TScriptList ScriptList; |
| 359 struct TFeatureList FeatureList; | 342 struct TFeatureList FeatureList; |
| 360 struct TLookupList LookupList; | 343 struct TLookupList LookupList; |
| 361 }; | 344 }; |
| 362 | 345 |
| 363 #endif // CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_ | 346 #endif // CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_ |
| OLD | NEW |