| 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 "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 "xfa/fgas/crt/fgas_codepage.h" | 10 #include "xfa/fgas/crt/fgas_codepage.h" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 void* pUserData) | 589 void* pUserData) |
| 590 : m_pFontSource(pFontEnum), | 590 : m_pFontSource(pFontEnum), |
| 591 m_pDelegate(pDelegate), | 591 m_pDelegate(pDelegate), |
| 592 m_pUserData(pUserData) {} | 592 m_pUserData(pUserData) {} |
| 593 | 593 |
| 594 FX_BOOL CFX_FontMgrImp::EnumFontsFromFontMapper() { | 594 FX_BOOL CFX_FontMgrImp::EnumFontsFromFontMapper() { |
| 595 CFX_FontMapper* pFontMapper = | 595 CFX_FontMapper* pFontMapper = |
| 596 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); | 596 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); |
| 597 if (!pFontMapper) | 597 if (!pFontMapper) |
| 598 return FALSE; | 598 return FALSE; |
| 599 |
| 599 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 600 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 600 if (!pSystemFontInfo) | 601 if (!pSystemFontInfo) |
| 601 return FALSE; | 602 return FALSE; |
| 603 |
| 602 pSystemFontInfo->EnumFontList(pFontMapper); | 604 pSystemFontInfo->EnumFontList(pFontMapper); |
| 603 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { | 605 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { |
| 604 IFX_FileRead* pFontStream = | 606 IFX_FileRead* pFontStream = |
| 605 CreateFontStream(pFontMapper, pSystemFontInfo, i); | 607 CreateFontStream(pFontMapper, pSystemFontInfo, i); |
| 606 if (!pFontStream) | 608 if (!pFontStream) |
| 607 continue; | 609 continue; |
| 610 |
| 608 CFX_WideString wsFaceName = | 611 CFX_WideString wsFaceName = |
| 609 CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str()); | 612 CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str()); |
| 610 RegisterFaces(pFontStream, &wsFaceName); | 613 RegisterFaces(pFontStream, &wsFaceName); |
| 611 pFontStream->Release(); | 614 pFontStream->Release(); |
| 612 } | 615 } |
| 613 if (m_InstalledFonts.GetSize() == 0) | 616 if (m_InstalledFonts.GetSize() == 0) |
| 614 return FALSE; | 617 return FALSE; |
| 618 |
| 615 return TRUE; | 619 return TRUE; |
| 616 } | 620 } |
| 621 |
| 617 FX_BOOL CFX_FontMgrImp::EnumFontsFromFiles() { | 622 FX_BOOL CFX_FontMgrImp::EnumFontsFromFiles() { |
| 618 CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); | 623 CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); |
| 619 FX_POSITION pos = m_pFontSource->GetStartPosition(); | 624 FX_POSITION pos = m_pFontSource->GetStartPosition(); |
| 620 IFX_FileAccess* pFontSource = nullptr; | 625 IFX_FileAccess* pFontSource = nullptr; |
| 621 IFX_FileRead* pFontStream = nullptr; | 626 IFX_FileRead* pFontStream = nullptr; |
| 622 while (pos) { | 627 while (pos) { |
| 623 pFontSource = m_pFontSource->GetNext(pos); | 628 pFontSource = m_pFontSource->GetNext(pos); |
| 624 pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); | 629 pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); |
| 625 if (!pFontStream) { | 630 if (!pFontStream) { |
| 626 pFontSource->Release(); | 631 pFontSource->Release(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 : m_pDelegate->GetDefFontByUnicode( | 715 : m_pDelegate->GetDefFontByUnicode( |
| 711 this, wUnicode, dwFontStyles, pszFontFamily); | 716 this, wUnicode, dwFontStyles, pszFontFamily); |
| 712 } | 717 } |
| 713 IFX_Font* CFX_FontMgrImp::GetDefFontByLanguage(uint16_t wLanguage, | 718 IFX_Font* CFX_FontMgrImp::GetDefFontByLanguage(uint16_t wLanguage, |
| 714 uint32_t dwFontStyles, | 719 uint32_t dwFontStyles, |
| 715 const FX_WCHAR* pszFontFamily) { | 720 const FX_WCHAR* pszFontFamily) { |
| 716 return NULL == m_pDelegate ? NULL : m_pDelegate->GetDefFontByLanguage( | 721 return NULL == m_pDelegate ? NULL : m_pDelegate->GetDefFontByLanguage( |
| 717 this, wLanguage, dwFontStyles, | 722 this, wLanguage, dwFontStyles, |
| 718 pszFontFamily); | 723 pszFontFamily); |
| 719 } | 724 } |
| 725 |
| 720 IFX_Font* CFX_FontMgrImp::GetFontByCodePage(uint16_t wCodePage, | 726 IFX_Font* CFX_FontMgrImp::GetFontByCodePage(uint16_t wCodePage, |
| 721 uint32_t dwFontStyles, | 727 uint32_t dwFontStyles, |
| 722 const FX_WCHAR* pszFontFamily) { | 728 const FX_WCHAR* pszFontFamily) { |
| 723 CFX_ByteString bsHash; | 729 CFX_ByteString bsHash; |
| 724 bsHash.Format("%d, %d", wCodePage, dwFontStyles); | 730 bsHash.Format("%d, %d", wCodePage, dwFontStyles); |
| 725 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); | 731 bsHash += CFX_WideString(pszFontFamily).UTF8Encode(); |
| 726 uint32_t dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); | 732 uint32_t dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); |
| 727 CFX_ArrayTemplate<IFX_Font*>* pFonts = NULL; | 733 |
| 728 IFX_Font* pFont = NULL; | 734 CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr; |
| 729 if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { | 735 if (m_Hash2Fonts.Lookup(dwHash, pFonts)) { |
| 730 if (NULL == pFonts) { | 736 if (!pFonts) |
| 731 return NULL; | 737 return nullptr; |
| 732 } | 738 |
| 733 if (0 != pFonts->GetSize()) { | 739 if (pFonts->GetSize() != 0) |
| 734 return pFonts->GetAt(0)->Retain(); | 740 return pFonts->GetAt(0)->Retain(); |
| 735 } | |
| 736 } | 741 } |
| 742 |
| 737 if (!pFonts) | 743 if (!pFonts) |
| 738 pFonts = new CFX_ArrayTemplate<IFX_Font*>; | 744 pFonts = new CFX_ArrayTemplate<IFX_Font*>; |
| 745 |
| 739 m_Hash2Fonts.SetAt(dwHash, pFonts); | 746 m_Hash2Fonts.SetAt(dwHash, pFonts); |
| 740 CFX_FontDescriptorInfos* sortedFonts = NULL; | 747 CFX_FontDescriptorInfos* sortedFonts = nullptr; |
| 741 if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { | 748 if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { |
| 742 sortedFonts = new CFX_FontDescriptorInfos; | 749 sortedFonts = new CFX_FontDescriptorInfos; |
| 743 MatchFonts(*sortedFonts, wCodePage, dwFontStyles, | 750 MatchFonts(*sortedFonts, wCodePage, dwFontStyles, |
| 744 CFX_WideString(pszFontFamily), 0); | 751 CFX_WideString(pszFontFamily), 0); |
| 745 m_Hash2CandidateList.SetAt(dwHash, sortedFonts); | 752 m_Hash2CandidateList.SetAt(dwHash, sortedFonts); |
| 746 } | 753 } |
| 747 if (sortedFonts->GetSize() == 0) { | 754 if (sortedFonts->GetSize() == 0) |
| 748 return NULL; | 755 return nullptr; |
| 749 } | 756 |
| 750 CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont; | 757 CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont; |
| 751 if (pDesc->m_pFileAccess) | 758 IFX_Font* pFont = |
| 752 pFont = LoadFont(pDesc->m_pFileAccess, pDesc->m_nFaceIndex, nullptr); | 759 pDesc->m_pFileAccess |
| 753 else | 760 ? LoadFont(pDesc->m_pFileAccess, pDesc->m_nFaceIndex, nullptr) |
| 754 pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); | 761 : LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); |
| 755 if (NULL != pFont) { | 762 if (pFont) |
| 756 pFont->SetLogicalFontStyle(dwFontStyles); | 763 pFont->SetLogicalFontStyle(dwFontStyles); |
| 757 } | 764 |
| 758 pFonts->Add(pFont); | 765 pFonts->Add(pFont); |
| 759 return pFont; | 766 return pFont; |
| 760 } | 767 } |
| 761 IFX_Font* CFX_FontMgrImp::GetFontByCharset(uint8_t nCharset, | 768 IFX_Font* CFX_FontMgrImp::GetFontByCharset(uint8_t nCharset, |
| 762 uint32_t dwFontStyles, | 769 uint32_t dwFontStyles, |
| 763 const FX_WCHAR* pszFontFamily) { | 770 const FX_WCHAR* pszFontFamily) { |
| 764 return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, | 771 return GetFontByCodePage(FX_GetCodePageFromCharset(nCharset), dwFontStyles, |
| 765 pszFontFamily); | 772 pszFontFamily); |
| 766 } | 773 } |
| 767 IFX_Font* CFX_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode, | 774 IFX_Font* CFX_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); | 837 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); |
| 831 FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); | 838 FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); |
| 832 pFileRead->Release(); | 839 pFileRead->Release(); |
| 833 if (!pFace) | 840 if (!pFace) |
| 834 return FALSE; | 841 return FALSE; |
| 835 if (FXFT_Get_Face_External_Stream(pFace)) | 842 if (FXFT_Get_Face_External_Stream(pFace)) |
| 836 FXFT_Clear_Face_External_Stream(pFace); | 843 FXFT_Clear_Face_External_Stream(pFace); |
| 837 FXFT_Done_Face(pFace); | 844 FXFT_Done_Face(pFace); |
| 838 return !retCharmap && retIndex; | 845 return !retCharmap && retIndex; |
| 839 } | 846 } |
| 847 |
| 840 FX_BOOL CFX_FontMgrImp::VerifyUnicode(IFX_Font* pFont, FX_WCHAR wcUnicode) { | 848 FX_BOOL CFX_FontMgrImp::VerifyUnicode(IFX_Font* pFont, FX_WCHAR wcUnicode) { |
| 841 if (NULL == pFont) { | 849 if (!pFont) |
| 842 return FALSE; | 850 return FALSE; |
| 843 } | 851 |
| 844 FXFT_Face pFace = ((CFX_Font*)pFont->GetDevFont())->GetFace(); | 852 FXFT_Face pFace = ((CFX_Font*)pFont->GetDevFont())->GetFace(); |
| 845 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); | 853 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); |
| 846 if (0 != FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE)) { | 854 if (FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE) != 0) |
| 847 return FALSE; | 855 return FALSE; |
| 848 } | 856 |
| 849 if (0 == FXFT_Get_Char_Index(pFace, wcUnicode)) { | 857 if (FXFT_Get_Char_Index(pFace, wcUnicode) == 0) { |
| 850 FXFT_Set_Charmap(pFace, charmap); | 858 FXFT_Set_Charmap(pFace, charmap); |
| 851 return FALSE; | 859 return FALSE; |
| 852 } | 860 } |
| 853 return TRUE; | 861 return TRUE; |
| 854 } | 862 } |
| 863 |
| 855 IFX_Font* CFX_FontMgrImp::GetFontByLanguage(uint16_t wLanguage, | 864 IFX_Font* CFX_FontMgrImp::GetFontByLanguage(uint16_t wLanguage, |
| 856 uint32_t dwFontStyles, | 865 uint32_t dwFontStyles, |
| 857 const FX_WCHAR* pszFontFamily) { | 866 const FX_WCHAR* pszFontFamily) { |
| 858 return GetFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), dwFontStyles, | 867 return GetFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), dwFontStyles, |
| 859 pszFontFamily); | 868 pszFontFamily); |
| 860 } | 869 } |
| 870 |
| 861 IFX_Font* CFX_FontMgrImp::LoadFont(const uint8_t* pBuffer, | 871 IFX_Font* CFX_FontMgrImp::LoadFont(const uint8_t* pBuffer, |
| 862 int32_t iLength, | 872 int32_t iLength, |
| 863 int32_t iFaceIndex, | 873 int32_t iFaceIndex, |
| 864 int32_t* pFaceCount) { | 874 int32_t* pFaceCount) { |
| 865 void* Hash[2] = {(void*)(uintptr_t)pBuffer, (void*)(uintptr_t)iLength}; | 875 void* Hash[2] = {(void*)(uintptr_t)pBuffer, (void*)(uintptr_t)iLength}; |
| 866 uint32_t dwHash = | 876 uint32_t dwHash = |
| 867 FX_HashCode_String_GetA((const FX_CHAR*)Hash, 2 * sizeof(void*)); | 877 FX_HashCode_String_GetA((const FX_CHAR*)Hash, 2 * sizeof(void*)); |
| 868 IFX_FileAccess* pFontAccess = NULL; | 878 IFX_FileAccess* pFontAccess = nullptr; |
| 869 if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) { | 879 m_Hash2FileAccess.Lookup(dwHash, pFontAccess); |
| 870 } | 880 return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE) |
| 871 if (NULL != pFontAccess) { | 881 : nullptr; |
| 872 return LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE); | |
| 873 } else { | |
| 874 return NULL; | |
| 875 } | |
| 876 } | 882 } |
| 883 |
| 877 IFX_Font* CFX_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName, | 884 IFX_Font* CFX_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName, |
| 878 int32_t iFaceIndex, | 885 int32_t iFaceIndex, |
| 879 int32_t* pFaceCount) { | 886 int32_t* pFaceCount) { |
| 880 CFX_ByteString bsHash; | 887 CFX_ByteString bsHash; |
| 881 bsHash += CFX_WideString(pszFileName).UTF8Encode(); | 888 bsHash += CFX_WideString(pszFileName).UTF8Encode(); |
| 889 |
| 882 uint32_t dwHash = | 890 uint32_t dwHash = |
| 883 FX_HashCode_String_GetA((const FX_CHAR*)bsHash, bsHash.GetLength()); | 891 FX_HashCode_String_GetA((const FX_CHAR*)bsHash, bsHash.GetLength()); |
| 884 IFX_FileAccess* pFontAccess = NULL; | 892 IFX_FileAccess* pFontAccess = nullptr; |
| 885 if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) { | 893 if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) { |
| 886 pFontAccess = FX_CreateDefaultFileAccess(pszFileName); | 894 pFontAccess = FX_CreateDefaultFileAccess(pszFileName); |
| 887 m_Hash2FileAccess.SetAt(dwHash, pFontAccess); | 895 m_Hash2FileAccess.SetAt(dwHash, pFontAccess); |
| 888 } | 896 } |
| 889 if (NULL != pFontAccess) { | 897 |
| 890 return LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE); | 898 return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE) |
| 891 } else { | 899 : nullptr; |
| 892 return NULL; | |
| 893 } | |
| 894 } | 900 } |
| 901 |
| 895 IFX_Font* CFX_FontMgrImp::LoadFont(IFX_Stream* pFontStream, | 902 IFX_Font* CFX_FontMgrImp::LoadFont(IFX_Stream* pFontStream, |
| 896 int32_t iFaceIndex, | 903 int32_t iFaceIndex, |
| 897 int32_t* pFaceCount, | 904 int32_t* pFaceCount, |
| 898 FX_BOOL bSaveStream) { | 905 FX_BOOL bSaveStream) { |
| 899 void* Hash[1] = {(void*)(uintptr_t)pFontStream}; | 906 void* Hash[1] = {(void*)(uintptr_t)pFontStream}; |
| 900 uint32_t dwHash = | 907 uint32_t dwHash = |
| 901 FX_HashCode_String_GetA((const FX_CHAR*)Hash, 1 * sizeof(void*)); | 908 FX_HashCode_String_GetA((const FX_CHAR*)Hash, 1 * sizeof(void*)); |
| 902 IFX_FileAccess* pFontAccess = NULL; | 909 IFX_FileAccess* pFontAccess = nullptr; |
| 903 if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) { | 910 m_Hash2FileAccess.Lookup(dwHash, pFontAccess); |
| 904 } | 911 |
| 905 if (NULL != pFontAccess) { | 912 return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE) |
| 906 return LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE); | 913 : nullptr; |
| 907 } else { | |
| 908 return NULL; | |
| 909 } | |
| 910 } | 914 } |
| 915 |
| 911 IFX_Font* CFX_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess, | 916 IFX_Font* CFX_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess, |
| 912 int32_t iFaceIndex, | 917 int32_t iFaceIndex, |
| 913 int32_t* pFaceCount, | 918 int32_t* pFaceCount, |
| 914 FX_BOOL bWantCache) { | 919 FX_BOOL bWantCache) { |
| 915 uint32_t dwHash = 0; | 920 uint32_t dwHash = 0; |
| 916 IFX_Font* pFont = NULL; | 921 IFX_Font* pFont = nullptr; |
| 917 if (bWantCache) { | 922 if (bWantCache) { |
| 918 CFX_ByteString bsHash; | 923 CFX_ByteString bsHash; |
| 919 bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex); | 924 bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex); |
| 920 dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); | 925 dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength()); |
| 921 if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) { | 926 if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) { |
| 922 if (NULL != pFont) { | 927 if (pFont) { |
| 923 if (NULL != pFaceCount) { | 928 if (pFaceCount) |
| 924 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; | 929 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; |
| 925 } | |
| 926 return pFont->Retain(); | 930 return pFont->Retain(); |
| 927 } | 931 } |
| 928 } | 932 } |
| 929 } | 933 } |
| 934 |
| 930 CFX_Font* pInternalFont = new CFX_Font; | 935 CFX_Font* pInternalFont = new CFX_Font; |
| 931 IFX_FileRead* pFontStream = | 936 IFX_FileRead* pFontStream = |
| 932 pFontAccess->CreateFileStream(FX_FILEMODE_ReadOnly); | 937 pFontAccess->CreateFileStream(FX_FILEMODE_ReadOnly); |
| 933 if (NULL == pFontStream) { | 938 if (!pFontStream) { |
| 934 delete pInternalFont; | 939 delete pInternalFont; |
| 935 return NULL; | 940 return nullptr; |
| 936 } | 941 } |
| 937 if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { | 942 if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { |
| 938 delete pInternalFont; | 943 delete pInternalFont; |
| 939 pFontStream->Release(); | 944 pFontStream->Release(); |
| 940 return NULL; | 945 return nullptr; |
| 941 } | 946 } |
| 942 pFont = IFX_Font::LoadFont(pInternalFont, this, TRUE); | 947 pFont = IFX_Font::LoadFont(pInternalFont, this, TRUE); |
| 943 if (NULL == pFont) { | 948 if (!pFont) { |
| 944 delete pInternalFont; | 949 delete pInternalFont; |
| 945 pFontStream->Release(); | 950 pFontStream->Release(); |
| 946 return NULL; | 951 return nullptr; |
| 947 } | 952 } |
| 948 if (bWantCache) { | 953 if (bWantCache) |
| 949 m_FileAccess2IFXFont.SetAt(dwHash, pFont); | 954 m_FileAccess2IFXFont.SetAt(dwHash, pFont); |
| 950 } | 955 |
| 951 m_IFXFont2FileRead.SetAt(pFont, pFontStream); | 956 m_IFXFont2FileRead.SetAt(pFont, pFontStream); |
| 952 if (NULL != pFaceCount) { | 957 if (pFaceCount) |
| 953 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; | 958 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; |
| 954 } | 959 |
| 955 return pFont; | 960 return pFont; |
| 956 } | 961 } |
| 962 |
| 957 IFX_Font* CFX_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName, | 963 IFX_Font* CFX_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName, |
| 958 int32_t iFaceIndex, | 964 int32_t iFaceIndex, |
| 959 int32_t* pFaceCount) { | 965 int32_t* pFaceCount) { |
| 960 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 966 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 961 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); | 967 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); |
| 962 if (!pFontMapper) | 968 if (!pFontMapper) |
| 963 return nullptr; | 969 return nullptr; |
| 970 |
| 964 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 971 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 965 if (!pSystemFontInfo) | 972 if (!pSystemFontInfo) |
| 966 return nullptr; | 973 return nullptr; |
| 974 |
| 967 IFX_FileRead* pFontStream = CreateFontStream(wsFaceName.UTF8Encode()); | 975 IFX_FileRead* pFontStream = CreateFontStream(wsFaceName.UTF8Encode()); |
| 968 if (!pFontStream) | 976 if (!pFontStream) |
| 969 return nullptr; | 977 return nullptr; |
| 978 |
| 970 if (!LoadFace(pFontStream, 0)) { | 979 if (!LoadFace(pFontStream, 0)) { |
| 971 pFontStream->Release(); | 980 pFontStream->Release(); |
| 972 return nullptr; | 981 return nullptr; |
| 973 } | 982 } |
| 983 |
| 974 CFX_Font* pInternalFont = new CFX_Font(); | 984 CFX_Font* pInternalFont = new CFX_Font(); |
| 975 if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { | 985 if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { |
| 976 pFontStream->Release(); | 986 pFontStream->Release(); |
| 977 return nullptr; | 987 return nullptr; |
| 978 } | 988 } |
| 989 |
| 979 IFX_Font* pFont = IFX_Font::LoadFont(pInternalFont, this, FALSE); | 990 IFX_Font* pFont = IFX_Font::LoadFont(pInternalFont, this, FALSE); |
| 980 if (!pFont) { | 991 if (!pFont) { |
| 981 pFontStream->Release(); | 992 pFontStream->Release(); |
| 982 return nullptr; | 993 return nullptr; |
| 983 } | 994 } |
| 995 |
| 984 m_IFXFont2FileRead.SetAt(pFont, pFontStream); | 996 m_IFXFont2FileRead.SetAt(pFont, pFontStream); |
| 985 if (pFaceCount) | 997 if (pFaceCount) |
| 986 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; | 998 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; |
| 999 |
| 987 return pFont; | 1000 return pFont; |
| 988 } | 1001 } |
| 1002 |
| 989 extern "C" { | 1003 extern "C" { |
| 1004 |
| 990 unsigned long _ftStreamRead(FXFT_Stream stream, | 1005 unsigned long _ftStreamRead(FXFT_Stream stream, |
| 991 unsigned long offset, | 1006 unsigned long offset, |
| 992 unsigned char* buffer, | 1007 unsigned char* buffer, |
| 993 unsigned long count) { | 1008 unsigned long count) { |
| 994 if (count == 0) { | 1009 if (count == 0) |
| 995 return 0; | 1010 return 0; |
| 996 } | 1011 |
| 997 IFX_FileRead* pFile = (IFX_FileRead*)stream->descriptor.pointer; | 1012 IFX_FileRead* pFile = (IFX_FileRead*)stream->descriptor.pointer; |
| 998 int res = pFile->ReadBlock(buffer, offset, count); | 1013 int res = pFile->ReadBlock(buffer, offset, count); |
| 999 if (res) { | 1014 if (res) |
| 1000 return count; | 1015 return count; |
| 1001 } | |
| 1002 return 0; | 1016 return 0; |
| 1003 } | 1017 } |
| 1018 |
| 1004 void _ftStreamClose(FXFT_Stream stream) {} | 1019 void _ftStreamClose(FXFT_Stream stream) {} |
| 1005 }; | 1020 |
| 1021 }; // extern "C" |
| 1006 | 1022 |
| 1007 FXFT_Face CFX_FontMgrImp::LoadFace(IFX_FileRead* pFontStream, | 1023 FXFT_Face CFX_FontMgrImp::LoadFace(IFX_FileRead* pFontStream, |
| 1008 int32_t iFaceIndex) { | 1024 int32_t iFaceIndex) { |
| 1009 if (!pFontStream) | 1025 if (!pFontStream) |
| 1010 return nullptr; | 1026 return nullptr; |
| 1011 | 1027 |
| 1012 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 1028 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 1013 pFontMgr->InitFTLibrary(); | 1029 pFontMgr->InitFTLibrary(); |
| 1014 FXFT_Library library = pFontMgr->GetFTLibrary(); | 1030 FXFT_Library library = pFontMgr->GetFTLibrary(); |
| 1015 if (!library) | 1031 if (!library) |
| 1016 return nullptr; | 1032 return nullptr; |
| 1017 | 1033 |
| 1018 FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); | 1034 FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); |
| 1019 FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec)); | 1035 FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec)); |
| 1020 ftStream->base = NULL; | 1036 ftStream->base = nullptr; |
| 1021 ftStream->descriptor.pointer = pFontStream; | 1037 ftStream->descriptor.pointer = pFontStream; |
| 1022 ftStream->pos = 0; | 1038 ftStream->pos = 0; |
| 1023 ftStream->size = (unsigned long)pFontStream->GetSize(); | 1039 ftStream->size = (unsigned long)pFontStream->GetSize(); |
| 1024 ftStream->read = _ftStreamRead; | 1040 ftStream->read = _ftStreamRead; |
| 1025 ftStream->close = _ftStreamClose; | 1041 ftStream->close = _ftStreamClose; |
| 1026 | 1042 |
| 1027 FXFT_Open_Args ftArgs; | 1043 FXFT_Open_Args ftArgs; |
| 1028 FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args)); | 1044 FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args)); |
| 1029 ftArgs.flags |= FT_OPEN_STREAM; | 1045 ftArgs.flags |= FT_OPEN_STREAM; |
| 1030 ftArgs.stream = ftStream; | 1046 ftArgs.stream = ftStream; |
| 1031 | 1047 |
| 1032 FXFT_Face pFace = NULL; | 1048 FXFT_Face pFace = nullptr; |
| 1033 if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { | 1049 if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { |
| 1034 FX_Free(ftStream); | 1050 FX_Free(ftStream); |
| 1035 return nullptr; | 1051 return nullptr; |
| 1036 } | 1052 } |
| 1037 | 1053 |
| 1038 FXFT_Set_Pixel_Sizes(pFace, 0, 64); | 1054 FXFT_Set_Pixel_Sizes(pFace, 0, 64); |
| 1039 return pFace; | 1055 return pFace; |
| 1040 } | 1056 } |
| 1041 | 1057 |
| 1042 IFX_FileRead* CFX_FontMgrImp::CreateFontStream( | 1058 IFX_FileRead* CFX_FontMgrImp::CreateFontStream( |
| 1043 CFX_FontMapper* pFontMapper, | 1059 CFX_FontMapper* pFontMapper, |
| 1044 IFX_SystemFontInfo* pSystemFontInfo, | 1060 IFX_SystemFontInfo* pSystemFontInfo, |
| 1045 uint32_t index) { | 1061 uint32_t index) { |
| 1046 int iExact = 0; | 1062 int iExact = 0; |
| 1047 void* hFont = pSystemFontInfo->MapFont( | 1063 void* hFont = pSystemFontInfo->MapFont( |
| 1048 0, 0, FXFONT_DEFAULT_CHARSET, 0, pFontMapper->GetFaceName(index), iExact); | 1064 0, 0, FXFONT_DEFAULT_CHARSET, 0, pFontMapper->GetFaceName(index), iExact); |
| 1049 if (!hFont) | 1065 if (!hFont) |
| 1050 return nullptr; | 1066 return nullptr; |
| 1067 |
| 1051 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); | 1068 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); |
| 1052 if (dwFileSize == 0) | 1069 if (dwFileSize == 0) |
| 1053 return nullptr; | 1070 return nullptr; |
| 1071 |
| 1054 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); | 1072 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); |
| 1055 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); | 1073 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); |
| 1074 |
| 1056 return FX_CreateMemoryStream(pBuffer, dwFileSize, TRUE); | 1075 return FX_CreateMemoryStream(pBuffer, dwFileSize, TRUE); |
| 1057 } | 1076 } |
| 1058 | 1077 |
| 1059 IFX_FileRead* CFX_FontMgrImp::CreateFontStream( | 1078 IFX_FileRead* CFX_FontMgrImp::CreateFontStream( |
| 1060 const CFX_ByteString& bsFaceName) { | 1079 const CFX_ByteString& bsFaceName) { |
| 1061 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 1080 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 1062 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); | 1081 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); |
| 1082 |
| 1063 if (!pFontMapper) | 1083 if (!pFontMapper) |
| 1064 return nullptr; | 1084 return nullptr; |
| 1085 |
| 1065 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 1086 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 1066 if (!pSystemFontInfo) | 1087 if (!pSystemFontInfo) |
| 1067 return nullptr; | 1088 return nullptr; |
| 1089 |
| 1068 pSystemFontInfo->EnumFontList(pFontMapper); | 1090 pSystemFontInfo->EnumFontList(pFontMapper); |
| 1069 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { | 1091 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { |
| 1070 if (pFontMapper->GetFaceName(i) == bsFaceName) | 1092 if (pFontMapper->GetFaceName(i) == bsFaceName) |
| 1071 return CreateFontStream(pFontMapper, pSystemFontInfo, i); | 1093 return CreateFontStream(pFontMapper, pSystemFontInfo, i); |
| 1072 } | 1094 } |
| 1073 return nullptr; | 1095 return nullptr; |
| 1074 } | 1096 } |
| 1075 int32_t CFX_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, | 1097 int32_t CFX_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, |
| 1076 uint16_t wCodePage, | 1098 uint16_t wCodePage, |
| 1077 uint32_t dwFontStyles, | 1099 uint32_t dwFontStyles, |
| 1078 const CFX_WideString& FontName, | 1100 const CFX_WideString& FontName, |
| 1079 FX_WCHAR wcUnicode) { | 1101 FX_WCHAR wcUnicode) { |
| 1080 MatchedFonts.RemoveAll(); | 1102 MatchedFonts.RemoveAll(); |
| 1081 CFX_WideString wsNormalizedFontName = FontName; | 1103 CFX_WideString wsNormalizedFontName = FontName; |
| 1082 static const int32_t nMax = 0xffff; | 1104 |
| 1083 CFX_FontDescriptor* pFont = NULL; | 1105 CFX_FontDescriptor* pFont = nullptr; |
| 1084 int32_t nCount = m_InstalledFonts.GetSize(); | 1106 int32_t nCount = m_InstalledFonts.GetSize(); |
| 1085 for (int32_t i = 0; i < nCount; i++) { | 1107 for (int32_t i = 0; i < nCount; i++) { |
| 1086 pFont = m_InstalledFonts[i]; | 1108 pFont = m_InstalledFonts[i]; |
| 1087 int32_t nPenalty = CalcPenalty(pFont, wCodePage, dwFontStyles, | 1109 int32_t nPenalty = CalcPenalty(pFont, wCodePage, dwFontStyles, |
| 1088 wsNormalizedFontName, wcUnicode); | 1110 wsNormalizedFontName, wcUnicode); |
| 1089 if (nPenalty >= 0xFFFF) { | 1111 if (nPenalty >= 0xffff) |
| 1090 continue; | 1112 continue; |
| 1091 } | 1113 |
| 1092 FX_FontDescriptorInfo FontInfo; | 1114 FX_FontDescriptorInfo FontInfo; |
| 1093 FontInfo.pFont = pFont; | 1115 FontInfo.pFont = pFont; |
| 1094 FontInfo.nPenalty = nPenalty; | 1116 FontInfo.nPenalty = nPenalty; |
| 1095 MatchedFonts.Add(FontInfo); | 1117 MatchedFonts.Add(FontInfo); |
| 1096 if (MatchedFonts.GetSize() == nMax) { | 1118 if (MatchedFonts.GetSize() == 0xffff) |
| 1097 break; | 1119 break; |
| 1098 } | |
| 1099 } | 1120 } |
| 1100 if (MatchedFonts.GetSize() == 0) { | 1121 if (MatchedFonts.GetSize() == 0) |
| 1101 return 0; | 1122 return 0; |
| 1102 } | 1123 |
| 1103 CFX_SSortTemplate<FX_FontDescriptorInfo> ssort; | 1124 CFX_SSortTemplate<FX_FontDescriptorInfo> ssort; |
| 1104 ssort.ShellSort(MatchedFonts.GetData(), MatchedFonts.GetSize()); | 1125 ssort.ShellSort(MatchedFonts.GetData(), MatchedFonts.GetSize()); |
| 1105 return MatchedFonts.GetSize(); | 1126 return MatchedFonts.GetSize(); |
| 1106 } | 1127 } |
| 1128 |
| 1107 struct FX_BitCodePage { | 1129 struct FX_BitCodePage { |
| 1108 uint16_t wBit; | 1130 uint16_t wBit; |
| 1109 uint16_t wCodePage; | 1131 uint16_t wCodePage; |
| 1110 }; | 1132 }; |
| 1111 static const FX_BitCodePage g_Bit2CodePage[] = { | 1133 static const FX_BitCodePage g_Bit2CodePage[] = { |
| 1112 {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255}, | 1134 {0, 1252}, {1, 1250}, {2, 1251}, {3, 1253}, {4, 1254}, {5, 1255}, |
| 1113 {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0}, | 1135 {6, 1256}, {7, 1257}, {8, 1258}, {9, 0}, {10, 0}, {11, 0}, |
| 1114 {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932}, | 1136 {12, 0}, {13, 0}, {14, 0}, {15, 0}, {16, 874}, {17, 932}, |
| 1115 {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0}, | 1137 {18, 936}, {19, 949}, {20, 950}, {21, 1361}, {22, 0}, {23, 0}, |
| 1116 {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0}, | 1138 {24, 0}, {25, 0}, {26, 0}, {27, 0}, {28, 0}, {29, 0}, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 for (int32_t i = 0; i < pFonts->GetSize(); i++) { | 1295 for (int32_t i = 0; i < pFonts->GetSize(); i++) { |
| 1274 if (pFonts->GetAt(i) == pEFont) { | 1296 if (pFonts->GetAt(i) == pEFont) { |
| 1275 pFonts->SetAt(i, NULL); | 1297 pFonts->SetAt(i, NULL); |
| 1276 } | 1298 } |
| 1277 } | 1299 } |
| 1278 } else { | 1300 } else { |
| 1279 m_Hash2Fonts.RemoveKey(dwHash); | 1301 m_Hash2Fonts.RemoveKey(dwHash); |
| 1280 } | 1302 } |
| 1281 } | 1303 } |
| 1282 } | 1304 } |
| 1305 |
| 1283 void CFX_FontMgrImp::RegisterFace(FXFT_Face pFace, | 1306 void CFX_FontMgrImp::RegisterFace(FXFT_Face pFace, |
| 1284 CFX_FontDescriptors& Fonts, | 1307 CFX_FontDescriptors& Fonts, |
| 1285 const CFX_WideString* pFaceName, | 1308 const CFX_WideString* pFaceName, |
| 1286 IFX_FileAccess* pFontAccess) { | 1309 IFX_FileAccess* pFontAccess) { |
| 1287 if (0 == (pFace->face_flags & FT_FACE_FLAG_SCALABLE)) { | 1310 if ((pFace->face_flags & FT_FACE_FLAG_SCALABLE) == 0) |
| 1288 return; | 1311 return; |
| 1289 } | 1312 |
| 1290 CFX_FontDescriptor* pFont = new CFX_FontDescriptor; | 1313 CFX_FontDescriptor* pFont = new CFX_FontDescriptor; |
| 1291 pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FX_FONTSTYLE_Bold : 0; | 1314 pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FX_FONTSTYLE_Bold : 0; |
| 1292 pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FX_FONTSTYLE_Italic : 0; | 1315 pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FX_FONTSTYLE_Italic : 0; |
| 1293 pFont->m_dwFontStyles |= GetFlags(pFace); | 1316 pFont->m_dwFontStyles |= GetFlags(pFace); |
| 1317 |
| 1294 CFX_ArrayTemplate<uint16_t> Charsets; | 1318 CFX_ArrayTemplate<uint16_t> Charsets; |
| 1295 GetCharsets(pFace, Charsets); | 1319 GetCharsets(pFace, Charsets); |
| 1296 GetUSBCSB(pFace, pFont->m_dwUsb, pFont->m_dwCsb); | 1320 GetUSBCSB(pFace, pFont->m_dwUsb, pFont->m_dwCsb); |
| 1321 |
| 1322 FT_ULong dwTag; |
| 1323 uint8_t* pTable = nullptr; |
| 1324 FT_ENC_TAG(dwTag, 'n', 'a', 'm', 'e'); |
| 1325 |
| 1297 unsigned long nLength = 0; | 1326 unsigned long nLength = 0; |
| 1298 FT_ULong dwTag; | 1327 unsigned int error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, nullptr, &nLength); |
| 1299 uint8_t* pTable = NULL; | 1328 if (error == 0 && nLength != 0) { |
| 1300 FT_ENC_TAG(dwTag, 'n', 'a', 'm', 'e'); | |
| 1301 unsigned int error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, NULL, &nLength); | |
| 1302 if (0 == error && 0 != nLength) { | |
| 1303 pTable = FX_Alloc(uint8_t, nLength); | 1329 pTable = FX_Alloc(uint8_t, nLength); |
| 1304 error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, pTable, NULL); | 1330 error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, pTable, nullptr); |
| 1305 if (0 != error) { | 1331 if (0 != error) { |
| 1306 FX_Free(pTable); | 1332 FX_Free(pTable); |
| 1307 pTable = NULL; | 1333 pTable = nullptr; |
| 1308 } | 1334 } |
| 1309 } | 1335 } |
| 1310 GetNames(pTable, pFont->m_wsFamilyNames); | 1336 GetNames(pTable, pFont->m_wsFamilyNames); |
| 1311 if (NULL != pTable) { | 1337 if (pTable) |
| 1312 FX_Free(pTable); | 1338 FX_Free(pTable); |
| 1313 } | 1339 |
| 1314 pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode()); | 1340 pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode()); |
| 1315 if (pFaceName) { | 1341 pFont->m_wsFaceName = |
| 1316 pFont->m_wsFaceName = *pFaceName; | 1342 pFaceName ? *pFaceName |
| 1317 } else { | 1343 : CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace)); |
| 1318 pFont->m_wsFaceName = | |
| 1319 CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace)); | |
| 1320 } | |
| 1321 pFont->m_nFaceIndex = pFace->face_index; | 1344 pFont->m_nFaceIndex = pFace->face_index; |
| 1322 if (pFontAccess) | 1345 pFont->m_pFileAccess = pFontAccess ? pFontAccess->Retain() : nullptr; |
| 1323 pFont->m_pFileAccess = pFontAccess->Retain(); | 1346 |
| 1324 else | |
| 1325 pFont->m_pFileAccess = nullptr; | |
| 1326 Fonts.Add(pFont); | 1347 Fonts.Add(pFont); |
| 1327 } | 1348 } |
| 1349 |
| 1328 void CFX_FontMgrImp::RegisterFaces(IFX_FileRead* pFontStream, | 1350 void CFX_FontMgrImp::RegisterFaces(IFX_FileRead* pFontStream, |
| 1329 const CFX_WideString* pFaceName) { | 1351 const CFX_WideString* pFaceName) { |
| 1330 int32_t index = 0; | 1352 int32_t index = 0; |
| 1331 int32_t num_faces = 0; | 1353 int32_t num_faces = 0; |
| 1332 do { | 1354 do { |
| 1333 FXFT_Face pFace = LoadFace(pFontStream, index++); | 1355 FXFT_Face pFace = LoadFace(pFontStream, index++); |
| 1334 if (!pFace) | 1356 if (!pFace) |
| 1335 continue; | 1357 continue; |
| 1336 // All faces keep number of faces. It can be retrieved from any one face. | 1358 // All faces keep number of faces. It can be retrieved from any one face. |
| 1337 if (!num_faces) | 1359 if (num_faces == 0) |
| 1338 num_faces = pFace->num_faces; | 1360 num_faces = pFace->num_faces; |
| 1339 RegisterFace(pFace, m_InstalledFonts, pFaceName, nullptr); | 1361 RegisterFace(pFace, m_InstalledFonts, pFaceName, nullptr); |
| 1340 if (FXFT_Get_Face_External_Stream(pFace)) | 1362 if (FXFT_Get_Face_External_Stream(pFace)) |
| 1341 FXFT_Clear_Face_External_Stream(pFace); | 1363 FXFT_Clear_Face_External_Stream(pFace); |
| 1342 FXFT_Done_Face(pFace); | 1364 FXFT_Done_Face(pFace); |
| 1343 } while (index < num_faces); | 1365 } while (index < num_faces); |
| 1344 } | 1366 } |
| 1345 uint32_t CFX_FontMgrImp::GetFlags(FXFT_Face pFace) { | 1367 uint32_t CFX_FontMgrImp::GetFlags(FXFT_Face pFace) { |
| 1346 uint32_t flag = 0; | 1368 uint32_t flag = 0; |
| 1347 if (FT_IS_FIXED_WIDTH(pFace)) { | 1369 if (FT_IS_FIXED_WIDTH(pFace)) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 } | 1530 } |
| 1509 } | 1531 } |
| 1510 int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1, | 1532 int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1, |
| 1511 const CFX_WideString& Name2) { | 1533 const CFX_WideString& Name2) { |
| 1512 if (Name1.Find((const FX_WCHAR*)Name2) != -1) { | 1534 if (Name1.Find((const FX_WCHAR*)Name2) != -1) { |
| 1513 return 1; | 1535 return 1; |
| 1514 } | 1536 } |
| 1515 return 0; | 1537 return 0; |
| 1516 } | 1538 } |
| 1517 #endif | 1539 #endif |
| OLD | NEW |