| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return FALSE; | 54 return FALSE; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 m_RefCount --; | 57 m_RefCount --; |
| 58 if (m_RefCount) { | 58 if (m_RefCount) { |
| 59 return FALSE; | 59 return FALSE; |
| 60 } | 60 } |
| 61 delete this; | 61 delete this; |
| 62 return TRUE; | 62 return TRUE; |
| 63 } | 63 } |
| 64 CFX_FontMgr::CFX_FontMgr() | 64 CFX_FontMgr::CFX_FontMgr() : m_FTLibrary(nullptr) |
| 65 { | 65 { |
| 66 m_pBuiltinMapper = new CFX_FontMapper; | 66 m_pBuiltinMapper = new CFX_FontMapper(this); |
| 67 m_pBuiltinMapper->m_pFontMgr = this; | |
| 68 m_pExtMapper = NULL; | |
| 69 m_FTLibrary = NULL; | |
| 70 FXSYS_memset(m_ExternalFonts, 0, sizeof m_ExternalFonts); | 67 FXSYS_memset(m_ExternalFonts, 0, sizeof m_ExternalFonts); |
| 71 } | 68 } |
| 72 CFX_FontMgr::~CFX_FontMgr() | 69 CFX_FontMgr::~CFX_FontMgr() |
| 73 { | 70 { |
| 74 delete m_pBuiltinMapper; | 71 delete m_pBuiltinMapper; |
| 75 FreeCache(); | 72 FreeCache(); |
| 76 if (m_FTLibrary) { | 73 if (m_FTLibrary) { |
| 77 FXFT_Done_FreeType(m_FTLibrary); | 74 FXFT_Done_FreeType(m_FTLibrary); |
| 78 } | 75 } |
| 79 } | 76 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 94 } | 91 } |
| 95 m_FaceMap.RemoveAll(); | 92 m_FaceMap.RemoveAll(); |
| 96 } | 93 } |
| 97 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) | 94 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) |
| 98 { | 95 { |
| 99 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); | 96 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); |
| 100 } | 97 } |
| 101 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bT
rueType, | 98 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bT
rueType, |
| 102 FX_DWORD flags, int weight, int italic_angl
e, int CharsetCP, CFX_SubstFont* pSubstFont) | 99 FX_DWORD flags, int weight, int italic_angl
e, int CharsetCP, CFX_SubstFont* pSubstFont) |
| 103 { | 100 { |
| 104 if (m_FTLibrary == NULL) { | 101 if (!m_FTLibrary) { |
| 105 FXFT_Init_FreeType(&m_FTLibrary); | 102 FXFT_Init_FreeType(&m_FTLibrary); |
| 106 } | 103 } |
| 107 if (m_pExtMapper) { | 104 return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight,
italic_angle, CharsetCP, pSubstFont); |
| 108 FXFT_Face face = m_pExtMapper->FindSubstFont(face_name, bTrueType, flags
, weight, italic_angle, | |
| 109 CharsetCP, pSubstFont); | |
| 110 if (face) { | |
| 111 return face; | |
| 112 } | |
| 113 } | |
| 114 return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight,
italic_angle, | |
| 115 CharsetCP, pSubstFont); | |
| 116 } | 105 } |
| 117 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, | 106 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, |
| 118 int weight, FX_BOOL bItalic, uint8_t*& pFon
tData) | 107 int weight, FX_BOOL bItalic, uint8_t*& pFon
tData) |
| 119 { | 108 { |
| 120 CFX_ByteString key(face_name); | 109 CFX_ByteString key(face_name); |
| 121 key += ','; | 110 key += ','; |
| 122 key += CFX_ByteString::FormatInteger(weight); | 111 key += CFX_ByteString::FormatInteger(weight); |
| 123 key += bItalic ? 'I' : 'N'; | 112 key += bItalic ? 'I' : 'N'; |
| 124 CTTFontDesc* pFontDesc = NULL; | 113 CTTFontDesc* pFontDesc = NULL; |
| 125 m_FaceMap.Lookup(key, (void*&)pFontDesc); | 114 m_FaceMap.Lookup(key, (void*&)pFontDesc); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 pFontData = g_FoxitSansMMFontData; | 436 pFontData = g_FoxitSansMMFontData; |
| 448 size = 66919; | 437 size = 66919; |
| 449 } | 438 } |
| 450 } else { | 439 } else { |
| 451 pFontData = g_FoxitFonts[index].m_pFontData; | 440 pFontData = g_FoxitFonts[index].m_pFontData; |
| 452 size = g_FoxitFonts[index].m_dwSize; | 441 size = g_FoxitFonts[index].m_dwSize; |
| 453 } | 442 } |
| 454 } | 443 } |
| 455 return TRUE; | 444 return TRUE; |
| 456 } | 445 } |
| 457 CFX_FontMapper::CFX_FontMapper() | 446 CFX_FontMapper::CFX_FontMapper(CFX_FontMgr* mgr) |
| 447 : m_pFontInfo(nullptr), |
| 448 m_bListLoaded(FALSE), |
| 449 m_pFontEnumerator(nullptr), |
| 450 m_pFontMgr(mgr) |
| 458 { | 451 { |
| 459 FXSYS_memset(m_FoxitFaces, 0, sizeof m_FoxitFaces); | 452 FXSYS_memset(m_FoxitFaces, 0, sizeof m_FoxitFaces); |
| 460 m_MMFaces[0] = m_MMFaces[1] = NULL; | 453 m_MMFaces[0] = m_MMFaces[1] = NULL; |
| 461 m_pFontInfo = NULL; | |
| 462 m_bListLoaded = FALSE; | |
| 463 m_pFontEnumerator = NULL; | |
| 464 } | 454 } |
| 465 CFX_FontMapper::~CFX_FontMapper() | 455 CFX_FontMapper::~CFX_FontMapper() |
| 466 { | 456 { |
| 467 for (int i = 0; i < 14; i ++) | 457 for (int i = 0; i < 14; i ++) |
| 468 if (m_FoxitFaces[i]) { | 458 if (m_FoxitFaces[i]) { |
| 469 FXFT_Done_Face(m_FoxitFaces[i]); | 459 FXFT_Done_Face(m_FoxitFaces[i]); |
| 470 } | 460 } |
| 471 if (m_MMFaces[0]) { | 461 if (m_MMFaces[0]) { |
| 472 FXFT_Done_Face(m_MMFaces[0]); | 462 FXFT_Done_Face(m_MMFaces[0]); |
| 473 } | 463 } |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1512 return FALSE; | 1502 return FALSE; |
| 1513 } | 1503 } |
| 1514 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; | 1504 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; |
| 1515 name = pFont->m_FaceName; | 1505 name = pFont->m_FaceName; |
| 1516 return TRUE; | 1506 return TRUE; |
| 1517 } | 1507 } |
| 1518 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) | 1508 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) |
| 1519 { | 1509 { |
| 1520 return FALSE; | 1510 return FALSE; |
| 1521 } | 1511 } |
| OLD | NEW |