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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 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/src/fpdfapi/fpdf_font/ttgsubtable.h ('k') | core/src/fpdfapi/fpdf_page/fpdf_page.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 "../../../../third_party/base/nonstd_unique_ptr.h" 7 #include "../../../../third_party/base/nonstd_unique_ptr.h"
8 #include "../../../include/fxge/fx_ge.h" 8 #include "../../../include/fxge/fx_ge.h"
9 #include "../../../include/fxge/fx_freetype.h" 9 #include "../../../include/fxge/fx_freetype.h"
10 #include "ttgsubtable.h" 10 #include "ttgsubtable.h"
(...skipping 30 matching lines...) Expand all
41 low = mid + 1; 41 low = mid + 1;
42 } else if (buf[mid].key > key) { 42 } else if (buf[mid].key > key) {
43 high = mid - 1; 43 high = mid - 1;
44 } else { 44 } else {
45 buf[mid].value = value; 45 buf[mid].value = value;
46 return; 46 return;
47 } 47 }
48 } 48 }
49 m_Buffer.InsertBlock(low * sizeof(_IntPair), &pair, sizeof(_IntPair)); 49 m_Buffer.InsertBlock(low * sizeof(_IntPair), &pair, sizeof(_IntPair));
50 } 50 }
51 FX_BOOL CFX_GlyphMap::Lookup(int key, int &value) 51 bool CFX_GlyphMap::Lookup(int key, int &value)
52 { 52 {
53 void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(), m_Buffer.GetSize() / sizeof(_IntPair), 53 void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(), m_Buffer.GetSize() / sizeof(_IntPair),
54 sizeof(_IntPair), _CompareInt); 54 sizeof(_IntPair), _CompareInt);
55 if (pResult == NULL) { 55 if (pResult == NULL) {
56 return FALSE; 56 return false;
57 } 57 }
58 value = ((FX_DWORD*)pResult)[1]; 58 value = ((FX_DWORD*)pResult)[1];
59 return TRUE; 59 return true;
60 } 60 }
61 bool CFX_CTTGSUBTable::LoadGSUBTable(FT_Bytes gsub) 61 bool CFX_CTTGSUBTable::LoadGSUBTable(FT_Bytes gsub)
62 { 62 {
63 header.Version = gsub[0] << 24 | gsub[1] << 16 | gsub[2] << 8 | gsub[3]; 63 header.Version = gsub[0] << 24 | gsub[1] << 16 | gsub[2] << 8 | gsub[3];
64 if(header.Version != 0x00010000) { 64 if(header.Version != 0x00010000) {
65 return false; 65 return false;
66 } 66 }
67 header.ScriptList = gsub[4] << 8 | gsub[5]; 67 header.ScriptList = gsub[4] << 8 | gsub[5];
68 header.FeatureList = gsub[6] << 8 | gsub[7]; 68 header.FeatureList = gsub[6] << 8 | gsub[7];
69 header.LookupList = gsub[8] << 8 | gsub[9]; 69 header.LookupList = gsub[8] << 8 | gsub[9];
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (!m_featureMap.GetStartPosition()) { 101 if (!m_featureMap.GetStartPosition()) {
102 for (int i = 0; i < FeatureList.FeatureCount; i ++) { 102 for (int i = 0; i < FeatureList.FeatureCount; i ++) {
103 if (FeatureList.FeatureRecord[i].FeatureTag == tag[0] || Feature List.FeatureRecord[i].FeatureTag == tag[1]) { 103 if (FeatureList.FeatureRecord[i].FeatureTag == tag[0] || Feature List.FeatureRecord[i].FeatureTag == tag[1]) {
104 FX_DWORD value; 104 FX_DWORD value;
105 if (!m_featureMap.Lookup(i, value)) { 105 if (!m_featureMap.Lookup(i, value)) {
106 m_featureMap.SetAt(i, i); 106 m_featureMap.SetAt(i, i);
107 } 107 }
108 } 108 }
109 } 109 }
110 } 110 }
111 m_bFeautureMapLoad = TRUE; 111 m_bFeautureMapLoad = true;
112 } 112 }
113 FX_POSITION pos = m_featureMap.GetStartPosition(); 113 FX_POSITION pos = m_featureMap.GetStartPosition();
114 while (pos) { 114 while (pos) {
115 FX_DWORD index, value; 115 FX_DWORD index, value;
116 m_featureMap.GetNextAssoc(pos, index, value); 116 m_featureMap.GetNextAssoc(pos, index, value);
117 if(GetVerticalGlyphSub(glyphnum, vglyphnum, &FeatureList.FeatureReco rd[value].Feature)) { 117 if(GetVerticalGlyphSub(glyphnum, vglyphnum, &FeatureList.FeatureReco rd[value].Feature)) {
118 return true; 118 return true;
119 } 119 }
120 } 120 }
121 return false; 121 return false;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 &rec->Coverage); 413 &rec->Coverage);
414 rec->GlyphCount = GetUInt16(sp); 414 rec->GlyphCount = GetUInt16(sp);
415 if(rec->GlyphCount <= 0) { 415 if(rec->GlyphCount <= 0) {
416 return; 416 return;
417 } 417 }
418 rec->Substitute = new TT_uint16_t[rec->GlyphCount]; 418 rec->Substitute = new TT_uint16_t[rec->GlyphCount];
419 for(i = 0; i < rec->GlyphCount; i++) { 419 for(i = 0; i < rec->GlyphCount; i++) {
420 rec->Substitute[i] = GetUInt16(sp); 420 rec->Substitute[i] = GetUInt16(sp);
421 } 421 }
422 } 422 }
423 FX_BOOL CFX_GSUBTable::GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum) 423 bool CFX_GSUBTable::GetVerticalGlyph(FX_DWORD glyphnum, FX_DWORD* vglyphnum)
424 { 424 {
425 return m_GsubImp.GetVerticalGlyph(glyphnum, vglyphnum); 425 return m_GsubImp.GetVerticalGlyph(glyphnum, vglyphnum);
426 } 426 }
427 // static 427 // static
428 IFX_GSUBTable* IFX_GSUBTable::Create(CFX_Font* pFont) 428 IFX_GSUBTable* IFX_GSUBTable::Create(CFX_Font* pFont)
429 { 429 {
430 if (!pFont) { 430 if (!pFont) {
431 return NULL; 431 return NULL;
432 } 432 }
433 if (NULL == pFont->m_pGsubData) { 433 if (NULL == pFont->m_pGsubData) {
434 unsigned long length = 0; 434 unsigned long length = 0;
435 int error = FXFT_Load_Sfnt_Table(pFont->m_Face, FT_MAKE_TAG('G', 'S', 'U ', 'B'), 0, NULL, &length); 435 int error = FXFT_Load_Sfnt_Table(pFont->m_Face, FT_MAKE_TAG('G', 'S', 'U ', 'B'), 0, NULL, &length);
436 if (!error) { 436 if (!error) {
437 pFont->m_pGsubData = (unsigned char*)FX_Alloc(uint8_t, length); 437 pFont->m_pGsubData = (unsigned char*)FX_Alloc(uint8_t, length);
438 } 438 }
439 if (!pFont->m_pGsubData) { 439 if (!pFont->m_pGsubData) {
440 return NULL; 440 return NULL;
441 } 441 }
442 } 442 }
443 int error = FXFT_Load_Sfnt_Table(pFont->m_Face, FT_MAKE_TAG('G', 'S', 'U', ' B'), 0, pFont->m_pGsubData, NULL); 443 int error = FXFT_Load_Sfnt_Table(pFont->m_Face, FT_MAKE_TAG('G', 'S', 'U', ' B'), 0, pFont->m_pGsubData, NULL);
444 if (!error && pFont->m_pGsubData) { 444 if (!error && pFont->m_pGsubData) {
445 nonstd::unique_ptr<CFX_GSUBTable> pGsubTable(new CFX_GSUBTable); 445 nonstd::unique_ptr<CFX_GSUBTable> pGsubTable(new CFX_GSUBTable);
446 if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->m_pGsubData)) { 446 if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->m_pGsubData)) {
447 return pGsubTable.release(); 447 return pGsubTable.release();
448 } 448 }
449 } 449 }
450 return NULL; 450 return NULL;
451 } 451 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/ttgsubtable.h ('k') | core/src/fpdfapi/fpdf_page/fpdf_page.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698