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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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/font_int.h ('k') | core/fpdfapi/fpdf_font/fpdf_font_cid.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/font_int.h" 7 #include "core/fpdfapi/fpdf_font/font_int.h"
8 8
9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" 9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
10 #include "core/fpdfapi/fpdf_page/pageint.h" 10 #include "core/fpdfapi/fpdf_page/pageint.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 84
85 85
86 short TT2PDF(int m, FXFT_Face face) { 86 short TT2PDF(int m, FXFT_Face face) {
87 int upm = FXFT_Get_Face_UnitsPerEM(face); 87 int upm = FXFT_Get_Face_UnitsPerEM(face);
88 if (upm == 0) 88 if (upm == 0)
89 return (short)m; 89 return (short)m;
90 return (m * 1000 + upm / 2) / upm; 90 return (m * 1000 + upm / 2) / upm;
91 } 91 }
92 92
93 93 CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) {
94 CFX_WideString CPDF_ToUnicodeMap::Lookup(FX_DWORD charcode) {
95 auto it = m_Map.find(charcode); 94 auto it = m_Map.find(charcode);
96 if (it != m_Map.end()) { 95 if (it != m_Map.end()) {
97 FX_DWORD value = it->second; 96 uint32_t value = it->second;
98 FX_WCHAR unicode = (FX_WCHAR)(value & 0xffff); 97 FX_WCHAR unicode = (FX_WCHAR)(value & 0xffff);
99 if (unicode != 0xffff) { 98 if (unicode != 0xffff) {
100 return unicode; 99 return unicode;
101 } 100 }
102 const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer(); 101 const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer();
103 FX_DWORD buf_len = m_MultiCharBuf.GetLength(); 102 uint32_t buf_len = m_MultiCharBuf.GetLength();
104 if (!buf || buf_len == 0) { 103 if (!buf || buf_len == 0) {
105 return CFX_WideString(); 104 return CFX_WideString();
106 } 105 }
107 FX_DWORD index = value >> 16; 106 uint32_t index = value >> 16;
108 if (index >= buf_len) { 107 if (index >= buf_len) {
109 return CFX_WideString(); 108 return CFX_WideString();
110 } 109 }
111 FX_DWORD len = buf[index]; 110 uint32_t len = buf[index];
112 if (index + len < index || index + len >= buf_len) { 111 if (index + len < index || index + len >= buf_len) {
113 return CFX_WideString(); 112 return CFX_WideString();
114 } 113 }
115 return CFX_WideString(buf + index + 1, len); 114 return CFX_WideString(buf + index + 1, len);
116 } 115 }
117 if (m_pBaseMap) { 116 if (m_pBaseMap) {
118 return m_pBaseMap->UnicodeFromCID((uint16_t)charcode); 117 return m_pBaseMap->UnicodeFromCID((uint16_t)charcode);
119 } 118 }
120 return CFX_WideString(); 119 return CFX_WideString();
121 } 120 }
122 121
123 FX_DWORD CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) { 122 uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) {
124 for (const auto& pair : m_Map) { 123 for (const auto& pair : m_Map) {
125 if (pair.second == unicode) 124 if (pair.second == unicode)
126 return pair.first; 125 return pair.first;
127 } 126 }
128 return 0; 127 return 0;
129 } 128 }
130 129
131 // Static. 130 // Static.
132 FX_DWORD CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) { 131 uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) {
133 const FX_CHAR* buf = str.GetCStr(); 132 const FX_CHAR* buf = str.GetCStr();
134 int len = str.GetLength(); 133 int len = str.GetLength();
135 if (len == 0) 134 if (len == 0)
136 return 0; 135 return 0;
137 136
138 int result = 0; 137 int result = 0;
139 if (buf[0] == '<') { 138 if (buf[0] == '<') {
140 for (int i = 1; i < len && std::isxdigit(buf[i]); ++i) 139 for (int i = 1; i < len && std::isxdigit(buf[i]); ++i)
141 result = result * 16 + FXSYS_toHexDigit(buf[i]); 140 result = result * 16 + FXSYS_toHexDigit(buf[i]);
142 return result; 141 return result;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 CFX_ByteStringC word = parser.GetWord(); 201 CFX_ByteStringC word = parser.GetWord();
203 if (word.IsEmpty()) { 202 if (word.IsEmpty()) {
204 break; 203 break;
205 } 204 }
206 if (word == "beginbfchar") { 205 if (word == "beginbfchar") {
207 while (1) { 206 while (1) {
208 word = parser.GetWord(); 207 word = parser.GetWord();
209 if (word.IsEmpty() || word == "endbfchar") { 208 if (word.IsEmpty() || word == "endbfchar") {
210 break; 209 break;
211 } 210 }
212 FX_DWORD srccode = StringToCode(word); 211 uint32_t srccode = StringToCode(word);
213 word = parser.GetWord(); 212 word = parser.GetWord();
214 CFX_WideString destcode = StringToWideString(word); 213 CFX_WideString destcode = StringToWideString(word);
215 int len = destcode.GetLength(); 214 int len = destcode.GetLength();
216 if (len == 0) { 215 if (len == 0) {
217 continue; 216 continue;
218 } 217 }
219 if (len == 1) { 218 if (len == 1) {
220 m_Map[srccode] = destcode.GetAt(0); 219 m_Map[srccode] = destcode.GetAt(0);
221 } else { 220 } else {
222 m_Map[srccode] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff; 221 m_Map[srccode] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff;
223 m_MultiCharBuf.AppendChar(destcode.GetLength()); 222 m_MultiCharBuf.AppendChar(destcode.GetLength());
224 m_MultiCharBuf << destcode; 223 m_MultiCharBuf << destcode;
225 } 224 }
226 } 225 }
227 } else if (word == "beginbfrange") { 226 } else if (word == "beginbfrange") {
228 while (1) { 227 while (1) {
229 CFX_ByteString low, high; 228 CFX_ByteString low, high;
230 low = parser.GetWord(); 229 low = parser.GetWord();
231 if (low.IsEmpty() || low == "endbfrange") { 230 if (low.IsEmpty() || low == "endbfrange") {
232 break; 231 break;
233 } 232 }
234 high = parser.GetWord(); 233 high = parser.GetWord();
235 FX_DWORD lowcode = StringToCode(low); 234 uint32_t lowcode = StringToCode(low);
236 FX_DWORD highcode = 235 uint32_t highcode =
237 (lowcode & 0xffffff00) | (StringToCode(high) & 0xff); 236 (lowcode & 0xffffff00) | (StringToCode(high) & 0xff);
238 if (highcode == (FX_DWORD)-1) { 237 if (highcode == (uint32_t)-1) {
239 break; 238 break;
240 } 239 }
241 CFX_ByteString start = parser.GetWord(); 240 CFX_ByteString start = parser.GetWord();
242 if (start == "[") { 241 if (start == "[") {
243 for (FX_DWORD code = lowcode; code <= highcode; code++) { 242 for (uint32_t code = lowcode; code <= highcode; code++) {
244 CFX_ByteString dest = parser.GetWord(); 243 CFX_ByteString dest = parser.GetWord();
245 CFX_WideString destcode = StringToWideString(dest); 244 CFX_WideString destcode = StringToWideString(dest);
246 int len = destcode.GetLength(); 245 int len = destcode.GetLength();
247 if (len == 0) { 246 if (len == 0) {
248 continue; 247 continue;
249 } 248 }
250 if (len == 1) { 249 if (len == 1) {
251 m_Map[code] = destcode.GetAt(0); 250 m_Map[code] = destcode.GetAt(0);
252 } else { 251 } else {
253 m_Map[code] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff; 252 m_Map[code] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff;
254 m_MultiCharBuf.AppendChar(destcode.GetLength()); 253 m_MultiCharBuf.AppendChar(destcode.GetLength());
255 m_MultiCharBuf << destcode; 254 m_MultiCharBuf << destcode;
256 } 255 }
257 } 256 }
258 parser.GetWord(); 257 parser.GetWord();
259 } else { 258 } else {
260 CFX_WideString destcode = StringToWideString(start); 259 CFX_WideString destcode = StringToWideString(start);
261 int len = destcode.GetLength(); 260 int len = destcode.GetLength();
262 FX_DWORD value = 0; 261 uint32_t value = 0;
263 if (len == 1) { 262 if (len == 1) {
264 value = StringToCode(start); 263 value = StringToCode(start);
265 for (FX_DWORD code = lowcode; code <= highcode; code++) { 264 for (uint32_t code = lowcode; code <= highcode; code++) {
266 m_Map[code] = value++; 265 m_Map[code] = value++;
267 } 266 }
268 } else { 267 } else {
269 for (FX_DWORD code = lowcode; code <= highcode; code++) { 268 for (uint32_t code = lowcode; code <= highcode; code++) {
270 CFX_WideString retcode; 269 CFX_WideString retcode;
271 if (code == lowcode) { 270 if (code == lowcode) {
272 retcode = destcode; 271 retcode = destcode;
273 } else { 272 } else {
274 retcode = StringDataAdd(destcode); 273 retcode = StringDataAdd(destcode);
275 } 274 }
276 m_Map[code] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff; 275 m_Map[code] = m_MultiCharBuf.GetLength() * 0x10000 + 0xffff;
277 m_MultiCharBuf.AppendChar(retcode.GetLength()); 276 m_MultiCharBuf.AppendChar(retcode.GetLength());
278 m_MultiCharBuf << retcode; 277 m_MultiCharBuf << retcode;
279 destcode = retcode; 278 destcode = retcode;
(...skipping 13 matching lines...) Expand all
293 } 292 }
294 if (cid_set) { 293 if (cid_set) {
295 m_pBaseMap = CPDF_ModuleMgr::Get() 294 m_pBaseMap = CPDF_ModuleMgr::Get()
296 ->GetPageModule() 295 ->GetPageModule()
297 ->GetFontGlobals() 296 ->GetFontGlobals()
298 ->m_CMapManager.GetCID2UnicodeMap(cid_set, FALSE); 297 ->m_CMapManager.GetCID2UnicodeMap(cid_set, FALSE);
299 } else { 298 } else {
300 m_pBaseMap = NULL; 299 m_pBaseMap = NULL;
301 } 300 }
302 } 301 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/font_int.h ('k') | core/fpdfapi/fpdf_font/fpdf_font_cid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698