| OLD | NEW |
| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 size = 66919; | 460 size = 66919; |
| 461 } | 461 } |
| 462 } else { | 462 } else { |
| 463 pFontData = g_FoxitFonts[index].m_pFontData; | 463 pFontData = g_FoxitFonts[index].m_pFontData; |
| 464 size = g_FoxitFonts[index].m_dwSize; | 464 size = g_FoxitFonts[index].m_dwSize; |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 return TRUE; | 467 return TRUE; |
| 468 } | 468 } |
| 469 CFX_FontMapper::CFX_FontMapper(CFX_FontMgr* mgr) | 469 CFX_FontMapper::CFX_FontMapper(CFX_FontMgr* mgr) |
| 470 : m_pFontInfo(nullptr), | 470 : m_bListLoaded(FALSE), |
| 471 m_bListLoaded(FALSE), | 471 m_pFontInfo(nullptr), |
| 472 m_pFontEnumerator(nullptr), | 472 m_pFontEnumerator(nullptr), |
| 473 m_pFontMgr(mgr) { | 473 m_pFontMgr(mgr) { |
| 474 FXSYS_memset(m_FoxitFaces, 0, sizeof m_FoxitFaces); | 474 m_MMFaces[0] = nullptr; |
| 475 m_MMFaces[0] = m_MMFaces[1] = NULL; | 475 m_MMFaces[1] = nullptr; |
| 476 FXSYS_memset(m_FoxitFaces, 0, sizeof(m_FoxitFaces)); |
| 476 } | 477 } |
| 477 CFX_FontMapper::~CFX_FontMapper() { | 478 CFX_FontMapper::~CFX_FontMapper() { |
| 478 for (int i = 0; i < 14; i++) | 479 for (int i = 0; i < 14; i++) |
| 479 if (m_FoxitFaces[i]) { | 480 if (m_FoxitFaces[i]) { |
| 480 FXFT_Done_Face(m_FoxitFaces[i]); | 481 FXFT_Done_Face(m_FoxitFaces[i]); |
| 481 } | 482 } |
| 482 if (m_MMFaces[0]) { | 483 if (m_MMFaces[0]) { |
| 483 FXFT_Done_Face(m_MMFaces[0]); | 484 FXFT_Done_Face(m_MMFaces[0]); |
| 484 } | 485 } |
| 485 if (m_MMFaces[1]) { | 486 if (m_MMFaces[1]) { |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 return NULL; | 1373 return NULL; |
| 1373 } | 1374 } |
| 1374 #endif | 1375 #endif |
| 1375 CFX_FolderFontInfo::CFX_FolderFontInfo() {} | 1376 CFX_FolderFontInfo::CFX_FolderFontInfo() {} |
| 1376 CFX_FolderFontInfo::~CFX_FolderFontInfo() { | 1377 CFX_FolderFontInfo::~CFX_FolderFontInfo() { |
| 1377 FX_POSITION pos = m_FontList.GetStartPosition(); | 1378 FX_POSITION pos = m_FontList.GetStartPosition(); |
| 1378 while (pos) { | 1379 while (pos) { |
| 1379 CFX_ByteString key; | 1380 CFX_ByteString key; |
| 1380 void* value; | 1381 void* value; |
| 1381 m_FontList.GetNextAssoc(pos, key, value); | 1382 m_FontList.GetNextAssoc(pos, key, value); |
| 1382 delete (CFontFaceInfo*)value; | 1383 delete (CFX_FontFaceInfo*)value; |
| 1383 } | 1384 } |
| 1384 } | 1385 } |
| 1385 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) { | 1386 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) { |
| 1386 m_PathList.Add(path); | 1387 m_PathList.Add(path); |
| 1387 } | 1388 } |
| 1388 void CFX_FolderFontInfo::Release() { | 1389 void CFX_FolderFontInfo::Release() { |
| 1389 delete this; | 1390 delete this; |
| 1390 } | 1391 } |
| 1391 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { | 1392 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { |
| 1392 m_pMapper = pMapper; | 1393 m_pMapper = pMapper; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); | 1487 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); |
| 1487 CFX_ByteString facename = _FPDF_GetNameFromTT(names, 1); | 1488 CFX_ByteString facename = _FPDF_GetNameFromTT(names, 1); |
| 1488 CFX_ByteString style = _FPDF_GetNameFromTT(names, 2); | 1489 CFX_ByteString style = _FPDF_GetNameFromTT(names, 2); |
| 1489 if (style != "Regular") { | 1490 if (style != "Regular") { |
| 1490 facename += " " + style; | 1491 facename += " " + style; |
| 1491 } | 1492 } |
| 1492 void* p; | 1493 void* p; |
| 1493 if (m_FontList.Lookup(facename, p)) { | 1494 if (m_FontList.Lookup(facename, p)) { |
| 1494 return; | 1495 return; |
| 1495 } | 1496 } |
| 1496 CFontFaceInfo* pInfo = new CFontFaceInfo; | 1497 CFX_FontFaceInfo* pInfo = |
| 1497 if (!pInfo) { | 1498 new CFX_FontFaceInfo(path, facename, tables, offset, filesize); |
| 1498 return; | |
| 1499 } | |
| 1500 pInfo->m_FilePath = path; | |
| 1501 pInfo->m_FaceName = facename; | |
| 1502 pInfo->m_FontTables = tables; | |
| 1503 pInfo->m_FontOffset = offset; | |
| 1504 pInfo->m_FileSize = filesize; | |
| 1505 pInfo->m_Charsets = 0; | |
| 1506 CFX_ByteString os2 = | 1499 CFX_ByteString os2 = |
| 1507 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); | 1500 _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); |
| 1508 if (os2.GetLength() >= 86) { | 1501 if (os2.GetLength() >= 86) { |
| 1509 const uint8_t* p = (const uint8_t*)os2 + 78; | 1502 const uint8_t* p = (const uint8_t*)os2 + 78; |
| 1510 FX_DWORD codepages = GET_TT_LONG(p); | 1503 FX_DWORD codepages = GET_TT_LONG(p); |
| 1511 if (codepages & (1 << 17)) { | 1504 if (codepages & (1 << 17)) { |
| 1512 m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET); | 1505 m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET); |
| 1513 pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS; | 1506 pInfo->m_Charsets |= CHARSET_FLAG_SHIFTJIS; |
| 1514 } | 1507 } |
| 1515 if (codepages & (1 << 18)) { | 1508 if (codepages & (1 << 18)) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 } | 1558 } |
| 1566 return p; | 1559 return p; |
| 1567 } | 1560 } |
| 1568 FX_DWORD CFX_FolderFontInfo::GetFontData(void* hFont, | 1561 FX_DWORD CFX_FolderFontInfo::GetFontData(void* hFont, |
| 1569 FX_DWORD table, | 1562 FX_DWORD table, |
| 1570 uint8_t* buffer, | 1563 uint8_t* buffer, |
| 1571 FX_DWORD size) { | 1564 FX_DWORD size) { |
| 1572 if (hFont == NULL) { | 1565 if (hFont == NULL) { |
| 1573 return 0; | 1566 return 0; |
| 1574 } | 1567 } |
| 1575 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; | 1568 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; |
| 1576 FXSYS_FILE* pFile = NULL; | 1569 FXSYS_FILE* pFile = NULL; |
| 1577 if (size > 0) { | 1570 if (size > 0) { |
| 1578 pFile = FXSYS_fopen(pFont->m_FilePath, "rb"); | 1571 pFile = FXSYS_fopen(pFont->m_FilePath, "rb"); |
| 1579 if (pFile == NULL) { | 1572 if (pFile == NULL) { |
| 1580 return 0; | 1573 return 0; |
| 1581 } | 1574 } |
| 1582 } | 1575 } |
| 1583 FX_DWORD datasize = 0; | 1576 FX_DWORD datasize = 0; |
| 1584 FX_DWORD offset; | 1577 FX_DWORD offset; |
| 1585 if (table == 0) { | 1578 if (table == 0) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1605 if (pFile) { | 1598 if (pFile) { |
| 1606 FXSYS_fclose(pFile); | 1599 FXSYS_fclose(pFile); |
| 1607 } | 1600 } |
| 1608 return datasize; | 1601 return datasize; |
| 1609 } | 1602 } |
| 1610 void CFX_FolderFontInfo::DeleteFont(void* hFont) {} | 1603 void CFX_FolderFontInfo::DeleteFont(void* hFont) {} |
| 1611 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { | 1604 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { |
| 1612 if (hFont == NULL) { | 1605 if (hFont == NULL) { |
| 1613 return FALSE; | 1606 return FALSE; |
| 1614 } | 1607 } |
| 1615 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; | 1608 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; |
| 1616 name = pFont->m_FaceName; | 1609 name = pFont->m_FaceName; |
| 1617 return TRUE; | 1610 return TRUE; |
| 1618 } | 1611 } |
| 1619 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { | 1612 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { |
| 1620 return FALSE; | 1613 return FALSE; |
| 1621 } | 1614 } |
| OLD | NEW |