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

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

Issue 1868293002: Make converstion explicit from CFX_ByteString to uint8_t* (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/fxcrt/include/fx_string.h ('k') | fpdfsdk/fpdf_flatten.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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 if (!m_pFontInfo) { 744 if (!m_pFontInfo) {
745 return; 745 return;
746 } 746 }
747 if (m_CharsetArray.Find((uint32_t)charset) == -1) { 747 if (m_CharsetArray.Find((uint32_t)charset) == -1) {
748 m_CharsetArray.Add((uint32_t)charset); 748 m_CharsetArray.Add((uint32_t)charset);
749 m_FaceArray.push_back(name); 749 m_FaceArray.push_back(name);
750 } 750 }
751 if (name == m_LastFamily) { 751 if (name == m_LastFamily) {
752 return; 752 return;
753 } 753 }
754 const uint8_t* ptr = name; 754 const uint8_t* ptr = name.raw_str();
755 FX_BOOL bLocalized = FALSE; 755 FX_BOOL bLocalized = FALSE;
756 for (int i = 0; i < name.GetLength(); i++) 756 for (int i = 0; i < name.GetLength(); i++)
757 if (ptr[i] > 0x80) { 757 if (ptr[i] > 0x80) {
758 bLocalized = TRUE; 758 bLocalized = TRUE;
759 break; 759 break;
760 } 760 }
761 if (bLocalized) { 761 if (bLocalized) {
762 void* hFont = m_pFontInfo->GetFont(name); 762 void* hFont = m_pFontInfo->GetFont(name);
763 if (!hFont) { 763 if (!hFont) {
764 int iExact; 764 int iExact;
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 char buffer[16]; 1457 char buffer[16];
1458 if (!FXSYS_fread(buffer, 12, 1, pFile)) { 1458 if (!FXSYS_fread(buffer, 12, 1, pFile)) {
1459 return; 1459 return;
1460 } 1460 }
1461 uint32_t nTables = GET_TT_SHORT(buffer + 4); 1461 uint32_t nTables = GET_TT_SHORT(buffer + 4);
1462 CFX_ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16); 1462 CFX_ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16);
1463 if (tables.IsEmpty()) { 1463 if (tables.IsEmpty()) {
1464 return; 1464 return;
1465 } 1465 }
1466 CFX_ByteString names = 1466 CFX_ByteString names =
1467 FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); 1467 FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x6e616d65);
1468 if (names.IsEmpty()) { 1468 if (names.IsEmpty()) {
1469 return; 1469 return;
1470 } 1470 }
1471 CFX_ByteString facename = GetNameFromTT(names, names.GetLength(), 1); 1471 CFX_ByteString facename =
1472 GetNameFromTT(names.raw_str(), names.GetLength(), 1);
1472 if (facename.IsEmpty()) { 1473 if (facename.IsEmpty()) {
1473 return; 1474 return;
1474 } 1475 }
1475 CFX_ByteString style = GetNameFromTT(names, names.GetLength(), 2); 1476 CFX_ByteString style = GetNameFromTT(names.raw_str(), names.GetLength(), 2);
1476 if (style != "Regular") { 1477 if (style != "Regular") {
1477 facename += " " + style; 1478 facename += " " + style;
1478 } 1479 }
1479 if (pdfium::ContainsKey(m_FontList, facename)) 1480 if (pdfium::ContainsKey(m_FontList, facename))
1480 return; 1481 return;
1481 1482
1482 CFX_FontFaceInfo* pInfo = 1483 CFX_FontFaceInfo* pInfo =
1483 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); 1484 new CFX_FontFaceInfo(path, facename, tables, offset, filesize);
1484 CFX_ByteString os2 = FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); 1485 CFX_ByteString os2 =
1486 FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x4f532f32);
1485 if (os2.GetLength() >= 86) { 1487 if (os2.GetLength() >= 86) {
1486 const uint8_t* p = (const uint8_t*)os2 + 78; 1488 const uint8_t* p = os2.raw_str() + 78;
1487 uint32_t codepages = GET_TT_LONG(p); 1489 uint32_t codepages = GET_TT_LONG(p);
1488 if (codepages & (1 << 17)) { 1490 if (codepages & (1 << 17)) {
1489 m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET); 1491 m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET);
1490 pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS; 1492 pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS;
1491 } 1493 }
1492 if (codepages & (1 << 18)) { 1494 if (codepages & (1 << 18)) {
1493 m_pMapper->AddInstalledFont(facename, FXFONT_GB2312_CHARSET); 1495 m_pMapper->AddInstalledFont(facename, FXFONT_GB2312_CHARSET);
1494 pInfo->m_Charsets |= CHARSET_FLAG_GB; 1496 pInfo->m_Charsets |= CHARSET_FLAG_GB;
1495 } 1497 }
1496 if (codepages & (1 << 20)) { 1498 if (codepages & (1 << 20)) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 const CFX_FontFaceInfo* pFont = static_cast<CFX_FontFaceInfo*>(hFont); 1598 const CFX_FontFaceInfo* pFont = static_cast<CFX_FontFaceInfo*>(hFont);
1597 uint32_t datasize = 0; 1599 uint32_t datasize = 0;
1598 uint32_t offset = 0; 1600 uint32_t offset = 0;
1599 if (table == 0) { 1601 if (table == 0) {
1600 datasize = pFont->m_FontOffset ? 0 : pFont->m_FileSize; 1602 datasize = pFont->m_FontOffset ? 0 : pFont->m_FileSize;
1601 } else if (table == kTableTTCF) { 1603 } else if (table == kTableTTCF) {
1602 datasize = pFont->m_FontOffset ? pFont->m_FileSize : 0; 1604 datasize = pFont->m_FontOffset ? pFont->m_FileSize : 0;
1603 } else { 1605 } else {
1604 uint32_t nTables = pFont->m_FontTables.GetLength() / 16; 1606 uint32_t nTables = pFont->m_FontTables.GetLength() / 16;
1605 for (uint32_t i = 0; i < nTables; i++) { 1607 for (uint32_t i = 0; i < nTables; i++) {
1606 const uint8_t* p = 1608 const uint8_t* p = pFont->m_FontTables.raw_str() + i * 16;
1607 static_cast<const uint8_t*>(pFont->m_FontTables) + i * 16;
1608 if (GET_TT_LONG(p) == table) { 1609 if (GET_TT_LONG(p) == table) {
1609 offset = GET_TT_LONG(p + 8); 1610 offset = GET_TT_LONG(p + 8);
1610 datasize = GET_TT_LONG(p + 12); 1611 datasize = GET_TT_LONG(p + 12);
1611 } 1612 }
1612 } 1613 }
1613 } 1614 }
1614 1615
1615 if (!datasize || size < datasize) 1616 if (!datasize || size < datasize)
1616 return datasize; 1617 return datasize;
1617 1618
(...skipping 25 matching lines...) Expand all
1643 int PDF_GetStandardFontName(CFX_ByteString* name) { 1644 int PDF_GetStandardFontName(CFX_ByteString* name) {
1644 AltFontName* found = static_cast<AltFontName*>( 1645 AltFontName* found = static_cast<AltFontName*>(
1645 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), 1646 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames),
1646 sizeof(AltFontName), CompareString)); 1647 sizeof(AltFontName), CompareString));
1647 if (!found) 1648 if (!found)
1648 return -1; 1649 return -1;
1649 1650
1650 *name = g_Base14FontNames[found->m_Index]; 1651 *name = g_Base14FontNames[found->m_Index];
1651 return found->m_Index; 1652 return found->m_Index;
1652 } 1653 }
OLDNEW
« no previous file with comments | « core/fxcrt/include/fx_string.h ('k') | fpdfsdk/fpdf_flatten.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698