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

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

Issue 1298393003: Extern in .cpp file is a code smell, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rename, remove dead fn. 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
« no previous file with comments | « core/src/fxge/ge/fx_ge_font.cpp ('k') | core/src/fxge/ge/text_int.h » ('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 <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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 {g_FoxitSansBoldFontData, 16344}, 402 {g_FoxitSansBoldFontData, 16344},
403 {g_FoxitSansBoldItalicFontData, 16418}, 403 {g_FoxitSansBoldItalicFontData, 16418},
404 {g_FoxitSansItalicFontData, 16339}, 404 {g_FoxitSansItalicFontData, 16339},
405 {g_FoxitSerifFontData, 19469}, 405 {g_FoxitSerifFontData, 19469},
406 {g_FoxitSerifBoldFontData, 19395}, 406 {g_FoxitSerifBoldFontData, 19395},
407 {g_FoxitSerifBoldItalicFontData, 20733}, 407 {g_FoxitSerifBoldItalicFontData, 20733},
408 {g_FoxitSerifItalicFontData, 21227}, 408 {g_FoxitSerifItalicFontData, 21227},
409 {g_FoxitSymbolFontData, 16729}, 409 {g_FoxitSymbolFontData, 16729},
410 {g_FoxitDingbatsFontData, 29513}, 410 {g_FoxitDingbatsFontData, 29513},
411 }; 411 };
412 void _FPDFAPI_GetInternalFontData(int id,
413 const uint8_t*& data,
414 FX_DWORD& size) {
415 CFX_GEModule::Get()->GetFontMgr()->GetStandardFont(data, size, id);
416 }
417 FX_BOOL CFX_FontMgr::GetStandardFont(const uint8_t*& pFontData, 412 FX_BOOL CFX_FontMgr::GetStandardFont(const uint8_t*& pFontData,
418 FX_DWORD& size, 413 FX_DWORD& size,
419 int index) { 414 int index) {
420 if (index > 15 || index < 0) { 415 if (index > 15 || index < 0) {
421 return FALSE; 416 return FALSE;
422 } 417 }
423 { 418 {
424 if (index >= 14) { 419 if (index >= 14) {
425 if (index == 14) { 420 if (index == 14) {
426 pFontData = g_FoxitSerifMMFontData; 421 pFontData = g_FoxitSerifMMFontData;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 norm.Remove(' '); 469 norm.Remove(' ');
475 norm.Remove('-'); 470 norm.Remove('-');
476 norm.Remove(','); 471 norm.Remove(',');
477 int pos = norm.Find('+'); 472 int pos = norm.Find('+');
478 if (pos > 0) { 473 if (pos > 0) {
479 norm = norm.Left(pos); 474 norm = norm.Left(pos);
480 } 475 }
481 norm.MakeLower(); 476 norm.MakeLower();
482 return norm; 477 return norm;
483 } 478 }
484 CFX_ByteString _FPDF_GetNameFromTT(const uint8_t* name_table, 479 CFX_ByteString GetNameFromTT(const uint8_t* name_table, FX_DWORD name_id) {
485 FX_DWORD name_id) {
486 const uint8_t* ptr = name_table + 2; 480 const uint8_t* ptr = name_table + 2;
487 int name_count = GET_TT_SHORT(ptr); 481 int name_count = GET_TT_SHORT(ptr);
488 int string_offset = GET_TT_SHORT(ptr + 2); 482 int string_offset = GET_TT_SHORT(ptr + 2);
489 const uint8_t* string_ptr = name_table + string_offset; 483 const uint8_t* string_ptr = name_table + string_offset;
490 ptr += 4; 484 ptr += 4;
491 for (int i = 0; i < name_count; i++) { 485 for (int i = 0; i < name_count; i++) {
492 if (GET_TT_SHORT(ptr + 6) == name_id && GET_TT_SHORT(ptr) == 1 && 486 if (GET_TT_SHORT(ptr + 6) == name_id && GET_TT_SHORT(ptr) == 1 &&
493 GET_TT_SHORT(ptr + 2) == 0) { 487 GET_TT_SHORT(ptr + 2) == 0) {
494 return CFX_ByteStringC(string_ptr + GET_TT_SHORT(ptr + 10), 488 return CFX_ByteStringC(string_ptr + GET_TT_SHORT(ptr + 10),
495 GET_TT_SHORT(ptr + 8)); 489 GET_TT_SHORT(ptr + 8));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 537 }
544 CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) { 538 CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
545 if (m_pFontInfo == NULL) { 539 if (m_pFontInfo == NULL) {
546 CFX_ByteString(); 540 CFX_ByteString();
547 } 541 }
548 CFX_ByteString result; 542 CFX_ByteString result;
549 FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0); 543 FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0);
550 if (size) { 544 if (size) {
551 uint8_t* buffer = FX_Alloc(uint8_t, size); 545 uint8_t* buffer = FX_Alloc(uint8_t, size);
552 m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size); 546 m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size);
553 result = _FPDF_GetNameFromTT(buffer, 6); 547 result = GetNameFromTT(buffer, 6);
554 FX_Free(buffer); 548 FX_Free(buffer);
555 } 549 }
556 return result; 550 return result;
557 } 551 }
558 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { 552 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
559 if (m_pFontInfo == NULL) { 553 if (m_pFontInfo == NULL) {
560 return; 554 return;
561 } 555 }
562 if (m_CharsetArray.Find((FX_DWORD)charset) == -1) { 556 if (m_CharsetArray.Find((FX_DWORD)charset) == -1) {
563 m_CharsetArray.Add((FX_DWORD)charset); 557 m_CharsetArray.Add((FX_DWORD)charset);
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 m_Weight = 0; 1236 m_Weight = 0;
1243 m_bItalic = FALSE; 1237 m_bItalic = FALSE;
1244 m_PitchFamily = 0; 1238 m_PitchFamily = 0;
1245 } 1239 }
1246 CFontFileFaceInfo::~CFontFileFaceInfo() { 1240 CFontFileFaceInfo::~CFontFileFaceInfo() {
1247 if (m_Face) { 1241 if (m_Face) {
1248 FXFT_Done_Face(m_Face); 1242 FXFT_Done_Face(m_Face);
1249 } 1243 }
1250 m_Face = NULL; 1244 m_Face = NULL;
1251 } 1245 }
1252 extern FX_BOOL _LoadFile(FXFT_Library library,
1253 FXFT_Face* Face,
1254 IFX_FileRead* pFile,
1255 FXFT_Stream* stream);
1256 #if _FX_OS_ == _FX_ANDROID_ 1246 #if _FX_OS_ == _FX_ANDROID_
1257 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) { 1247 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) {
1258 return NULL; 1248 return NULL;
1259 } 1249 }
1260 #endif 1250 #endif
1261 CFX_FolderFontInfo::CFX_FolderFontInfo() {} 1251 CFX_FolderFontInfo::CFX_FolderFontInfo() {}
1262 CFX_FolderFontInfo::~CFX_FolderFontInfo() { 1252 CFX_FolderFontInfo::~CFX_FolderFontInfo() {
1263 for (const auto& pair : m_FontList) { 1253 for (const auto& pair : m_FontList) {
1264 delete pair.second; 1254 delete pair.second;
1265 } 1255 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 if (!FXSYS_fread(buffer, 12, 1, pFile)) { 1349 if (!FXSYS_fread(buffer, 12, 1, pFile)) {
1360 return; 1350 return;
1361 } 1351 }
1362 FX_DWORD nTables = GET_TT_SHORT(buffer + 4); 1352 FX_DWORD nTables = GET_TT_SHORT(buffer + 4);
1363 CFX_ByteString tables = _FPDF_ReadStringFromFile(pFile, nTables * 16); 1353 CFX_ByteString tables = _FPDF_ReadStringFromFile(pFile, nTables * 16);
1364 if (tables.IsEmpty()) { 1354 if (tables.IsEmpty()) {
1365 return; 1355 return;
1366 } 1356 }
1367 CFX_ByteString names = 1357 CFX_ByteString names =
1368 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); 1358 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65);
1369 CFX_ByteString facename = _FPDF_GetNameFromTT(names, 1); 1359 CFX_ByteString facename = GetNameFromTT(names, 1);
1370 CFX_ByteString style = _FPDF_GetNameFromTT(names, 2); 1360 CFX_ByteString style = GetNameFromTT(names, 2);
1371 if (style != "Regular") { 1361 if (style != "Regular") {
1372 facename += " " + style; 1362 facename += " " + style;
1373 } 1363 }
1374 if (m_FontList.find(facename) != m_FontList.end()) { 1364 if (m_FontList.find(facename) != m_FontList.end()) {
1375 return; 1365 return;
1376 } 1366 }
1377 CFX_FontFaceInfo* pInfo = 1367 CFX_FontFaceInfo* pInfo =
1378 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); 1368 new CFX_FontFaceInfo(path, facename, tables, offset, filesize);
1379 CFX_ByteString os2 = 1369 CFX_ByteString os2 =
1380 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); 1370 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 if (hFont == NULL) { 1466 if (hFont == NULL) {
1477 return FALSE; 1467 return FALSE;
1478 } 1468 }
1479 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; 1469 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont;
1480 name = pFont->m_FaceName; 1470 name = pFont->m_FaceName;
1481 return TRUE; 1471 return TRUE;
1482 } 1472 }
1483 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { 1473 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) {
1484 return FALSE; 1474 return FALSE;
1485 } 1475 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_font.cpp ('k') | core/src/fxge/ge/text_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698