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

Side by Side Diff: core/fpdfapi/fpdf_font/ttgsubtable.cpp

Issue 2119013002: Change class member variables in raw pointer type into unique_ptr (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 5 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
« no previous file with comments | « core/fpdfapi/fpdf_font/ttgsubtable.h ('k') | core/fpdfapi/fpdf_page/cpdf_formobject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" 7 #include "core/fpdfapi/fpdf_font/ttgsubtable.h"
8 8
9 #include <memory>
10
11 #include "core/fxge/include/fx_freetype.h" 9 #include "core/fxge/include/fx_freetype.h"
12 #include "core/fxge/include/fx_ge.h" 10 #include "core/fxge/include/fx_ge.h"
13 #include "third_party/base/stl_util.h" 11 #include "third_party/base/stl_util.h"
14 12
15 CFX_GlyphMap::CFX_GlyphMap() {} 13 CFX_GlyphMap::CFX_GlyphMap() {}
16 14
17 CFX_GlyphMap::~CFX_GlyphMap() {} 15 CFX_GlyphMap::~CFX_GlyphMap() {}
18 16
19 extern "C" { 17 extern "C" {
20 static int _CompareInt(const void* p1, const void* p2) { 18 static int _CompareInt(const void* p1, const void* p2) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum, 88 bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
91 uint32_t* vglyphnum) { 89 uint32_t* vglyphnum) {
92 uint32_t tag[] = { 90 uint32_t tag[] = {
93 (uint8_t)'v' << 24 | (uint8_t)'r' << 16 | (uint8_t)'t' << 8 | 91 (uint8_t)'v' << 24 | (uint8_t)'r' << 16 | (uint8_t)'t' << 8 |
94 (uint8_t)'2', 92 (uint8_t)'2',
95 (uint8_t)'v' << 24 | (uint8_t)'e' << 16 | (uint8_t)'r' << 8 | 93 (uint8_t)'v' << 24 | (uint8_t)'e' << 16 | (uint8_t)'r' << 8 |
96 (uint8_t)'t', 94 (uint8_t)'t',
97 }; 95 };
98 if (!m_bFeautureMapLoad) { 96 if (!m_bFeautureMapLoad) {
99 for (int i = 0; i < ScriptList.ScriptCount; i++) { 97 for (int i = 0; i < ScriptList.ScriptCount; i++) {
100 for (int j = 0; j < (ScriptList.ScriptRecord + i)->Script.LangSysCount; 98 for (int j = 0; j < ScriptList.ScriptRecord[i].Script.LangSysCount; ++j) {
101 ++j) { 99 const auto& record = ScriptList.ScriptRecord[i].Script.LangSysRecord[j];
102 for (int k = 0; 100 for (int k = 0; k < record.LangSys.FeatureCount; ++k) {
103 k < ((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j) 101 uint32_t index = record.LangSys.FeatureIndex[k];
104 ->LangSys.FeatureCount;
105 ++k) {
106 uint32_t index =
107 *(((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j)
108 ->LangSys.FeatureIndex +
109 k);
110 if (FeatureList.FeatureRecord[index].FeatureTag == tag[0] || 102 if (FeatureList.FeatureRecord[index].FeatureTag == tag[0] ||
111 FeatureList.FeatureRecord[index].FeatureTag == tag[1]) { 103 FeatureList.FeatureRecord[index].FeatureTag == tag[1]) {
112 if (!pdfium::ContainsKey(m_featureMap, index)) { 104 if (!pdfium::ContainsKey(m_featureMap, index)) {
113 m_featureMap[index] = index; 105 m_featureMap[index] = index;
114 } 106 }
115 } 107 }
116 } 108 }
117 } 109 }
118 } 110 }
119 if (m_featureMap.empty()) { 111 if (m_featureMap.empty()) {
(...skipping 10 matching lines...) Expand all
130 if (GetVerticalGlyphSub(glyphnum, vglyphnum, 122 if (GetVerticalGlyphSub(glyphnum, vglyphnum,
131 &FeatureList.FeatureRecord[pair.second].Feature)) { 123 &FeatureList.FeatureRecord[pair.second].Feature)) {
132 return true; 124 return true;
133 } 125 }
134 } 126 }
135 return false; 127 return false;
136 } 128 }
137 129
138 bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum, 130 bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum,
139 uint32_t* vglyphnum, 131 uint32_t* vglyphnum,
140 struct TFeature* Feature) const { 132 TFeature* Feature) const {
141 for (int i = 0; i < Feature->LookupCount; i++) { 133 for (int i = 0; i < Feature->LookupCount; i++) {
142 int index = Feature->LookupListIndex[i]; 134 int index = Feature->LookupListIndex[i];
143 if (index < 0 || LookupList.LookupCount < index) { 135 if (index < 0 || LookupList.LookupCount < index) {
144 continue; 136 continue;
145 } 137 }
146 if (LookupList.Lookup[index].LookupType == 1) { 138 if (LookupList.Lookup[index].LookupType == 1) {
147 if (GetVerticalGlyphSub2(glyphnum, vglyphnum, 139 if (GetVerticalGlyphSub2(glyphnum, vglyphnum,
148 &LookupList.Lookup[index])) { 140 &LookupList.Lookup[index])) {
149 return true; 141 return true;
150 } 142 }
151 } 143 }
152 } 144 }
153 return false; 145 return false;
154 } 146 }
155 147
156 bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum, 148 bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum,
157 uint32_t* vglyphnum, 149 uint32_t* vglyphnum,
158 struct TLookup* Lookup) const { 150 TLookup* Lookup) const {
159 for (int i = 0; i < Lookup->SubTableCount; i++) { 151 for (int i = 0; i < Lookup->SubTableCount; i++) {
160 switch (Lookup->SubTable[i]->SubstFormat) { 152 switch (Lookup->SubTable[i]->SubstFormat) {
161 case 1: { 153 case 1: {
162 TSingleSubstFormat1* tbl1 = (TSingleSubstFormat1*)Lookup->SubTable[i]; 154 TSingleSubstFormat1* tbl1 = (TSingleSubstFormat1*)Lookup->SubTable[i];
163 if (GetCoverageIndex(tbl1->Coverage, glyphnum) >= 0) { 155 if (GetCoverageIndex(tbl1->Coverage.get(), glyphnum) >= 0) {
164 *vglyphnum = glyphnum + tbl1->DeltaGlyphID; 156 *vglyphnum = glyphnum + tbl1->DeltaGlyphID;
165 return true; 157 return true;
166 } 158 }
167 break; 159 break;
168 } 160 }
169 case 2: { 161 case 2: {
170 TSingleSubstFormat2* tbl2 = (TSingleSubstFormat2*)Lookup->SubTable[i]; 162 TSingleSubstFormat2* tbl2 = (TSingleSubstFormat2*)Lookup->SubTable[i];
171 int index = -1; 163 int index = -1;
172 index = GetCoverageIndex(tbl2->Coverage, glyphnum); 164 index = GetCoverageIndex(tbl2->Coverage.get(), glyphnum);
173 if (0 <= index && index < tbl2->GlyphCount) { 165 if (0 <= index && index < tbl2->GlyphCount) {
174 *vglyphnum = tbl2->Substitute[index]; 166 *vglyphnum = tbl2->Substitute[index];
175 return true; 167 return true;
176 } 168 }
177 break; 169 break;
178 } 170 }
179 } 171 }
180 } 172 }
181 return false; 173 return false;
182 } 174 }
183 175
184 int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage, 176 int CFX_CTTGSUBTable::GetCoverageIndex(TCoverageFormatBase* Coverage,
185 uint32_t g) const { 177 uint32_t g) const {
186 int i = 0; 178 int i = 0;
187 if (!Coverage) { 179 if (!Coverage) {
188 return -1; 180 return -1;
189 } 181 }
190 switch (Coverage->CoverageFormat) { 182 switch (Coverage->CoverageFormat) {
191 case 1: { 183 case 1: {
192 TCoverageFormat1* c1 = (TCoverageFormat1*)Coverage; 184 TCoverageFormat1* c1 = (TCoverageFormat1*)Coverage;
193 for (i = 0; i < c1->GlyphCount; i++) { 185 for (i = 0; i < c1->GlyphCount; i++) {
194 if ((uint32_t)c1->GlyphArray[i] == g) { 186 if ((uint32_t)c1->GlyphArray[i] == g) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 237
246 bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist, 238 bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist,
247 FT_Bytes featurelist, 239 FT_Bytes featurelist,
248 FT_Bytes lookuplist) { 240 FT_Bytes lookuplist) {
249 ParseScriptList(scriptlist, &ScriptList); 241 ParseScriptList(scriptlist, &ScriptList);
250 ParseFeatureList(featurelist, &FeatureList); 242 ParseFeatureList(featurelist, &FeatureList);
251 ParseLookupList(lookuplist, &LookupList); 243 ParseLookupList(lookuplist, &LookupList);
252 return true; 244 return true;
253 } 245 }
254 246
255 void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, struct TScriptList* rec) { 247 void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, TScriptList* rec) {
256 int i; 248 int i;
257 FT_Bytes sp = raw; 249 FT_Bytes sp = raw;
258 rec->ScriptCount = GetUInt16(sp); 250 rec->ScriptCount = GetUInt16(sp);
259 if (rec->ScriptCount <= 0) { 251 if (rec->ScriptCount <= 0) {
260 return; 252 return;
261 } 253 }
262 rec->ScriptRecord = new struct TScriptRecord[rec->ScriptCount]; 254 rec->ScriptRecord.reset(new TScriptRecord[rec->ScriptCount]);
263 for (i = 0; i < rec->ScriptCount; i++) { 255 for (i = 0; i < rec->ScriptCount; i++) {
264 rec->ScriptRecord[i].ScriptTag = GetUInt32(sp); 256 rec->ScriptRecord[i].ScriptTag = GetUInt32(sp);
265 uint16_t offset = GetUInt16(sp); 257 uint16_t offset = GetUInt16(sp);
266 ParseScript(&raw[offset], &rec->ScriptRecord[i].Script); 258 ParseScript(&raw[offset], &rec->ScriptRecord[i].Script);
267 } 259 }
268 } 260 }
269 261
270 void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, struct TScript* rec) { 262 void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, TScript* rec) {
271 int i; 263 int i;
272 FT_Bytes sp = raw; 264 FT_Bytes sp = raw;
273 rec->DefaultLangSys = GetUInt16(sp); 265 rec->DefaultLangSys = GetUInt16(sp);
274 rec->LangSysCount = GetUInt16(sp); 266 rec->LangSysCount = GetUInt16(sp);
275 if (rec->LangSysCount <= 0) { 267 if (rec->LangSysCount <= 0) {
276 return; 268 return;
277 } 269 }
278 rec->LangSysRecord = new struct TLangSysRecord[rec->LangSysCount]; 270 rec->LangSysRecord.reset(new TLangSysRecord[rec->LangSysCount]);
279 for (i = 0; i < rec->LangSysCount; i++) { 271 for (i = 0; i < rec->LangSysCount; i++) {
280 rec->LangSysRecord[i].LangSysTag = GetUInt32(sp); 272 rec->LangSysRecord[i].LangSysTag = GetUInt32(sp);
281 uint16_t offset = GetUInt16(sp); 273 uint16_t offset = GetUInt16(sp);
282 ParseLangSys(&raw[offset], &rec->LangSysRecord[i].LangSys); 274 ParseLangSys(&raw[offset], &rec->LangSysRecord[i].LangSys);
283 } 275 }
284 } 276 }
285 277
286 void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, struct TLangSys* rec) { 278 void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, TLangSys* rec) {
287 FT_Bytes sp = raw; 279 FT_Bytes sp = raw;
288 rec->LookupOrder = GetUInt16(sp); 280 rec->LookupOrder = GetUInt16(sp);
289 rec->ReqFeatureIndex = GetUInt16(sp); 281 rec->ReqFeatureIndex = GetUInt16(sp);
290 rec->FeatureCount = GetUInt16(sp); 282 rec->FeatureCount = GetUInt16(sp);
291 if (rec->FeatureCount <= 0) { 283 if (rec->FeatureCount <= 0) {
292 return; 284 return;
293 } 285 }
294 rec->FeatureIndex = new uint16_t[rec->FeatureCount]; 286 rec->FeatureIndex.reset(new uint16_t[rec->FeatureCount]);
295 FXSYS_memset(rec->FeatureIndex, 0, sizeof(uint16_t) * rec->FeatureCount); 287 FXSYS_memset(rec->FeatureIndex.get(), 0,
288 sizeof(uint16_t) * rec->FeatureCount);
296 for (int i = 0; i < rec->FeatureCount; ++i) { 289 for (int i = 0; i < rec->FeatureCount; ++i) {
297 rec->FeatureIndex[i] = GetUInt16(sp); 290 rec->FeatureIndex[i] = GetUInt16(sp);
298 } 291 }
299 } 292 }
300 293
301 void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) { 294 void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) {
302 int i; 295 int i;
303 FT_Bytes sp = raw; 296 FT_Bytes sp = raw;
304 rec->FeatureCount = GetUInt16(sp); 297 rec->FeatureCount = GetUInt16(sp);
305 if (rec->FeatureCount <= 0) { 298 if (rec->FeatureCount <= 0) {
306 return; 299 return;
307 } 300 }
308 rec->FeatureRecord = new struct TFeatureRecord[rec->FeatureCount]; 301 rec->FeatureRecord.reset(new TFeatureRecord[rec->FeatureCount]);
309 for (i = 0; i < rec->FeatureCount; i++) { 302 for (i = 0; i < rec->FeatureCount; i++) {
310 rec->FeatureRecord[i].FeatureTag = GetUInt32(sp); 303 rec->FeatureRecord[i].FeatureTag = GetUInt32(sp);
311 uint16_t offset = GetUInt16(sp); 304 uint16_t offset = GetUInt16(sp);
312 ParseFeature(&raw[offset], &rec->FeatureRecord[i].Feature); 305 ParseFeature(&raw[offset], &rec->FeatureRecord[i].Feature);
313 } 306 }
314 } 307 }
315 308
316 void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) { 309 void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) {
317 int i; 310 int i;
318 FT_Bytes sp = raw; 311 FT_Bytes sp = raw;
319 rec->FeatureParams = GetUInt16(sp); 312 rec->FeatureParams = GetUInt16(sp);
320 rec->LookupCount = GetUInt16(sp); 313 rec->LookupCount = GetUInt16(sp);
321 if (rec->LookupCount <= 0) { 314 if (rec->LookupCount <= 0) {
322 return; 315 return;
323 } 316 }
324 rec->LookupListIndex = new uint16_t[rec->LookupCount]; 317 rec->LookupListIndex.reset(new uint16_t[rec->LookupCount]);
325 for (i = 0; i < rec->LookupCount; i++) { 318 for (i = 0; i < rec->LookupCount; i++) {
326 rec->LookupListIndex[i] = GetUInt16(sp); 319 rec->LookupListIndex[i] = GetUInt16(sp);
327 } 320 }
328 } 321 }
329 322
330 void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) { 323 void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) {
331 int i; 324 int i;
332 FT_Bytes sp = raw; 325 FT_Bytes sp = raw;
333 rec->LookupCount = GetUInt16(sp); 326 rec->LookupCount = GetUInt16(sp);
334 if (rec->LookupCount <= 0) { 327 if (rec->LookupCount <= 0) {
335 return; 328 return;
336 } 329 }
337 rec->Lookup = new struct TLookup[rec->LookupCount]; 330 rec->Lookup.reset(new TLookup[rec->LookupCount]);
338 for (i = 0; i < rec->LookupCount; i++) { 331 for (i = 0; i < rec->LookupCount; i++) {
339 uint16_t offset = GetUInt16(sp); 332 uint16_t offset = GetUInt16(sp);
340 ParseLookup(&raw[offset], &rec->Lookup[i]); 333 ParseLookup(&raw[offset], &rec->Lookup[i]);
341 } 334 }
342 } 335 }
343 336
344 void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) { 337 void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) {
345 int i; 338 int i;
346 FT_Bytes sp = raw; 339 FT_Bytes sp = raw;
347 rec->LookupType = GetUInt16(sp); 340 rec->LookupType = GetUInt16(sp);
348 rec->LookupFlag = GetUInt16(sp); 341 rec->LookupFlag = GetUInt16(sp);
349 rec->SubTableCount = GetUInt16(sp); 342 rec->SubTableCount = GetUInt16(sp);
350 if (rec->SubTableCount <= 0) { 343 if (rec->SubTableCount <= 0) {
351 return; 344 return;
352 } 345 }
353 rec->SubTable = new struct TSubTableBase*[rec->SubTableCount]; 346 rec->SubTable.reset(new TSubTableBase*[rec->SubTableCount]);
354 for (i = 0; i < rec->SubTableCount; i++) { 347 for (i = 0; i < rec->SubTableCount; i++) {
355 rec->SubTable[i] = nullptr; 348 rec->SubTable[i] = nullptr;
356 } 349 }
357 if (rec->LookupType != 1) { 350 if (rec->LookupType != 1) {
358 return; 351 return;
359 } 352 }
360 for (i = 0; i < rec->SubTableCount; i++) { 353 for (i = 0; i < rec->SubTableCount; i++) {
361 uint16_t offset = GetUInt16(sp); 354 uint16_t offset = GetUInt16(sp);
362 ParseSingleSubst(&raw[offset], &rec->SubTable[i]); 355 ParseSingleSubst(&raw[offset], &rec->SubTable[i]);
363 } 356 }
364 } 357 }
365 358
366 void CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec) { 359 CFX_CTTGSUBTable::TCoverageFormatBase* CFX_CTTGSUBTable::ParseCoverage(
360 FT_Bytes raw) {
367 FT_Bytes sp = raw; 361 FT_Bytes sp = raw;
368 uint16_t Format = GetUInt16(sp); 362 uint16_t format = GetUInt16(sp);
369 switch (Format) { 363 TCoverageFormatBase* rec = nullptr;
370 case 1: 364 if (format == 1) {
371 *rec = new TCoverageFormat1(); 365 rec = new TCoverageFormat1();
372 ParseCoverageFormat1(raw, (TCoverageFormat1*)*rec); 366 ParseCoverageFormat1(raw, static_cast<TCoverageFormat1*>(rec));
373 break; 367 } else if (format == 2) {
374 case 2: 368 rec = new TCoverageFormat2();
375 *rec = new TCoverageFormat2(); 369 ParseCoverageFormat2(raw, static_cast<TCoverageFormat2*>(rec));
376 ParseCoverageFormat2(raw, (TCoverageFormat2*)*rec);
377 break;
378 } 370 }
371 return rec;
379 } 372 }
380 373
381 void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw, 374 void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw,
382 TCoverageFormat1* rec) { 375 TCoverageFormat1* rec) {
383 int i; 376 int i;
384 FT_Bytes sp = raw; 377 FT_Bytes sp = raw;
385 GetUInt16(sp); 378 GetUInt16(sp);
386 rec->GlyphCount = GetUInt16(sp); 379 rec->GlyphCount = GetUInt16(sp);
387 if (rec->GlyphCount <= 0) { 380 if (rec->GlyphCount <= 0) {
388 return; 381 return;
389 } 382 }
390 rec->GlyphArray = new uint16_t[rec->GlyphCount]; 383 rec->GlyphArray.reset(new uint16_t[rec->GlyphCount]);
391 for (i = 0; i < rec->GlyphCount; i++) { 384 for (i = 0; i < rec->GlyphCount; i++) {
392 rec->GlyphArray[i] = GetUInt16(sp); 385 rec->GlyphArray[i] = GetUInt16(sp);
393 } 386 }
394 } 387 }
395 388
396 void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw, 389 void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw,
397 TCoverageFormat2* rec) { 390 TCoverageFormat2* rec) {
398 int i; 391 int i;
399 FT_Bytes sp = raw; 392 FT_Bytes sp = raw;
400 GetUInt16(sp); 393 GetUInt16(sp);
401 rec->RangeCount = GetUInt16(sp); 394 rec->RangeCount = GetUInt16(sp);
402 if (rec->RangeCount <= 0) { 395 if (rec->RangeCount <= 0) {
403 return; 396 return;
404 } 397 }
405 rec->RangeRecord = new TRangeRecord[rec->RangeCount]; 398 rec->RangeRecord.reset(new TRangeRecord[rec->RangeCount]);
406 for (i = 0; i < rec->RangeCount; i++) { 399 for (i = 0; i < rec->RangeCount; i++) {
407 rec->RangeRecord[i].Start = GetUInt16(sp); 400 rec->RangeRecord[i].Start = GetUInt16(sp);
408 rec->RangeRecord[i].End = GetUInt16(sp); 401 rec->RangeRecord[i].End = GetUInt16(sp);
409 rec->RangeRecord[i].StartCoverageIndex = GetUInt16(sp); 402 rec->RangeRecord[i].StartCoverageIndex = GetUInt16(sp);
410 } 403 }
411 } 404 }
412 405
413 void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) { 406 void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) {
414 FT_Bytes sp = raw; 407 FT_Bytes sp = raw;
415 uint16_t Format = GetUInt16(sp); 408 uint16_t Format = GetUInt16(sp);
416 switch (Format) { 409 switch (Format) {
417 case 1: 410 case 1:
418 *rec = new TSingleSubstFormat1(); 411 *rec = new TSingleSubstFormat1();
419 ParseSingleSubstFormat1(raw, (TSingleSubstFormat1*)*rec); 412 ParseSingleSubstFormat1(raw, (TSingleSubstFormat1*)*rec);
420 break; 413 break;
421 case 2: 414 case 2:
422 *rec = new TSingleSubstFormat2(); 415 *rec = new TSingleSubstFormat2();
423 ParseSingleSubstFormat2(raw, (TSingleSubstFormat2*)*rec); 416 ParseSingleSubstFormat2(raw, (TSingleSubstFormat2*)*rec);
424 break; 417 break;
425 } 418 }
426 } 419 }
427 420
428 void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw, 421 void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw,
429 TSingleSubstFormat1* rec) { 422 TSingleSubstFormat1* rec) {
430 FT_Bytes sp = raw; 423 FT_Bytes sp = raw;
431 GetUInt16(sp); 424 GetUInt16(sp);
432 uint16_t offset = GetUInt16(sp); 425 uint16_t offset = GetUInt16(sp);
433 ParseCoverage(&raw[offset], &rec->Coverage); 426 rec->Coverage.reset(ParseCoverage(&raw[offset]));
434 rec->DeltaGlyphID = GetInt16(sp); 427 rec->DeltaGlyphID = GetInt16(sp);
435 } 428 }
436 429
437 void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, 430 void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw,
438 TSingleSubstFormat2* rec) { 431 TSingleSubstFormat2* rec) {
439 int i; 432 int i;
440 FT_Bytes sp = raw; 433 FT_Bytes sp = raw;
441 GetUInt16(sp); 434 GetUInt16(sp);
442 uint16_t offset = GetUInt16(sp); 435 uint16_t offset = GetUInt16(sp);
443 ParseCoverage(&raw[offset], &rec->Coverage); 436 rec->Coverage.reset(ParseCoverage(&raw[offset]));
444 rec->GlyphCount = GetUInt16(sp); 437 rec->GlyphCount = GetUInt16(sp);
445 if (rec->GlyphCount <= 0) { 438 if (rec->GlyphCount <= 0) {
446 return; 439 return;
447 } 440 }
448 rec->Substitute = new uint16_t[rec->GlyphCount]; 441 rec->Substitute.reset(new uint16_t[rec->GlyphCount]);
449 for (i = 0; i < rec->GlyphCount; i++) { 442 for (i = 0; i < rec->GlyphCount; i++) {
450 rec->Substitute[i] = GetUInt16(sp); 443 rec->Substitute[i] = GetUInt16(sp);
451 } 444 }
452 } 445 }
453 446
454 CFX_CTTGSUBTable::TCoverageFormat1::TCoverageFormat1() 447 CFX_CTTGSUBTable::TCoverageFormat1::TCoverageFormat1()
455 : GlyphCount(0), GlyphArray(nullptr) { 448 : TCoverageFormatBase(1), GlyphCount(0) {}
456 CoverageFormat = 1;
457 }
458 449
459 CFX_CTTGSUBTable::TCoverageFormat1::~TCoverageFormat1() { 450 CFX_CTTGSUBTable::TCoverageFormat1::~TCoverageFormat1() {}
460 delete[] GlyphArray;
461 }
462 451
463 CFX_CTTGSUBTable::TRangeRecord::TRangeRecord() 452 CFX_CTTGSUBTable::TRangeRecord::TRangeRecord()
464 : Start(0), End(0), StartCoverageIndex(0) {} 453 : Start(0), End(0), StartCoverageIndex(0) {}
465 454
466 CFX_CTTGSUBTable::TCoverageFormat2::TCoverageFormat2() 455 CFX_CTTGSUBTable::TCoverageFormat2::TCoverageFormat2()
467 : RangeCount(0), RangeRecord(nullptr) { 456 : TCoverageFormatBase(2), RangeCount(0) {}
468 CoverageFormat = 2;
469 }
470 457
471 CFX_CTTGSUBTable::TCoverageFormat2::~TCoverageFormat2() { 458 CFX_CTTGSUBTable::TCoverageFormat2::~TCoverageFormat2() {}
472 delete[] RangeRecord;
473 }
474
475 CFX_CTTGSUBTable::TClassDefFormat1::TClassDefFormat1()
476 : StartGlyph(0), GlyphCount(0), ClassValueArray(nullptr) {
477 ClassFormat = 1;
478 }
479
480 CFX_CTTGSUBTable::TClassDefFormat1::~TClassDefFormat1() {
481 delete[] ClassValueArray;
482 }
483
484 CFX_CTTGSUBTable::TClassDefFormat2::TClassDefFormat2()
485 : ClassRangeCount(0), ClassRangeRecord(nullptr) {
486 ClassFormat = 2;
487 }
488
489 CFX_CTTGSUBTable::TClassDefFormat2::~TClassDefFormat2() {
490 delete[] ClassRangeRecord;
491 }
492 459
493 CFX_CTTGSUBTable::TSingleSubstFormat1::TSingleSubstFormat1() 460 CFX_CTTGSUBTable::TSingleSubstFormat1::TSingleSubstFormat1()
494 : Coverage(nullptr), DeltaGlyphID(0) { 461 : TSubTableBase(1), DeltaGlyphID(0) {}
495 SubstFormat = 1;
496 }
497 462
498 CFX_CTTGSUBTable::TSingleSubstFormat1::~TSingleSubstFormat1() { 463 CFX_CTTGSUBTable::TSingleSubstFormat1::~TSingleSubstFormat1() {}
499 delete Coverage;
500 }
501 464
502 CFX_CTTGSUBTable::TSingleSubstFormat2::TSingleSubstFormat2() 465 CFX_CTTGSUBTable::TSingleSubstFormat2::TSingleSubstFormat2()
503 : Coverage(nullptr), GlyphCount(0), Substitute(nullptr) { 466 : TSubTableBase(2), GlyphCount(0) {}
504 SubstFormat = 2;
505 }
506 467
507 CFX_CTTGSUBTable::TSingleSubstFormat2::~TSingleSubstFormat2() { 468 CFX_CTTGSUBTable::TSingleSubstFormat2::~TSingleSubstFormat2() {}
508 delete Coverage;
509 delete[] Substitute;
510 }
511 469
512 CFX_CTTGSUBTable::TLookup::TLookup() 470 CFX_CTTGSUBTable::TLookup::TLookup()
513 : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(nullptr) {} 471 : LookupType(0), LookupFlag(0), SubTableCount(0) {}
514 472
515 CFX_CTTGSUBTable::TLookup::~TLookup() { 473 CFX_CTTGSUBTable::TLookup::~TLookup() {
516 if (SubTable) { 474 if (SubTable) {
517 for (int i = 0; i < SubTableCount; ++i) 475 for (int i = 0; i < SubTableCount; ++i)
518 delete SubTable[i]; 476 delete SubTable[i];
519 delete[] SubTable;
520 } 477 }
521 } 478 }
479
480 CFX_CTTGSUBTable::TScript::TScript() : DefaultLangSys(0), LangSysCount(0) {}
481
482 CFX_CTTGSUBTable::TScript::~TScript() {}
483
484 CFX_CTTGSUBTable::TScriptList::TScriptList() : ScriptCount(0) {}
485
486 CFX_CTTGSUBTable::TScriptList::~TScriptList() {}
487
488 CFX_CTTGSUBTable::TFeature::TFeature() : FeatureParams(0), LookupCount(0) {}
489
490 CFX_CTTGSUBTable::TFeature::~TFeature() {}
491
492 CFX_CTTGSUBTable::TFeatureList::TFeatureList() : FeatureCount(0) {}
493
494 CFX_CTTGSUBTable::TFeatureList::~TFeatureList() {}
495
496 CFX_CTTGSUBTable::TLookupList::TLookupList() : LookupCount(0) {}
497
498 CFX_CTTGSUBTable::TLookupList::~TLookupList() {}
499
500 CFX_CTTGSUBTable::TLangSys::TLangSys()
501 : LookupOrder(0), ReqFeatureIndex(0), FeatureCount(0) {}
502
503 CFX_CTTGSUBTable::TLangSys::~TLangSys() {}
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/ttgsubtable.h ('k') | core/fpdfapi/fpdf_page/cpdf_formobject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698