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/fx_stream.h" | 9 #include "core/fxcrt/fx_stream.h" |
10 #include "core/fxge/cfx_fontmapper.h" | 10 #include "core/fxge/cfx_fontmapper.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 m_UnicodeFonts(16), | 30 m_UnicodeFonts(16), |
31 m_BufferFonts(4), | 31 m_BufferFonts(4), |
32 m_StreamFonts(4), | 32 m_StreamFonts(4), |
33 m_DeriveFonts(4) { | 33 m_DeriveFonts(4) { |
34 if (m_pEnumerator) { | 34 if (m_pEnumerator) { |
35 m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); | 35 m_pEnumerator(m_FontFaces, nullptr, 0xFEFF); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { | 39 CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { |
40 m_FontFaces.RemoveAll(FALSE); | 40 m_FontFaces.RemoveAll(false); |
41 m_CPFonts.RemoveAll(); | 41 m_CPFonts.RemoveAll(); |
42 m_FamilyFonts.RemoveAll(); | 42 m_FamilyFonts.RemoveAll(); |
43 m_UnicodeFonts.RemoveAll(); | 43 m_UnicodeFonts.RemoveAll(); |
44 m_BufferFonts.RemoveAll(); | 44 m_BufferFonts.RemoveAll(); |
45 m_StreamFonts.RemoveAll(); | 45 m_StreamFonts.RemoveAll(); |
46 m_DeriveFonts.RemoveAll(); | 46 m_DeriveFonts.RemoveAll(); |
47 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) | 47 for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) |
48 m_Fonts[i]->Release(); | 48 m_Fonts[i]->Release(); |
49 } | 49 } |
50 | 50 |
51 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( | 51 CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( |
52 uint16_t wCodePage, | 52 uint16_t wCodePage, |
53 uint32_t dwFontStyles, | 53 uint32_t dwFontStyles, |
54 const FX_WCHAR* pszFontFamily) { | 54 const FX_WCHAR* pszFontFamily) { |
55 uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); | 55 uint32_t dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles); |
56 CFGAS_GEFont* pFont = nullptr; | 56 CFGAS_GEFont* pFont = nullptr; |
57 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 57 if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
58 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; | 58 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; |
59 } | 59 } |
60 FX_FONTDESCRIPTOR const* pFD = | 60 FX_FONTDESCRIPTOR const* pFD = |
61 FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage); | 61 FindFont(pszFontFamily, dwFontStyles, true, wCodePage); |
62 if (!pFD) | 62 if (!pFD) |
63 pFD = FindFont(nullptr, dwFontStyles, TRUE, wCodePage); | 63 pFD = FindFont(nullptr, dwFontStyles, true, wCodePage); |
64 if (!pFD) | 64 if (!pFD) |
65 pFD = FindFont(nullptr, dwFontStyles, FALSE, wCodePage); | 65 pFD = FindFont(nullptr, dwFontStyles, false, wCodePage); |
66 if (!pFD) | 66 if (!pFD) |
67 return nullptr; | 67 return nullptr; |
68 | 68 |
69 pFont = | 69 pFont = |
70 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 70 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
71 if (pFont) { | 71 if (pFont) { |
72 m_Fonts.Add(pFont); | 72 m_Fonts.Add(pFont); |
73 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 73 m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
74 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); | 74 dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage); |
75 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 75 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
(...skipping 18 matching lines...) Expand all Loading... |
94 if (pRet->wBitField == 999) | 94 if (pRet->wBitField == 999) |
95 return nullptr; | 95 return nullptr; |
96 | 96 |
97 uint32_t dwHash = | 97 uint32_t dwHash = |
98 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField); | 98 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, pRet->wBitField); |
99 CFGAS_GEFont* pFont = nullptr; | 99 CFGAS_GEFont* pFont = nullptr; |
100 if (m_UnicodeFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) | 100 if (m_UnicodeFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) |
101 return pFont ? LoadFont(pFont, dwFontStyles, pRet->wCodePage) : nullptr; | 101 return pFont ? LoadFont(pFont, dwFontStyles, pRet->wCodePage) : nullptr; |
102 | 102 |
103 FX_FONTDESCRIPTOR const* pFD = | 103 FX_FONTDESCRIPTOR const* pFD = |
104 FindFont(pszFontFamily, dwFontStyles, FALSE, pRet->wCodePage, | 104 FindFont(pszFontFamily, dwFontStyles, false, pRet->wCodePage, |
105 pRet->wBitField, wUnicode); | 105 pRet->wBitField, wUnicode); |
106 if (!pFD && pszFontFamily) { | 106 if (!pFD && pszFontFamily) { |
107 pFD = FindFont(nullptr, dwFontStyles, FALSE, pRet->wCodePage, | 107 pFD = FindFont(nullptr, dwFontStyles, false, pRet->wCodePage, |
108 pRet->wBitField, wUnicode); | 108 pRet->wBitField, wUnicode); |
109 } | 109 } |
110 if (!pFD) | 110 if (!pFD) |
111 return nullptr; | 111 return nullptr; |
112 | 112 |
113 uint16_t wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); | 113 uint16_t wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); |
114 const FX_WCHAR* pFontFace = pFD->wsFontFace; | 114 const FX_WCHAR* pFontFace = pFD->wsFontFace; |
115 pFont = CFGAS_GEFont::LoadFont(pFontFace, dwFontStyles, wCodePage, this); | 115 pFont = CFGAS_GEFont::LoadFont(pFontFace, dwFontStyles, wCodePage, this); |
116 if (pFont) { | 116 if (pFont) { |
117 m_Fonts.Add(pFont); | 117 m_Fonts.Add(pFont); |
(...skipping 18 matching lines...) Expand all Loading... |
136 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, | 136 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily, |
137 uint32_t dwFontStyles, | 137 uint32_t dwFontStyles, |
138 uint16_t wCodePage) { | 138 uint16_t wCodePage) { |
139 uint32_t dwHash = | 139 uint32_t dwHash = |
140 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); | 140 FGAS_GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); |
141 CFGAS_GEFont* pFont = nullptr; | 141 CFGAS_GEFont* pFont = nullptr; |
142 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { | 142 if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) { |
143 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; | 143 return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : nullptr; |
144 } | 144 } |
145 FX_FONTDESCRIPTOR const* pFD = | 145 FX_FONTDESCRIPTOR const* pFD = |
146 FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage); | 146 FindFont(pszFontFamily, dwFontStyles, true, wCodePage); |
147 if (!pFD) | 147 if (!pFD) |
148 pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage); | 148 pFD = FindFont(pszFontFamily, dwFontStyles, false, wCodePage); |
149 if (!pFD) | 149 if (!pFD) |
150 return nullptr; | 150 return nullptr; |
151 | 151 |
152 if (wCodePage == 0xFFFF) { | 152 if (wCodePage == 0xFFFF) { |
153 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); | 153 wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet); |
154 } | 154 } |
155 pFont = | 155 pFont = |
156 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); | 156 CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); |
157 if (pFont) { | 157 if (pFont) { |
158 m_Fonts.Add(pFont); | 158 m_Fonts.Add(pFont); |
(...skipping 20 matching lines...) Expand all Loading... |
179 m_BufferFonts.SetAt((void*)pBuffer, pFont); | 179 m_BufferFonts.SetAt((void*)pBuffer, pFont); |
180 return pFont->Retain(); | 180 return pFont->Retain(); |
181 } | 181 } |
182 return nullptr; | 182 return nullptr; |
183 } | 183 } |
184 | 184 |
185 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, | 185 CFGAS_GEFont* CFGAS_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream, |
186 const FX_WCHAR* pszFontAlias, | 186 const FX_WCHAR* pszFontAlias, |
187 uint32_t dwFontStyles, | 187 uint32_t dwFontStyles, |
188 uint16_t wCodePage, | 188 uint16_t wCodePage, |
189 FX_BOOL bSaveStream) { | 189 bool bSaveStream) { |
190 ASSERT(pFontStream && pFontStream->GetLength() > 0); | 190 ASSERT(pFontStream && pFontStream->GetLength() > 0); |
191 CFGAS_GEFont* pFont = nullptr; | 191 CFGAS_GEFont* pFont = nullptr; |
192 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { | 192 if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) { |
193 if (pFont) { | 193 if (pFont) { |
194 if (pszFontAlias) { | 194 if (pszFontAlias) { |
195 uint32_t dwHash = | 195 uint32_t dwHash = |
196 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); | 196 FGAS_GetFontFamilyHash(pszFontAlias, dwFontStyles, wCodePage); |
197 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); | 197 m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont); |
198 } | 198 } |
199 return LoadFont(pFont, dwFontStyles, wCodePage); | 199 return LoadFont(pFont, dwFontStyles, wCodePage); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 int index = m_FontFaces.Add(*pDesc); | 314 int index = m_FontFaces.Add(*pDesc); |
315 return m_FontFaces.GetPtrAt(index); | 315 return m_FontFaces.GetPtrAt(index); |
316 } | 316 } |
317 return nullptr; | 317 return nullptr; |
318 } | 318 } |
319 | 319 |
320 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, | 320 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, |
321 const CFX_FontDescriptors& fonts) { | 321 const CFX_FontDescriptors& fonts) { |
322 FX_FONTDESCRIPTOR const* pBestFont = nullptr; | 322 FX_FONTDESCRIPTOR const* pBestFont = nullptr; |
323 int32_t iBestSimilar = 0; | 323 int32_t iBestSimilar = 0; |
324 FX_BOOL bMatchStyle = | 324 bool bMatchStyle = (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0; |
325 (pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0; | |
326 int32_t iCount = fonts.GetSize(); | 325 int32_t iCount = fonts.GetSize(); |
327 for (int32_t i = 0; i < iCount; ++i) { | 326 for (int32_t i = 0; i < iCount; ++i) { |
328 FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i); | 327 FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i); |
329 if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == | 328 if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) == |
330 FX_FONTSTYLE_BoldItalic) { | 329 FX_FONTSTYLE_BoldItalic) { |
331 continue; | 330 continue; |
332 } | 331 } |
333 if (pParams->pwsFamily) { | 332 if (pParams->pwsFamily) { |
334 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace)) { | 333 if (FXSYS_wcsicmp(pParams->pwsFamily, pFont->wsFontFace)) { |
335 continue; | 334 continue; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 m_Hash2Fonts.RemoveAll(); | 589 m_Hash2Fonts.RemoveAll(); |
591 pos = m_IFXFont2FileRead.GetStartPosition(); | 590 pos = m_IFXFont2FileRead.GetStartPosition(); |
592 while (pos) { | 591 while (pos) { |
593 CFGAS_GEFont* pFont; | 592 CFGAS_GEFont* pFont; |
594 IFX_SeekableReadStream* pFileRead; | 593 IFX_SeekableReadStream* pFileRead; |
595 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); | 594 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); |
596 pFileRead->Release(); | 595 pFileRead->Release(); |
597 } | 596 } |
598 } | 597 } |
599 | 598 |
600 FX_BOOL CFGAS_FontMgrImp::EnumFontsFromFontMapper() { | 599 bool CFGAS_FontMgrImp::EnumFontsFromFontMapper() { |
601 CFX_FontMapper* pFontMapper = | 600 CFX_FontMapper* pFontMapper = |
602 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); | 601 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); |
603 if (!pFontMapper) | 602 if (!pFontMapper) |
604 return FALSE; | 603 return false; |
605 | 604 |
606 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 605 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
607 if (!pSystemFontInfo) | 606 if (!pSystemFontInfo) |
608 return FALSE; | 607 return false; |
609 | 608 |
610 pSystemFontInfo->EnumFontList(pFontMapper); | 609 pSystemFontInfo->EnumFontList(pFontMapper); |
611 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { | 610 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { |
612 IFX_SeekableReadStream* pFontStream = | 611 IFX_SeekableReadStream* pFontStream = |
613 CreateFontStream(pFontMapper, pSystemFontInfo, i); | 612 CreateFontStream(pFontMapper, pSystemFontInfo, i); |
614 if (!pFontStream) | 613 if (!pFontStream) |
615 continue; | 614 continue; |
616 | 615 |
617 CFX_WideString wsFaceName = | 616 CFX_WideString wsFaceName = |
618 CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str()); | 617 CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str()); |
619 RegisterFaces(pFontStream, &wsFaceName); | 618 RegisterFaces(pFontStream, &wsFaceName); |
620 pFontStream->Release(); | 619 pFontStream->Release(); |
621 } | 620 } |
622 if (m_InstalledFonts.GetSize() == 0) | 621 if (m_InstalledFonts.GetSize() == 0) |
623 return FALSE; | 622 return false; |
624 | 623 |
625 return TRUE; | 624 return true; |
626 } | 625 } |
627 | 626 |
628 FX_BOOL CFGAS_FontMgrImp::EnumFontsFromFiles() { | 627 bool CFGAS_FontMgrImp::EnumFontsFromFiles() { |
629 CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); | 628 CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); |
630 FX_POSITION pos = m_pFontSource->GetStartPosition(); | 629 FX_POSITION pos = m_pFontSource->GetStartPosition(); |
631 IFX_FileAccess* pFontSource = nullptr; | 630 IFX_FileAccess* pFontSource = nullptr; |
632 IFX_SeekableReadStream* pFontStream = nullptr; | 631 IFX_SeekableReadStream* pFontStream = nullptr; |
633 while (pos) { | 632 while (pos) { |
634 pFontSource = m_pFontSource->GetNext(pos); | 633 pFontSource = m_pFontSource->GetNext(pos); |
635 pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); | 634 pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); |
636 if (!pFontStream) { | 635 if (!pFontStream) { |
637 pFontSource->Release(); | 636 pFontSource->Release(); |
638 continue; | 637 continue; |
639 } | 638 } |
640 RegisterFaces(pFontStream, nullptr); | 639 RegisterFaces(pFontStream, nullptr); |
641 pFontStream->Release(); | 640 pFontStream->Release(); |
642 pFontSource->Release(); | 641 pFontSource->Release(); |
643 } | 642 } |
644 if (m_InstalledFonts.GetSize() == 0) | 643 if (m_InstalledFonts.GetSize() == 0) |
645 return FALSE; | 644 return false; |
646 return TRUE; | 645 return true; |
647 } | 646 } |
648 | 647 |
649 FX_BOOL CFGAS_FontMgrImp::EnumFonts() { | 648 bool CFGAS_FontMgrImp::EnumFonts() { |
650 if (EnumFontsFromFontMapper()) | 649 if (EnumFontsFromFontMapper()) |
651 return TRUE; | 650 return true; |
652 return EnumFontsFromFiles(); | 651 return EnumFontsFromFiles(); |
653 } | 652 } |
654 | 653 |
655 CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCodePage( | 654 CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCodePage( |
656 uint16_t wCodePage, | 655 uint16_t wCodePage, |
657 uint32_t dwFontStyles, | 656 uint32_t dwFontStyles, |
658 const FX_WCHAR* pszFontFamily) { | 657 const FX_WCHAR* pszFontFamily) { |
659 return nullptr; | 658 return nullptr; |
660 } | 659 } |
661 | 660 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 continue; | 773 continue; |
775 pFont->SetLogicalFontStyle(dwFontStyles); | 774 pFont->SetLogicalFontStyle(dwFontStyles); |
776 pFonts->Add(pFont); | 775 pFonts->Add(pFont); |
777 return pFont; | 776 return pFont; |
778 } | 777 } |
779 if (!pszFontFamily) | 778 if (!pszFontFamily) |
780 m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr); | 779 m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr); |
781 return nullptr; | 780 return nullptr; |
782 } | 781 } |
783 | 782 |
784 FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc, | 783 bool CFGAS_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc, |
785 FX_WCHAR wcUnicode) { | 784 FX_WCHAR wcUnicode) { |
786 IFX_SeekableReadStream* pFileRead = | 785 IFX_SeekableReadStream* pFileRead = |
787 CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); | 786 CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); |
788 if (!pFileRead) | 787 if (!pFileRead) |
789 return FALSE; | 788 return false; |
790 FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); | 789 FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); |
791 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); | 790 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); |
792 FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); | 791 FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); |
793 pFileRead->Release(); | 792 pFileRead->Release(); |
794 if (!pFace) | 793 if (!pFace) |
795 return FALSE; | 794 return false; |
796 if (FXFT_Get_Face_External_Stream(pFace)) | 795 if (FXFT_Get_Face_External_Stream(pFace)) |
797 FXFT_Clear_Face_External_Stream(pFace); | 796 FXFT_Clear_Face_External_Stream(pFace); |
798 FXFT_Done_Face(pFace); | 797 FXFT_Done_Face(pFace); |
799 return !retCharmap && retIndex; | 798 return !retCharmap && retIndex; |
800 } | 799 } |
801 | 800 |
802 FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(CFGAS_GEFont* pFont, | 801 bool CFGAS_FontMgrImp::VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode) { |
803 FX_WCHAR wcUnicode) { | |
804 if (!pFont) | 802 if (!pFont) |
805 return FALSE; | 803 return false; |
806 | 804 |
807 FXFT_Face pFace = pFont->GetDevFont()->GetFace(); | 805 FXFT_Face pFace = pFont->GetDevFont()->GetFace(); |
808 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); | 806 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); |
809 if (FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE) != 0) | 807 if (FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE) != 0) |
810 return FALSE; | 808 return false; |
811 | 809 |
812 if (FXFT_Get_Char_Index(pFace, wcUnicode) == 0) { | 810 if (FXFT_Get_Char_Index(pFace, wcUnicode) == 0) { |
813 FXFT_Set_Charmap(pFace, charmap); | 811 FXFT_Set_Charmap(pFace, charmap); |
814 return FALSE; | 812 return false; |
815 } | 813 } |
816 return TRUE; | 814 return true; |
817 } | 815 } |
818 | 816 |
819 CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByLanguage( | 817 CFGAS_GEFont* CFGAS_FontMgrImp::GetFontByLanguage( |
820 uint16_t wLanguage, | 818 uint16_t wLanguage, |
821 uint32_t dwFontStyles, | 819 uint32_t dwFontStyles, |
822 const FX_WCHAR* pszFontFamily) { | 820 const FX_WCHAR* pszFontFamily) { |
823 return GetFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), dwFontStyles, | 821 return GetFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), dwFontStyles, |
824 pszFontFamily); | 822 pszFontFamily); |
825 } | 823 } |
826 | 824 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 if (!hFont) | 925 if (!hFont) |
928 return nullptr; | 926 return nullptr; |
929 | 927 |
930 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); | 928 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); |
931 if (dwFileSize == 0) | 929 if (dwFileSize == 0) |
932 return nullptr; | 930 return nullptr; |
933 | 931 |
934 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); | 932 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); |
935 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); | 933 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); |
936 | 934 |
937 return FX_CreateMemoryStream(pBuffer, dwFileSize, TRUE); | 935 return FX_CreateMemoryStream(pBuffer, dwFileSize, true); |
938 } | 936 } |
939 | 937 |
940 IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream( | 938 IFX_SeekableReadStream* CFGAS_FontMgrImp::CreateFontStream( |
941 const CFX_ByteString& bsFaceName) { | 939 const CFX_ByteString& bsFaceName) { |
942 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 940 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
943 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); | 941 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); |
944 | 942 |
945 if (!pFontMapper) | 943 if (!pFontMapper) |
946 return nullptr; | 944 return nullptr; |
947 | 945 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 | 1375 |
1378 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, | 1376 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, |
1379 const CFX_WideString& Name2) { | 1377 const CFX_WideString& Name2) { |
1380 if (Name1.Find(Name2.c_str()) != -1) { | 1378 if (Name1.Find(Name2.c_str()) != -1) { |
1381 return 1; | 1379 return 1; |
1382 } | 1380 } |
1383 return 0; | 1381 return 0; |
1384 } | 1382 } |
1385 | 1383 |
1386 #endif | 1384 #endif |
OLD | NEW |