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

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

Issue 2248453002: Use a std::vector in fpdf_font code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 4 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
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp ('k') | core/fpdfapi/fpdf_font/cpdf_type3font.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/cpdf_type1font.h" 7 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
8 8
9 #include "core/fpdfapi/fpdf_font/font_int.h" 9 #include "core/fpdfapi/fpdf_font/font_int.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 #endif 166 #endif
167 return; 167 return;
168 } 168 }
169 } 169 }
170 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); 170 FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE);
171 if (m_BaseEncoding == 0) { 171 if (m_BaseEncoding == 0) {
172 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; 172 m_BaseEncoding = PDFFONT_ENCODING_STANDARD;
173 } 173 }
174 for (int charcode = 0; charcode < 256; charcode++) { 174 for (int charcode = 0; charcode < 256; charcode++) {
175 const FX_CHAR* name = 175 const FX_CHAR* name =
176 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 176 GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
177 if (!name) { 177 if (!name)
178 continue; 178 continue;
179 } 179
180 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 180 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
181 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( 181 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
182 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]); 182 m_Font.GetFace(), m_Encoding.m_Unicodes[charcode]);
183 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 183 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
184 FX_CHAR name_glyph[256]; 184 FX_CHAR name_glyph[256];
185 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph, 185 FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph,
186 256); 186 256);
187 name_glyph[255] = 0; 187 name_glyph[255] = 0;
188 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 188 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
189 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII, 189 kCFAllocatorDefault, name_glyph, kCFStringEncodingASCII,
(...skipping 28 matching lines...) Expand all
218 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); 218 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256);
219 #endif 219 #endif
220 return; 220 return;
221 } 221 }
222 FT_UseType1Charmap(m_Font.GetFace()); 222 FT_UseType1Charmap(m_Font.GetFace());
223 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 223 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
224 if (bCoreText) { 224 if (bCoreText) {
225 if (m_Flags & PDFFONT_SYMBOLIC) { 225 if (m_Flags & PDFFONT_SYMBOLIC) {
226 for (int charcode = 0; charcode < 256; charcode++) { 226 for (int charcode = 0; charcode < 256; charcode++) {
227 const FX_CHAR* name = 227 const FX_CHAR* name =
228 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 228 GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
229 if (name) { 229 if (name) {
230 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 230 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
231 m_GlyphIndex[charcode] = 231 m_GlyphIndex[charcode] =
232 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); 232 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
233 CFStringRef name_ct = CFStringCreateWithCStringNoCopy( 233 CFStringRef name_ct = CFStringCreateWithCStringNoCopy(
234 kCFAllocatorDefault, name, kCFStringEncodingASCII, 234 kCFAllocatorDefault, name, kCFStringEncodingASCII,
235 kCFAllocatorNull); 235 kCFAllocatorNull);
236 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 236 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
237 (CGFontRef)m_Font.GetPlatformFont(), name_ct); 237 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
238 if (name_ct) { 238 if (name_ct) {
(...skipping 27 matching lines...) Expand all
266 } 266 }
267 } 267 }
268 return; 268 return;
269 } 269 }
270 FX_BOOL bUnicode = FALSE; 270 FX_BOOL bUnicode = FALSE;
271 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { 271 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) {
272 bUnicode = TRUE; 272 bUnicode = TRUE;
273 } 273 }
274 for (int charcode = 0; charcode < 256; charcode++) { 274 for (int charcode = 0; charcode < 256; charcode++) {
275 const FX_CHAR* name = 275 const FX_CHAR* name =
276 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 276 GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
277 if (!name) { 277 if (!name) {
278 continue; 278 continue;
279 } 279 }
280 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 280 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
281 const FX_CHAR* pStrUnicode = GlyphNameRemap(name); 281 const FX_CHAR* pStrUnicode = GlyphNameRemap(name);
282 if (pStrUnicode && 282 if (pStrUnicode &&
283 0 == FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name)) { 283 0 == FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name)) {
284 name = pStrUnicode; 284 name = pStrUnicode;
285 } 285 }
286 m_GlyphIndex[charcode] = 286 m_GlyphIndex[charcode] =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName( 324 m_ExtGID[charcode] = CGFontGetGlyphWithGlyphName(
325 (CGFontRef)m_Font.GetPlatformFont(), name_ct); 325 (CGFontRef)m_Font.GetPlatformFont(), name_ct);
326 if (name_ct) { 326 if (name_ct) {
327 CFRelease(name_ct); 327 CFRelease(name_ct);
328 } 328 }
329 } 329 }
330 } 330 }
331 } 331 }
332 return; 332 return;
333 } 333 }
334 #endif 334 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
335 if (m_Flags & PDFFONT_SYMBOLIC) { 335 if (m_Flags & PDFFONT_SYMBOLIC) {
336 for (int charcode = 0; charcode < 256; charcode++) { 336 for (int charcode = 0; charcode < 256; charcode++) {
337 const FX_CHAR* name = 337 const FX_CHAR* name =
338 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 338 GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
339 if (name) { 339 if (name) {
340 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 340 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
341 m_GlyphIndex[charcode] = 341 m_GlyphIndex[charcode] =
342 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); 342 FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
343 } else { 343 } else {
344 m_GlyphIndex[charcode] = 344 m_GlyphIndex[charcode] =
345 FXFT_Get_Char_Index(m_Font.GetFace(), charcode); 345 FXFT_Get_Char_Index(m_Font.GetFace(), charcode);
346 if (m_GlyphIndex[charcode]) { 346 if (m_GlyphIndex[charcode]) {
347 FX_WCHAR unicode = 347 FX_WCHAR unicode =
348 FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode); 348 FT_UnicodeFromCharCode(PDFFONT_ENCODING_STANDARD, charcode);
(...skipping 17 matching lines...) Expand all
366 366
367 #endif 367 #endif
368 return; 368 return;
369 } 369 }
370 FX_BOOL bUnicode = FALSE; 370 FX_BOOL bUnicode = FALSE;
371 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { 371 if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) {
372 bUnicode = TRUE; 372 bUnicode = TRUE;
373 } 373 }
374 for (int charcode = 0; charcode < 256; charcode++) { 374 for (int charcode = 0; charcode < 256; charcode++) {
375 const FX_CHAR* name = 375 const FX_CHAR* name =
376 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); 376 GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode);
377 if (!name) { 377 if (!name) {
378 continue; 378 continue;
379 } 379 }
380 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); 380 m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
381 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); 381 m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
382 if (m_GlyphIndex[charcode] == 0) { 382 if (m_GlyphIndex[charcode] == 0) {
383 if (FXSYS_strcmp(name, ".notdef") != 0 && 383 if (FXSYS_strcmp(name, ".notdef") != 0 &&
384 FXSYS_strcmp(name, "space") != 0) { 384 FXSYS_strcmp(name, "space") != 0) {
385 m_GlyphIndex[charcode] = FXFT_Get_Char_Index( 385 m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
386 m_Font.GetFace(), 386 m_Font.GetFace(),
387 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); 387 bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode);
388 } else { 388 } else {
389 m_Encoding.m_Unicodes[charcode] = 0x20; 389 m_Encoding.m_Unicodes[charcode] = 0x20;
390 m_GlyphIndex[charcode] = 0xffff; 390 m_GlyphIndex[charcode] = 0xffff;
391 } 391 }
392 } 392 }
393 } 393 }
394 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 394 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
395 if (!bCoreText) 395 if (!bCoreText)
396 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256); 396 FXSYS_memcpy(m_ExtGID, m_GlyphIndex, 256);
397 #endif 397 #endif
398 } 398 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp ('k') | core/fpdfapi/fpdf_font/cpdf_type3font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698