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

Side by Side Diff: core/src/fxge/ge/fx_ge_fontmap.cpp

Issue 1294933008: Merge to XFA: Extern in .cpp file is a code smell, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: IWYU 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 <limits> 7 #include <limits>
8 8
9 #include "../../../include/fxge/fx_ge.h" 9 #include "../../../include/fxge/fx_ge.h"
10 #include "../../../include/fxge/fx_freetype.h" 10 #include "../../../include/fxge/fx_freetype.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 {g_FoxitSansBoldFontData, 16344}, 416 {g_FoxitSansBoldFontData, 16344},
417 {g_FoxitSansBoldItalicFontData, 16418}, 417 {g_FoxitSansBoldItalicFontData, 16418},
418 {g_FoxitSansItalicFontData, 16339}, 418 {g_FoxitSansItalicFontData, 16339},
419 {g_FoxitSerifFontData, 19469}, 419 {g_FoxitSerifFontData, 19469},
420 {g_FoxitSerifBoldFontData, 19395}, 420 {g_FoxitSerifBoldFontData, 19395},
421 {g_FoxitSerifBoldItalicFontData, 20733}, 421 {g_FoxitSerifBoldItalicFontData, 20733},
422 {g_FoxitSerifItalicFontData, 21227}, 422 {g_FoxitSerifItalicFontData, 21227},
423 {g_FoxitSymbolFontData, 16729}, 423 {g_FoxitSymbolFontData, 16729},
424 {g_FoxitDingbatsFontData, 29513}, 424 {g_FoxitDingbatsFontData, 29513},
425 }; 425 };
426 void _FPDFAPI_GetInternalFontData(int id,
427 const uint8_t*& data,
428 FX_DWORD& size) {
429 CFX_GEModule::Get()->GetFontMgr()->GetStandardFont(data, size, id);
430 }
431 FX_BOOL CFX_FontMgr::GetStandardFont(const uint8_t*& pFontData, 426 FX_BOOL CFX_FontMgr::GetStandardFont(const uint8_t*& pFontData,
432 FX_DWORD& size, 427 FX_DWORD& size,
433 int index) { 428 int index) {
434 if (index > 15 || index < 0) { 429 if (index > 15 || index < 0) {
435 return FALSE; 430 return FALSE;
436 } 431 }
437 { 432 {
438 if (index >= 14) { 433 if (index >= 14) {
439 if (index == 14) { 434 if (index == 14) {
440 pFontData = g_FoxitSerifMMFontData; 435 pFontData = g_FoxitSerifMMFontData;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 norm.Remove(' '); 483 norm.Remove(' ');
489 norm.Remove('-'); 484 norm.Remove('-');
490 norm.Remove(','); 485 norm.Remove(',');
491 int pos = norm.Find('+'); 486 int pos = norm.Find('+');
492 if (pos > 0) { 487 if (pos > 0) {
493 norm = norm.Left(pos); 488 norm = norm.Left(pos);
494 } 489 }
495 norm.MakeLower(); 490 norm.MakeLower();
496 return norm; 491 return norm;
497 } 492 }
498 CFX_ByteString _FPDF_GetNameFromTT(const uint8_t* name_table, 493 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name_id) {
499 FX_DWORD name_id) {
500 const uint8_t* ptr = name_table + 2; 494 const uint8_t* ptr = name_table + 2;
501 int name_count = GET_TT_SHORT(ptr); 495 int name_count = GET_TT_SHORT(ptr);
502 int string_offset = GET_TT_SHORT(ptr + 2); 496 int string_offset = GET_TT_SHORT(ptr + 2);
503 const uint8_t* string_ptr = name_table + string_offset; 497 const uint8_t* string_ptr = name_table + string_offset;
504 ptr += 4; 498 ptr += 4;
505 for (int i = 0; i < name_count; i++) { 499 for (int i = 0; i < name_count; i++) {
506 if (GET_TT_SHORT(ptr + 6) == name_id && GET_TT_SHORT(ptr) == 1 && 500 if (GET_TT_SHORT(ptr + 6) == name_id && GET_TT_SHORT(ptr) == 1 &&
507 GET_TT_SHORT(ptr + 2) == 0) { 501 GET_TT_SHORT(ptr + 2) == 0) {
508 return CFX_ByteStringC(string_ptr + GET_TT_SHORT(ptr + 10), 502 return CFX_ByteStringC(string_ptr + GET_TT_SHORT(ptr + 10),
509 GET_TT_SHORT(ptr + 8)); 503 GET_TT_SHORT(ptr + 8));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 551 }
558 CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) { 552 CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
559 if (m_pFontInfo == NULL) { 553 if (m_pFontInfo == NULL) {
560 CFX_ByteString(); 554 CFX_ByteString();
561 } 555 }
562 CFX_ByteString result; 556 CFX_ByteString result;
563 FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0); 557 FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0);
564 if (size) { 558 if (size) {
565 uint8_t* buffer = FX_Alloc(uint8_t, size); 559 uint8_t* buffer = FX_Alloc(uint8_t, size);
566 m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size); 560 m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size);
567 result = _FPDF_GetNameFromTT(buffer, 6); 561 result = GetNameFromTT(buffer, 6);
568 FX_Free(buffer); 562 FX_Free(buffer);
569 } 563 }
570 return result; 564 return result;
571 } 565 }
572 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { 566 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
573 if (m_pFontInfo == NULL) { 567 if (m_pFontInfo == NULL) {
574 return; 568 return;
575 } 569 }
576 if (m_CharsetArray.Find((FX_DWORD)charset) == -1) { 570 if (m_CharsetArray.Find((FX_DWORD)charset) == -1) {
577 m_CharsetArray.Add((FX_DWORD)charset); 571 m_CharsetArray.Add((FX_DWORD)charset);
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 m_Weight = 0; 1335 m_Weight = 0;
1342 m_bItalic = FALSE; 1336 m_bItalic = FALSE;
1343 m_PitchFamily = 0; 1337 m_PitchFamily = 0;
1344 } 1338 }
1345 CFontFileFaceInfo::~CFontFileFaceInfo() { 1339 CFontFileFaceInfo::~CFontFileFaceInfo() {
1346 if (m_Face) { 1340 if (m_Face) {
1347 FXFT_Done_Face(m_Face); 1341 FXFT_Done_Face(m_Face);
1348 } 1342 }
1349 m_Face = NULL; 1343 m_Face = NULL;
1350 } 1344 }
1351 extern FX_BOOL _LoadFile(FXFT_Library library,
1352 FXFT_Face* Face,
1353 IFX_FileRead* pFile,
1354 FXFT_Stream* stream);
1355 #if _FX_OS_ == _FX_ANDROID_ 1345 #if _FX_OS_ == _FX_ANDROID_
1356 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() { 1346 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() {
1357 return NULL; 1347 return NULL;
1358 } 1348 }
1359 #endif 1349 #endif
1360 CFX_FolderFontInfo::CFX_FolderFontInfo() {} 1350 CFX_FolderFontInfo::CFX_FolderFontInfo() {}
1361 CFX_FolderFontInfo::~CFX_FolderFontInfo() { 1351 CFX_FolderFontInfo::~CFX_FolderFontInfo() {
1362 for (const auto& pair : m_FontList) { 1352 for (const auto& pair : m_FontList) {
1363 delete pair.second; 1353 delete pair.second;
1364 } 1354 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 if (!FXSYS_fread(buffer, 12, 1, pFile)) { 1448 if (!FXSYS_fread(buffer, 12, 1, pFile)) {
1459 return; 1449 return;
1460 } 1450 }
1461 FX_DWORD nTables = GET_TT_SHORT(buffer + 4); 1451 FX_DWORD nTables = GET_TT_SHORT(buffer + 4);
1462 CFX_ByteString tables = _FPDF_ReadStringFromFile(pFile, nTables * 16); 1452 CFX_ByteString tables = _FPDF_ReadStringFromFile(pFile, nTables * 16);
1463 if (tables.IsEmpty()) { 1453 if (tables.IsEmpty()) {
1464 return; 1454 return;
1465 } 1455 }
1466 CFX_ByteString names = 1456 CFX_ByteString names =
1467 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); 1457 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65);
1468 CFX_ByteString facename = _FPDF_GetNameFromTT(names, 1); 1458 CFX_ByteString facename = GetNameFromTT(names, 1);
1469 CFX_ByteString style = _FPDF_GetNameFromTT(names, 2); 1459 CFX_ByteString style = GetNameFromTT(names, 2);
1470 if (style != "Regular") { 1460 if (style != "Regular") {
1471 facename += " " + style; 1461 facename += " " + style;
1472 } 1462 }
1473 if (m_FontList.find(facename) != m_FontList.end()) { 1463 if (m_FontList.find(facename) != m_FontList.end()) {
1474 return; 1464 return;
1475 } 1465 }
1476 CFX_FontFaceInfo* pInfo = 1466 CFX_FontFaceInfo* pInfo =
1477 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); 1467 new CFX_FontFaceInfo(path, facename, tables, offset, filesize);
1478 CFX_ByteString os2 = 1468 CFX_ByteString os2 =
1479 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); 1469 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 if (hFont == NULL) { 1571 if (hFont == NULL) {
1582 return FALSE; 1572 return FALSE;
1583 } 1573 }
1584 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; 1574 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont;
1585 name = pFont->m_FaceName; 1575 name = pFont->m_FaceName;
1586 return TRUE; 1576 return TRUE;
1587 } 1577 }
1588 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { 1578 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) {
1589 return FALSE; 1579 return FALSE;
1590 } 1580 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698