Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: core/src/fpdfapi/fpdf_font/ttgsubtable.h

Issue 453133004: clang-format all code (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 TTGSUBTable_H 7 #ifndef TTGSUBTable_H
8 #define TTGSUBTable_H 8 #define TTGSUBTable_H
9 #include "../../fx_freetype.h" 9 #include "../../fx_freetype.h"
10 #include "../../../include/fxcrt/fx_basic.h" 10 #include "../../../include/fxcrt/fx_basic.h"
11 #include "common.h" 11 #include "common.h"
12 class CFX_GlyphMap 12 class CFX_GlyphMap {
13 { 13 public:
14 public: 14 CFX_GlyphMap();
15 CFX_GlyphMap(); 15 ~CFX_GlyphMap();
16 ~CFX_GlyphMap(); 16 void SetAt(int key, int value);
17 void» SetAt(int key, int value); 17 FX_BOOL Lookup(int key, int& value);
18 FX_BOOL» Lookup(int key, int &value); 18
19 protected: 19 protected:
20 CFX_BinaryBuf» m_Buffer; 20 CFX_BinaryBuf m_Buffer;
21 }; 21 };
22 class CFX_CTTGSUBTable : public CFX_Object 22 class CFX_CTTGSUBTable : public CFX_Object {
23 { 23 public:
24 public: 24 CFX_CTTGSUBTable(void) : m_bFeautureMapLoad(FALSE), loaded(false){};
25 CFX_CTTGSUBTable(void): m_bFeautureMapLoad(FALSE), loaded(false) {}; 25 CFX_CTTGSUBTable(FT_Bytes gsub) : m_bFeautureMapLoad(FALSE), loaded(false) {
26 CFX_CTTGSUBTable(FT_Bytes gsub): m_bFeautureMapLoad(FALSE), loaded(false) 26 LoadGSUBTable(gsub);
27 { 27 }
28 LoadGSUBTable(gsub); 28 virtual ~CFX_CTTGSUBTable() {}
29 } 29 bool IsOk(void) const { return loaded; }
30 virtual ~CFX_CTTGSUBTable() {} 30 bool LoadGSUBTable(FT_Bytes gsub);
31 bool IsOk(void) const 31 bool GetVerticalGlyph(TT_uint32_t glyphnum, TT_uint32_t* vglyphnum);
32 { 32
33 return loaded; 33 private:
34 } 34 struct tt_gsub_header {
35 bool LoadGSUBTable(FT_Bytes gsub); 35 TT_uint32_t Version;
36 bool GetVerticalGlyph(TT_uint32_t glyphnum, TT_uint32_t *vglyphnum); 36 TT_uint16_t ScriptList;
37 private: 37 TT_uint16_t FeatureList;
38 struct tt_gsub_header { 38 TT_uint16_t LookupList;
39 TT_uint32_t Version; 39 };
40 TT_uint16_t ScriptList; 40 struct TLangSys {
41 TT_uint16_t FeatureList; 41 TT_uint16_t LookupOrder;
42 TT_uint16_t LookupList; 42 TT_uint16_t ReqFeatureIndex;
43 }; 43 TT_uint16_t FeatureCount;
44 struct TLangSys { 44 TT_uint16_t* FeatureIndex;
45 TT_uint16_t LookupOrder; 45 TLangSys()
46 TT_uint16_t ReqFeatureIndex; 46 : LookupOrder(0),
47 TT_uint16_t FeatureCount; 47 ReqFeatureIndex(0),
48 TT_uint16_t *FeatureIndex; 48 FeatureCount(0),
49 TLangSys(): LookupOrder(0), ReqFeatureIndex(0), FeatureCount(0), Feature Index(NULL) {} 49 FeatureIndex(NULL) {}
50 ~TLangSys() 50 ~TLangSys() {
51 { 51 if (FeatureIndex) {
52 if(FeatureIndex) { 52 delete[] FeatureIndex;
53 delete[] FeatureIndex; 53 }
54 } 54 }
55
56 private:
57 TLangSys(const TLangSys&);
58 TLangSys& operator=(const TLangSys&);
59 };
60 struct TLangSysRecord {
61 TT_uint32_t LangSysTag;
62 struct TLangSys LangSys;
63 TLangSysRecord() : LangSysTag(0) {}
64
65 private:
66 TLangSysRecord(const TLangSysRecord&);
67 TLangSysRecord& operator=(const TLangSysRecord&);
68 };
69 struct TScript {
70 TT_uint16_t DefaultLangSys;
71 TT_uint16_t LangSysCount;
72 struct TLangSysRecord* LangSysRecord;
73 TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(NULL) {}
74 ~TScript() {
75 if (LangSysRecord) {
76 delete[] LangSysRecord;
77 }
78 }
79
80 private:
81 TScript(const TScript&);
82 TScript& operator=(const TScript&);
83 };
84 struct TScriptRecord {
85 TT_uint32_t ScriptTag;
86 struct TScript Script;
87 TScriptRecord() : ScriptTag(0) {}
88
89 private:
90 TScriptRecord(const TScriptRecord&);
91 TScriptRecord& operator=(const TScriptRecord&);
92 };
93 struct TScriptList {
94 TT_uint16_t ScriptCount;
95 struct TScriptRecord* ScriptRecord;
96 TScriptList() : ScriptCount(0), ScriptRecord(NULL) {}
97 ~TScriptList() {
98 if (ScriptRecord) {
99 delete[] ScriptRecord;
100 }
101 }
102
103 private:
104 TScriptList(const TScriptList&);
105 TScriptList& operator=(const TScriptList&);
106 };
107 struct TFeature {
108 TT_uint16_t FeatureParams;
109 int LookupCount;
110 TT_uint16_t* LookupListIndex;
111 TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(NULL) {}
112 ~TFeature() {
113 if (LookupListIndex) {
114 delete[] LookupListIndex;
115 }
116 }
117
118 private:
119 TFeature(const TFeature&);
120 TFeature& operator=(const TFeature&);
121 };
122 struct TFeatureRecord {
123 TT_uint32_t FeatureTag;
124 struct TFeature Feature;
125 TFeatureRecord() : FeatureTag(0) {}
126
127 private:
128 TFeatureRecord(const TFeatureRecord&);
129 TFeatureRecord& operator=(const TFeatureRecord&);
130 };
131 struct TFeatureList {
132 int FeatureCount;
133 struct TFeatureRecord* FeatureRecord;
134 TFeatureList() : FeatureCount(0), FeatureRecord(NULL) {}
135 ~TFeatureList() {
136 if (FeatureRecord) {
137 delete[] FeatureRecord;
138 }
139 }
140
141 private:
142 TFeatureList(const TFeatureList&);
143 TFeatureList& operator=(const TFeatureList&);
144 };
145 enum TLookupFlag {
146 LOOKUPFLAG_RightToLeft = 0x0001,
147 LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002,
148 LOOKUPFLAG_IgnoreLigatures = 0x0004,
149 LOOKUPFLAG_IgnoreMarks = 0x0008,
150 LOOKUPFLAG_Reserved = 0x00F0,
151 LOOKUPFLAG_MarkAttachmentType = 0xFF00,
152 };
153 struct TCoverageFormatBase {
154 TT_uint16_t CoverageFormat;
155 CFX_GlyphMap m_glyphMap;
156 TCoverageFormatBase() : CoverageFormat(0) {}
157 virtual ~TCoverageFormatBase() {}
158
159 private:
160 TCoverageFormatBase(const TCoverageFormatBase&);
161 TCoverageFormatBase& operator=(const TCoverageFormatBase&);
162 };
163 struct TCoverageFormat1 : public TCoverageFormatBase {
164 TT_uint16_t GlyphCount;
165 TT_uint16_t* GlyphArray;
166 TCoverageFormat1() : GlyphCount(0), GlyphArray(NULL) { CoverageFormat = 1; }
167 ~TCoverageFormat1() {
168 if (GlyphArray) {
169 delete[] GlyphArray;
170 }
171 }
172
173 private:
174 TCoverageFormat1(const TCoverageFormat1&);
175 TCoverageFormat1& operator=(const TCoverageFormat1&);
176 };
177 struct TRangeRecord {
178 TT_uint16_t Start;
179 TT_uint16_t End;
180 TT_uint16_t StartCoverageIndex;
181 TRangeRecord() : Start(0), End(0), StartCoverageIndex(0) {}
182 friend bool operator>(const TRangeRecord& r1, const TRangeRecord& r2) {
183 return r1.Start > r2.Start;
184 }
185
186 private:
187 TRangeRecord(const TRangeRecord&);
188 };
189 struct TCoverageFormat2 : public TCoverageFormatBase {
190 TT_uint16_t RangeCount;
191 struct TRangeRecord* RangeRecord;
192 TCoverageFormat2() : RangeCount(0), RangeRecord(NULL) {
193 CoverageFormat = 2;
194 }
195 ~TCoverageFormat2() {
196 if (RangeRecord) {
197 delete[] RangeRecord;
198 }
199 }
200
201 private:
202 TCoverageFormat2(const TCoverageFormat2&);
203 TCoverageFormat2& operator=(const TCoverageFormat2&);
204 };
205 struct TClassDefFormatBase {
206 TT_uint16_t ClassFormat;
207 TClassDefFormatBase() : ClassFormat(0) {}
208 virtual ~TClassDefFormatBase() {}
209
210 private:
211 TClassDefFormatBase(const TClassDefFormatBase&);
212 TClassDefFormatBase& operator=(const TClassDefFormatBase&);
213 };
214 struct TClassDefFormat1 : public TClassDefFormatBase {
215 TT_uint16_t StartGlyph;
216 TT_uint16_t GlyphCount;
217 TT_uint16_t* ClassValueArray;
218 TClassDefFormat1() : StartGlyph(0), GlyphCount(0), ClassValueArray(NULL) {
219 ClassFormat = 1;
220 }
221 ~TClassDefFormat1() {
222 if (ClassValueArray) {
223 delete[] ClassValueArray;
224 }
225 }
226
227 private:
228 TClassDefFormat1(const TClassDefFormat1&);
229 TClassDefFormat1& operator=(const TClassDefFormat1&);
230 };
231 struct TClassRangeRecord {
232 TT_uint16_t Start;
233 TT_uint16_t End;
234 TT_uint16_t Class;
235 TClassRangeRecord() : Start(0), End(0), Class(0) {}
236
237 private:
238 TClassRangeRecord(const TClassRangeRecord&);
239 TClassRangeRecord& operator=(const TClassRangeRecord&);
240 };
241 struct TClassDefFormat2 : public TClassDefFormatBase {
242 TT_uint16_t ClassRangeCount;
243 struct TClassRangeRecord* ClassRangeRecord;
244 TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(NULL) {
245 ClassFormat = 2;
246 }
247 ~TClassDefFormat2() {
248 if (ClassRangeRecord) {
249 delete[] ClassRangeRecord;
250 }
251 }
252
253 private:
254 TClassDefFormat2(const TClassDefFormat2&);
255 TClassDefFormat2& operator=(const TClassDefFormat2&);
256 };
257 struct TDevice {
258 TT_uint16_t StartSize;
259 TT_uint16_t EndSize;
260 TT_uint16_t DeltaFormat;
261 TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {}
262
263 private:
264 TDevice(const TDevice&);
265 TDevice& operator=(const TDevice&);
266 };
267 struct TSubTableBase {
268 TT_uint16_t SubstFormat;
269 TSubTableBase() : SubstFormat(0) {}
270 virtual ~TSubTableBase() {}
271
272 private:
273 TSubTableBase(const TSubTableBase&);
274 TSubTableBase& operator=(const TSubTableBase&);
275 };
276 struct TSingleSubstFormat1 : public TSubTableBase {
277 TCoverageFormatBase* Coverage;
278 TT_int16_t DeltaGlyphID;
279 TSingleSubstFormat1() : Coverage(NULL), DeltaGlyphID(0) { SubstFormat = 1; }
280 ~TSingleSubstFormat1() {
281 if (Coverage) {
282 delete Coverage;
283 }
284 }
285
286 private:
287 TSingleSubstFormat1(const TSingleSubstFormat1&);
288 TSingleSubstFormat1& operator=(const TSingleSubstFormat1&);
289 };
290 struct TSingleSubstFormat2 : public TSubTableBase {
291 TCoverageFormatBase* Coverage;
292 TT_uint16_t GlyphCount;
293 TT_uint16_t* Substitute;
294 TSingleSubstFormat2() : Coverage(NULL), GlyphCount(0), Substitute(NULL) {
295 SubstFormat = 2;
296 }
297 ~TSingleSubstFormat2() {
298 if (Coverage) {
299 delete Coverage;
300 }
301 if (Substitute) {
302 delete[] Substitute;
303 }
304 }
305
306 private:
307 TSingleSubstFormat2(const TSingleSubstFormat2&);
308 TSingleSubstFormat2& operator=(const TSingleSubstFormat2&);
309 };
310 struct TLookup {
311 TT_uint16_t LookupType;
312 TT_uint16_t LookupFlag;
313 TT_uint16_t SubTableCount;
314 struct TSubTableBase** SubTable;
315 TLookup()
316 : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(NULL) {}
317 ~TLookup() {
318 if (SubTableCount > 0 && SubTable != NULL) {
319 for (int i = 0; i < SubTableCount; i++) {
320 delete SubTable[i];
55 } 321 }
56 private: 322 delete[] SubTable;
57 TLangSys(const TLangSys&); 323 }
58 TLangSys& operator=(const TLangSys&); 324 }
59 }; 325
60 struct TLangSysRecord { 326 private:
61 TT_uint32_t LangSysTag; 327 TLookup(const TLookup&);
62 struct TLangSys LangSys; 328 TLookup& operator=(const TLookup&);
63 TLangSysRecord(): LangSysTag(0) {} 329 };
64 private: 330 struct TLookupList {
65 TLangSysRecord(const TLangSysRecord&); 331 int LookupCount;
66 TLangSysRecord& operator=(const TLangSysRecord&); 332 struct TLookup* Lookup;
67 }; 333 TLookupList() : LookupCount(0), Lookup(NULL) {}
68 struct TScript { 334 ~TLookupList() {
69 TT_uint16_t DefaultLangSys; 335 if (Lookup) {
70 TT_uint16_t LangSysCount; 336 delete[] Lookup;
71 struct TLangSysRecord *LangSysRecord; 337 }
72 TScript(): DefaultLangSys(0), LangSysCount(0), LangSysRecord(NULL) {} 338 }
73 ~TScript() 339
74 { 340 private:
75 if(LangSysRecord) { 341 TLookupList(const TLookupList&);
76 delete[] LangSysRecord; 342 TLookupList& operator=(const TLookupList&);
77 } 343 };
78 } 344 bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist);
79 private: 345 void ParseScriptList(FT_Bytes raw, TScriptList* rec);
80 TScript(const TScript&); 346 void ParseScript(FT_Bytes raw, TScript* rec);
81 TScript& operator=(const TScript&); 347 void ParseLangSys(FT_Bytes raw, TLangSys* rec);
82 }; 348 void ParseFeatureList(FT_Bytes raw, TFeatureList* rec);
83 struct TScriptRecord { 349 void ParseFeature(FT_Bytes raw, TFeature* rec);
84 TT_uint32_t ScriptTag; 350 void ParseLookupList(FT_Bytes raw, TLookupList* rec);
85 struct TScript Script; 351 void ParseLookup(FT_Bytes raw, TLookup* rec);
86 TScriptRecord(): ScriptTag(0) {} 352 void ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec);
87 private: 353 void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec);
88 TScriptRecord(const TScriptRecord&); 354 void ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2* rec);
89 TScriptRecord& operator=(const TScriptRecord&); 355 void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec);
90 }; 356 void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec);
91 struct TScriptList { 357 void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec);
92 TT_uint16_t ScriptCount; 358 bool GetVerticalGlyphSub(TT_uint32_t glyphnum,
93 struct TScriptRecord *ScriptRecord; 359 TT_uint32_t* vglyphnum,
94 TScriptList(): ScriptCount(0), ScriptRecord(NULL) {} 360 struct TFeature* Feature);
95 ~TScriptList() 361 bool GetVerticalGlyphSub2(TT_uint32_t glyphnum,
96 { 362 TT_uint32_t* vglyphnum,
97 if(ScriptRecord) { 363 struct TLookup* Lookup);
98 delete[] ScriptRecord; 364 int GetCoverageIndex(struct TCoverageFormatBase* Coverage, TT_uint32_t g);
99 } 365 TT_uint8_t GetUInt8(FT_Bytes& p) const {
100 } 366 TT_uint8_t ret = p[0];
101 private: 367 p += 1;
102 TScriptList(const TScriptList&); 368 return ret;
103 TScriptList& operator=(const TScriptList&); 369 }
104 }; 370 TT_int16_t GetInt16(FT_Bytes& p) const {
105 struct TFeature { 371 TT_uint16_t ret = p[0] << 8 | p[1];
106 TT_uint16_t FeatureParams; 372 p += 2;
107 int LookupCount; 373 return *(TT_int16_t*)&ret;
108 TT_uint16_t *LookupListIndex; 374 }
109 TFeature(): FeatureParams(0), LookupCount(0), LookupListIndex(NULL) {} 375 TT_uint16_t GetUInt16(FT_Bytes& p) const {
110 ~TFeature() 376 TT_uint16_t ret = p[0] << 8 | p[1];
111 { 377 p += 2;
112 if(LookupListIndex) { 378 return ret;
113 delete[] LookupListIndex; 379 }
114 } 380 TT_int32_t GetInt32(FT_Bytes& p) const {
115 } 381 TT_uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
116 private: 382 p += 4;
117 TFeature(const TFeature&); 383 return *(TT_int32_t*)&ret;
118 TFeature& operator=(const TFeature&); 384 }
119 }; 385 TT_uint32_t GetUInt32(FT_Bytes& p) const {
120 struct TFeatureRecord { 386 TT_uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
121 TT_uint32_t FeatureTag; 387 p += 4;
122 struct TFeature Feature; 388 return ret;
123 TFeatureRecord(): FeatureTag(0) {} 389 }
124 private: 390 CFX_CMapDWordToDWord m_featureMap;
125 TFeatureRecord(const TFeatureRecord&); 391 FX_BOOL m_bFeautureMapLoad;
126 TFeatureRecord& operator=(const TFeatureRecord&); 392 bool loaded;
127 }; 393 struct tt_gsub_header header;
128 struct TFeatureList { 394 struct TScriptList ScriptList;
129 int FeatureCount; 395 struct TFeatureList FeatureList;
130 struct TFeatureRecord *FeatureRecord; 396 struct TLookupList LookupList;
131 TFeatureList(): FeatureCount(0), FeatureRecord(NULL) {}
132 ~TFeatureList()
133 {
134 if(FeatureRecord) {
135 delete[] FeatureRecord;
136 }
137 }
138 private:
139 TFeatureList(const TFeatureList&);
140 TFeatureList& operator=(const TFeatureList&);
141 };
142 enum TLookupFlag {
143 LOOKUPFLAG_RightToLeft = 0x0001,
144 LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002,
145 LOOKUPFLAG_IgnoreLigatures = 0x0004,
146 LOOKUPFLAG_IgnoreMarks = 0x0008,
147 LOOKUPFLAG_Reserved = 0x00F0,
148 LOOKUPFLAG_MarkAttachmentType = 0xFF00,
149 };
150 struct TCoverageFormatBase {
151 TT_uint16_t CoverageFormat;
152 CFX_GlyphMap m_glyphMap;
153 TCoverageFormatBase(): CoverageFormat(0) {}
154 virtual ~TCoverageFormatBase() {}
155 private:
156 TCoverageFormatBase(const TCoverageFormatBase&);
157 TCoverageFormatBase& operator=(const TCoverageFormatBase&);
158 };
159 struct TCoverageFormat1: public TCoverageFormatBase {
160 TT_uint16_t GlyphCount;
161 TT_uint16_t *GlyphArray;
162 TCoverageFormat1(): GlyphCount(0), GlyphArray(NULL)
163 {
164 CoverageFormat = 1;
165 }
166 ~TCoverageFormat1()
167 {
168 if(GlyphArray) {
169 delete[] GlyphArray;
170 }
171 }
172 private:
173 TCoverageFormat1(const TCoverageFormat1&);
174 TCoverageFormat1& operator=(const TCoverageFormat1&);
175 };
176 struct TRangeRecord {
177 TT_uint16_t Start;
178 TT_uint16_t End;
179 TT_uint16_t StartCoverageIndex;
180 TRangeRecord(): Start(0), End(0), StartCoverageIndex(0) {}
181 friend bool operator > (const TRangeRecord &r1, const TRangeRecord &r2)
182 {
183 return r1.Start > r2.Start;
184 }
185 private:
186 TRangeRecord(const TRangeRecord&);
187 };
188 struct TCoverageFormat2: public TCoverageFormatBase {
189 TT_uint16_t RangeCount;
190 struct TRangeRecord *RangeRecord;
191 TCoverageFormat2(): RangeCount(0), RangeRecord(NULL)
192 {
193 CoverageFormat = 2;
194 }
195 ~TCoverageFormat2()
196 {
197 if(RangeRecord) {
198 delete[] RangeRecord;
199 }
200 }
201 private:
202 TCoverageFormat2(const TCoverageFormat2&);
203 TCoverageFormat2& operator=(const TCoverageFormat2&);
204 };
205 struct TClassDefFormatBase {
206 TT_uint16_t ClassFormat;
207 TClassDefFormatBase(): ClassFormat(0) {}
208 virtual ~TClassDefFormatBase() {}
209 private:
210 TClassDefFormatBase(const TClassDefFormatBase&);
211 TClassDefFormatBase& operator=(const TClassDefFormatBase&);
212 };
213 struct TClassDefFormat1: public TClassDefFormatBase {
214 TT_uint16_t StartGlyph;
215 TT_uint16_t GlyphCount;
216 TT_uint16_t *ClassValueArray;
217 TClassDefFormat1(): StartGlyph(0), GlyphCount(0), ClassValueArray(NULL)
218 {
219 ClassFormat = 1;
220 }
221 ~TClassDefFormat1()
222 {
223 if(ClassValueArray) {
224 delete[] ClassValueArray;
225 }
226 }
227 private:
228 TClassDefFormat1(const TClassDefFormat1&);
229 TClassDefFormat1& operator=(const TClassDefFormat1&);
230 };
231 struct TClassRangeRecord {
232 TT_uint16_t Start;
233 TT_uint16_t End;
234 TT_uint16_t Class;
235 TClassRangeRecord(): Start(0), End(0), Class(0) {}
236 private:
237 TClassRangeRecord(const TClassRangeRecord&);
238 TClassRangeRecord& operator=(const TClassRangeRecord&);
239 };
240 struct TClassDefFormat2: public TClassDefFormatBase {
241 TT_uint16_t ClassRangeCount;
242 struct TClassRangeRecord *ClassRangeRecord;
243 TClassDefFormat2(): ClassRangeCount(0), ClassRangeRecord(NULL)
244 {
245 ClassFormat = 2;
246 }
247 ~TClassDefFormat2()
248 {
249 if(ClassRangeRecord) {
250 delete[] ClassRangeRecord;
251 }
252 }
253 private:
254 TClassDefFormat2(const TClassDefFormat2&);
255 TClassDefFormat2& operator=(const TClassDefFormat2&);
256 };
257 struct TDevice {
258 TT_uint16_t StartSize;
259 TT_uint16_t EndSize;
260 TT_uint16_t DeltaFormat;
261 TDevice(): StartSize(0), EndSize(0), DeltaFormat(0) {}
262 private:
263 TDevice(const TDevice&);
264 TDevice& operator=(const TDevice&);
265 };
266 struct TSubTableBase {
267 TT_uint16_t SubstFormat;
268 TSubTableBase(): SubstFormat(0) {}
269 virtual ~TSubTableBase() {}
270 private:
271 TSubTableBase(const TSubTableBase&);
272 TSubTableBase& operator=(const TSubTableBase&);
273 };
274 struct TSingleSubstFormat1: public TSubTableBase {
275 TCoverageFormatBase *Coverage;
276 TT_int16_t DeltaGlyphID;
277 TSingleSubstFormat1(): Coverage(NULL), DeltaGlyphID(0)
278 {
279 SubstFormat = 1;
280 }
281 ~TSingleSubstFormat1()
282 {
283 if(Coverage) {
284 delete Coverage;
285 }
286 }
287 private:
288 TSingleSubstFormat1(const TSingleSubstFormat1&);
289 TSingleSubstFormat1& operator=(const TSingleSubstFormat1&);
290 };
291 struct TSingleSubstFormat2: public TSubTableBase {
292 TCoverageFormatBase *Coverage;
293 TT_uint16_t GlyphCount;
294 TT_uint16_t *Substitute;
295 TSingleSubstFormat2(): Coverage(NULL), GlyphCount(0), Substitute(NULL)
296 {
297 SubstFormat = 2;
298 }
299 ~TSingleSubstFormat2()
300 {
301 if(Coverage) {
302 delete Coverage;
303 }
304 if(Substitute) {
305 delete[] Substitute;
306 }
307 }
308 private:
309 TSingleSubstFormat2(const TSingleSubstFormat2&);
310 TSingleSubstFormat2& operator=(const TSingleSubstFormat2&);
311 };
312 struct TLookup {
313 TT_uint16_t LookupType;
314 TT_uint16_t LookupFlag;
315 TT_uint16_t SubTableCount;
316 struct TSubTableBase **SubTable;
317 TLookup(): LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(NULL ) {}
318 ~TLookup()
319 {
320 if(SubTableCount > 0 && SubTable != NULL) {
321 for(int i = 0; i < SubTableCount; i++) {
322 delete SubTable[i];
323 }
324 delete[] SubTable;
325 }
326 }
327 private:
328 TLookup(const TLookup&);
329 TLookup& operator=(const TLookup&);
330 };
331 struct TLookupList {
332 int LookupCount;
333 struct TLookup *Lookup;
334 TLookupList(): LookupCount(0), Lookup(NULL) {}
335 ~TLookupList()
336 {
337 if(Lookup) {
338 delete[] Lookup;
339 }
340 }
341 private:
342 TLookupList(const TLookupList&);
343 TLookupList& operator=(const TLookupList&);
344 };
345 bool Parse(
346 FT_Bytes scriptlist,
347 FT_Bytes featurelist,
348 FT_Bytes lookuplist);
349 void ParseScriptList(FT_Bytes raw, TScriptList *rec);
350 void ParseScript(FT_Bytes raw, TScript *rec);
351 void ParseLangSys(FT_Bytes raw, TLangSys *rec);
352 void ParseFeatureList(FT_Bytes raw, TFeatureList *rec);
353 void ParseFeature(FT_Bytes raw, TFeature *rec);
354 void ParseLookupList(FT_Bytes raw, TLookupList *rec);
355 void ParseLookup(FT_Bytes raw, TLookup *rec);
356 void ParseCoverage(FT_Bytes raw, TCoverageFormatBase **rec);
357 void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1 *rec);
358 void ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2 *rec);
359 void ParseSingleSubst(FT_Bytes raw, TSubTableBase **rec);
360 void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1 *rec);
361 void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2 *rec);
362 bool GetVerticalGlyphSub(
363 TT_uint32_t glyphnum,
364 TT_uint32_t *vglyphnum,
365 struct TFeature *Feature);
366 bool GetVerticalGlyphSub2(
367 TT_uint32_t glyphnum,
368 TT_uint32_t *vglyphnum,
369 struct TLookup *Lookup);
370 int GetCoverageIndex(struct TCoverageFormatBase *Coverage, TT_uint32_t g);
371 TT_uint8_t GetUInt8(FT_Bytes& p) const
372 {
373 TT_uint8_t ret = p[0];
374 p += 1;
375 return ret;
376 }
377 TT_int16_t GetInt16(FT_Bytes& p) const
378 {
379 TT_uint16_t ret = p[0] << 8 | p[1];
380 p += 2;
381 return *(TT_int16_t*)&ret;
382 }
383 TT_uint16_t GetUInt16(FT_Bytes& p) const
384 {
385 TT_uint16_t ret = p[0] << 8 | p[1];
386 p += 2;
387 return ret;
388 }
389 TT_int32_t GetInt32(FT_Bytes& p) const
390 {
391 TT_uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
392 p += 4;
393 return *(TT_int32_t*)&ret;
394 }
395 TT_uint32_t GetUInt32(FT_Bytes& p) const
396 {
397 TT_uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
398 p += 4;
399 return ret;
400 }
401 CFX_CMapDWordToDWord m_featureMap;
402 FX_BOOL m_bFeautureMapLoad;
403 bool loaded;
404 struct tt_gsub_header header;
405 struct TScriptList ScriptList;
406 struct TFeatureList FeatureList;
407 struct TLookupList LookupList;
408 }; 397 };
409 class CFX_GSUBTable FX_FINAL : public IFX_GSUBTable, public CFX_Object 398 class CFX_GSUBTable FX_FINAL : public IFX_GSUBTable, public CFX_Object {
410 { 399 public:
411 public: 400 virtual void Release() { delete this; }
412 virtual void» Release() 401 virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum);
413 { 402 CFX_CTTGSUBTable m_GsubImp;
414 delete this;
415 }
416 virtual FX_BOOL GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum);
417 CFX_CTTGSUBTable m_GsubImp;
418 }; 403 };
419 #endif 404 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698