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