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 -1; | 54 return -1; |
55 } | 55 } |
56 } | 56 } |
57 m_RefCount --; | 57 m_RefCount --; |
58 if (m_RefCount) { | 58 if (m_RefCount) { |
59 return m_RefCount; | 59 return m_RefCount; |
60 } | 60 } |
61 delete this; | 61 delete this; |
62 return 0; | 62 return 0; |
63 } | 63 } |
64 CFX_FontMgr::CFX_FontMgr() | 64 CFX_FontMgr::CFX_FontMgr() : m_FTLibrary(nullptr) |
65 { | 65 { |
66 m_pBuiltinMapper = FX_NEW CFX_FontMapper; | 66 m_pBuiltinMapper = new CFX_FontMapper(this); |
67 if (!m_pBuiltinMapper) { | |
68 return; | |
69 } | |
70 m_pBuiltinMapper->m_pFontMgr = this; | |
71 m_pExtMapper = NULL; | |
72 m_FTLibrary = NULL; | |
73 FXSYS_memset(m_ExternalFonts, 0, sizeof m_ExternalFonts); | 67 FXSYS_memset(m_ExternalFonts, 0, sizeof m_ExternalFonts); |
74 } | 68 } |
75 CFX_FontMgr::~CFX_FontMgr() | 69 CFX_FontMgr::~CFX_FontMgr() |
76 { | 70 { |
77 delete m_pBuiltinMapper; | 71 delete m_pBuiltinMapper; |
78 FreeCache(); | 72 FreeCache(); |
79 if (m_FTLibrary) { | 73 if (m_FTLibrary) { |
80 FXFT_Done_FreeType(m_FTLibrary); | 74 FXFT_Done_FreeType(m_FTLibrary); |
81 } | 75 } |
82 } | 76 } |
(...skipping 14 matching lines...) Expand all Loading... |
97 } | 91 } |
98 m_FaceMap.RemoveAll(); | 92 m_FaceMap.RemoveAll(); |
99 } | 93 } |
100 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) | 94 void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) |
101 { | 95 { |
102 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); | 96 m_pBuiltinMapper->SetSystemFontInfo(pFontInfo); |
103 } | 97 } |
104 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, |
105 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) |
106 { | 100 { |
107 if (m_FTLibrary == NULL) { | 101 if (!m_FTLibrary) { |
108 FXFT_Init_FreeType(&m_FTLibrary); | 102 FXFT_Init_FreeType(&m_FTLibrary); |
109 } | 103 } |
110 if (m_pExtMapper) { | 104 return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight,
italic_angle, CharsetCP, pSubstFont); |
111 FXFT_Face face = m_pExtMapper->FindSubstFont(face_name, bTrueType, flags
, weight, italic_angle, | |
112 CharsetCP, pSubstFont); | |
113 if (face) { | |
114 return face; | |
115 } | |
116 } | |
117 return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight,
italic_angle, | |
118 CharsetCP, pSubstFont); | |
119 } | 105 } |
120 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, | 106 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name, |
121 int weight, FX_BOOL bItalic, uint8_t*& pFon
tData) | 107 int weight, FX_BOOL bItalic, uint8_t*& pFon
tData) |
122 { | 108 { |
123 CFX_ByteString key(face_name); | 109 CFX_ByteString key(face_name); |
124 key += ','; | 110 key += ','; |
125 key += CFX_ByteString::FormatInteger(weight); | 111 key += CFX_ByteString::FormatInteger(weight); |
126 key += bItalic ? 'I' : 'N'; | 112 key += bItalic ? 'I' : 'N'; |
127 CTTFontDesc* pFontDesc = NULL; | 113 CTTFontDesc* pFontDesc = NULL; |
128 m_FaceMap.Lookup(key, (void*&)pFontDesc); | 114 m_FaceMap.Lookup(key, (void*&)pFontDesc); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 pFontData = g_FoxitSansMMFontData; | 450 pFontData = g_FoxitSansMMFontData; |
465 size = 66919; | 451 size = 66919; |
466 } | 452 } |
467 } else { | 453 } else { |
468 pFontData = g_FoxitFonts[index].m_pFontData; | 454 pFontData = g_FoxitFonts[index].m_pFontData; |
469 size = g_FoxitFonts[index].m_dwSize; | 455 size = g_FoxitFonts[index].m_dwSize; |
470 } | 456 } |
471 } | 457 } |
472 return TRUE; | 458 return TRUE; |
473 } | 459 } |
474 CFX_FontMapper::CFX_FontMapper() | 460 CFX_FontMapper::CFX_FontMapper(CFX_FontMgr* mgr) |
| 461 : m_pFontInfo(nullptr), |
| 462 m_bListLoaded(FALSE), |
| 463 m_pFontEnumerator(nullptr), |
| 464 m_pFontMgr(mgr) |
475 { | 465 { |
476 FXSYS_memset(m_FoxitFaces, 0, sizeof m_FoxitFaces); | 466 FXSYS_memset(m_FoxitFaces, 0, sizeof m_FoxitFaces); |
477 m_MMFaces[0] = m_MMFaces[1] = NULL; | 467 m_MMFaces[0] = m_MMFaces[1] = NULL; |
478 m_pFontInfo = NULL; | |
479 m_bListLoaded = FALSE; | |
480 m_pFontEnumerator = NULL; | |
481 } | 468 } |
482 CFX_FontMapper::~CFX_FontMapper() | 469 CFX_FontMapper::~CFX_FontMapper() |
483 { | 470 { |
484 for (int i = 0; i < 14; i ++) | 471 for (int i = 0; i < 14; i ++) |
485 if (m_FoxitFaces[i]) { | 472 if (m_FoxitFaces[i]) { |
486 FXFT_Done_Face(m_FoxitFaces[i]); | 473 FXFT_Done_Face(m_FoxitFaces[i]); |
487 } | 474 } |
488 if (m_MMFaces[0]) { | 475 if (m_MMFaces[0]) { |
489 FXFT_Done_Face(m_MMFaces[0]); | 476 FXFT_Done_Face(m_MMFaces[0]); |
490 } | 477 } |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 return FALSE; | 1603 return FALSE; |
1617 } | 1604 } |
1618 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; | 1605 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; |
1619 name = pFont->m_FaceName; | 1606 name = pFont->m_FaceName; |
1620 return TRUE; | 1607 return TRUE; |
1621 } | 1608 } |
1622 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) | 1609 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) |
1623 { | 1610 { |
1624 return FALSE; | 1611 return FALSE; |
1625 } | 1612 } |
OLD | NEW |