OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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 "xfa/fgas/font/fgas_stdfontmgr.h" | 7 #include "xfa/fgas/font/fgas_stdfontmgr.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_stream.h" | 9 #include "core/fxcrt/include/fx_stream.h" |
10 #include "core/fxge/include/fx_ge.h" | 10 #include "core/fxge/include/fx_ge.h" |
11 #include "xfa/fgas/crt/fgas_codepage.h" | 11 #include "xfa/fgas/crt/fgas_codepage.h" |
12 #include "xfa/fgas/font/fgas_fontutils.h" | 12 #include "xfa/fgas/font/fgas_fontutils.h" |
13 #include "xfa/fgas/font/fgas_gefont.h" | 13 #include "xfa/fgas/font/fgas_gefont.h" |
14 | 14 |
15 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 15 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
16 | 16 |
17 IFGAS_FontMgr* IFGAS_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) { | 17 IFGAS_FontMgr* IFGAS_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) { |
18 return new CFGAS_StdFontMgrImp(pEnumerator); | 18 return new CFGAS_StdFontMgrImp(pEnumerator); |
19 } | 19 } |
20 | 20 |
21 CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) | 21 CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) |
22 : m_pEnumerator(pEnumerator), | 22 : m_pEnumerator(pEnumerator), |
23 m_FontFaces(), | 23 m_FontFaces(100), |
24 m_CPFonts(8), | 24 m_CPFonts(8), |
25 m_FamilyFonts(16), | 25 m_FamilyFonts(16), |
26 m_UnicodeFonts(16), | 26 m_UnicodeFonts(16), |
27 m_BufferFonts(4), | 27 m_BufferFonts(4), |
28 m_StreamFonts(4), | 28 m_StreamFonts(4), |
29 m_DeriveFonts(4) { | 29 m_DeriveFonts(4) { |
30 if (m_pEnumerator) { | 30 if (m_pEnumerator) { |
31 m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); | 31 m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { | 35 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { |
36 m_FontFaces.RemoveAll(); | 36 m_FontFaces.RemoveAll(FALSE); |
37 m_CPFonts.RemoveAll(); | 37 m_CPFonts.RemoveAll(); |
38 m_FamilyFonts.RemoveAll(); | 38 m_FamilyFonts.RemoveAll(); |
39 m_UnicodeFonts.RemoveAll(); | 39 m_UnicodeFonts.RemoveAll(); |
40 m_BufferFonts.RemoveAll(); | 40 m_BufferFonts.RemoveAll(); |
41 m_StreamFonts.RemoveAll(); | 41 m_StreamFonts.RemoveAll(); |
42 m_DeriveFonts.RemoveAll(); | 42 m_DeriveFonts.RemoveAll(); |
43 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) | 43 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) |
44 m_Fonts[i]->Release(); | 44 m_Fonts[i]->Release(); |
45 } | 45 } |
46 | 46 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 params.wUnicode = wUnicode; | 291 params.wUnicode = wUnicode; |
292 params.wCodePage = wCodePage; | 292 params.wCodePage = wCodePage; |
293 params.pwsFamily = pszFontFamily; | 293 params.pwsFamily = pszFontFamily; |
294 params.dwFontStyles = dwFontStyles; | 294 params.dwFontStyles = dwFontStyles; |
295 params.dwMatchFlags = dwMatchFlags; | 295 params.dwMatchFlags = dwMatchFlags; |
296 FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(¶ms, m_FontFaces); | 296 FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(¶ms, m_FontFaces); |
297 if (pDesc) { | 297 if (pDesc) { |
298 return pDesc; | 298 return pDesc; |
299 } | 299 } |
300 if (pszFontFamily && m_pEnumerator) { | 300 if (pszFontFamily && m_pEnumerator) { |
301 CFX_FontDescriptors namedFonts; | 301 CFX_FontDescriptors namedFonts(100); |
302 m_pEnumerator(namedFonts, pszFontFamily, wUnicode); | 302 m_pEnumerator(namedFonts, pszFontFamily, wUnicode); |
303 params.pwsFamily = nullptr; | 303 params.pwsFamily = nullptr; |
304 pDesc = FX_DefFontMatcher(¶ms, namedFonts); | 304 pDesc = FX_DefFontMatcher(¶ms, namedFonts); |
305 if (!pDesc) { | 305 if (!pDesc) { |
306 return nullptr; | 306 return nullptr; |
307 } | 307 } |
308 for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { | 308 for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) { |
309 FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); | 309 FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i); |
310 if (*pMatch == *pDesc) { | 310 if (*pMatch == *pDesc) { |
311 return pMatch; | 311 return pMatch; |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 | 1388 |
1389 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, | 1389 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, |
1390 const CFX_WideString& Name2) { | 1390 const CFX_WideString& Name2) { |
1391 if (Name1.Find(Name2.c_str()) != -1) { | 1391 if (Name1.Find(Name2.c_str()) != -1) { |
1392 return 1; | 1392 return 1; |
1393 } | 1393 } |
1394 return 0; | 1394 return 0; |
1395 } | 1395 } |
1396 | 1396 |
1397 #endif | 1397 #endif |
OLD | NEW |