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

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

Issue 1289703003: FX_CMapDwordToDword considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 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 #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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 for (int k = 0; 78 for (int k = 0;
79 k < ((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j) 79 k < ((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j)
80 ->LangSys.FeatureCount; 80 ->LangSys.FeatureCount;
81 ++k) { 81 ++k) {
82 FX_DWORD index = 82 FX_DWORD index =
83 *(((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j) 83 *(((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j)
84 ->LangSys.FeatureIndex + 84 ->LangSys.FeatureIndex +
85 k); 85 k);
86 if (FeatureList.FeatureRecord[index].FeatureTag == tag[0] || 86 if (FeatureList.FeatureRecord[index].FeatureTag == tag[0] ||
87 FeatureList.FeatureRecord[index].FeatureTag == tag[1]) { 87 FeatureList.FeatureRecord[index].FeatureTag == tag[1]) {
88 FX_DWORD value; 88 if (m_featureMap.find(index) == m_featureMap.end()) {
89 if (!m_featureMap.Lookup(index, value)) { 89 m_featureMap[index] = index;
90 m_featureMap.SetAt(index, index);
91 } 90 }
92 } 91 }
93 } 92 }
94 } 93 }
95 } 94 }
96 if (!m_featureMap.GetStartPosition()) { 95 if (m_featureMap.empty()) {
97 for (int i = 0; i < FeatureList.FeatureCount; i++) { 96 for (int i = 0; i < FeatureList.FeatureCount; i++) {
98 if (FeatureList.FeatureRecord[i].FeatureTag == tag[0] || 97 if (FeatureList.FeatureRecord[i].FeatureTag == tag[0] ||
99 FeatureList.FeatureRecord[i].FeatureTag == tag[1]) { 98 FeatureList.FeatureRecord[i].FeatureTag == tag[1]) {
100 FX_DWORD value; 99 if (m_featureMap.find(i) == m_featureMap.end()) {
Lei Zhang 2015/08/17 23:45:13 Assuming we started with an empty map on line 95 a
Tom Sepez 2015/08/18 16:21:42 Indeed it will.
101 if (!m_featureMap.Lookup(i, value)) { 100 m_featureMap[i] = i;
102 m_featureMap.SetAt(i, i);
103 } 101 }
104 } 102 }
105 } 103 }
106 } 104 }
107 m_bFeautureMapLoad = TRUE; 105 m_bFeautureMapLoad = TRUE;
108 } 106 }
109 FX_POSITION pos = m_featureMap.GetStartPosition(); 107 for (const auto& pair : m_featureMap) {
110 while (pos) {
111 FX_DWORD index, value;
112 m_featureMap.GetNextAssoc(pos, index, value);
113 if (GetVerticalGlyphSub(glyphnum, vglyphnum, 108 if (GetVerticalGlyphSub(glyphnum, vglyphnum,
114 &FeatureList.FeatureRecord[value].Feature)) { 109 &FeatureList.FeatureRecord[pair.second].Feature)) {
115 return true; 110 return true;
116 } 111 }
117 } 112 }
118 return false; 113 return false;
119 } 114 }
120 bool CFX_CTTGSUBTable::GetVerticalGlyphSub(TT_uint32_t glyphnum, 115 bool CFX_CTTGSUBTable::GetVerticalGlyphSub(TT_uint32_t glyphnum,
121 TT_uint32_t* vglyphnum, 116 TT_uint32_t* vglyphnum,
122 struct TFeature* Feature) { 117 struct TFeature* Feature) {
123 for (int i = 0; i < Feature->LookupCount; i++) { 118 for (int i = 0; i < Feature->LookupCount; i++) {
124 int index = Feature->LookupListIndex[i]; 119 int index = Feature->LookupListIndex[i];
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 FXFT_Load_Sfnt_Table(pFont->m_Face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, 405 FXFT_Load_Sfnt_Table(pFont->m_Face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0,
411 pFont->m_pGsubData, NULL); 406 pFont->m_pGsubData, NULL);
412 if (!error && pFont->m_pGsubData) { 407 if (!error && pFont->m_pGsubData) {
413 nonstd::unique_ptr<CFX_GSUBTable> pGsubTable(new CFX_GSUBTable); 408 nonstd::unique_ptr<CFX_GSUBTable> pGsubTable(new CFX_GSUBTable);
414 if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->m_pGsubData)) { 409 if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->m_pGsubData)) {
415 return pGsubTable.release(); 410 return pGsubTable.release();
416 } 411 }
417 } 412 }
418 return NULL; 413 return NULL;
419 } 414 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/ttgsubtable.h ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698