| 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/cfgas_fontmgr.h" | 7 #include "xfa/fgas/font/cfgas_fontmgr.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 pos = m_Hash2Fonts.GetStartPosition(); | 600 pos = m_Hash2Fonts.GetStartPosition(); |
| 601 while (pos) { | 601 while (pos) { |
| 602 uint32_t dwHash; | 602 uint32_t dwHash; |
| 603 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; | 603 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; |
| 604 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); | 604 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
| 605 for (int32_t i = 0; i < pFonts->GetSize(); i++) | 605 for (int32_t i = 0; i < pFonts->GetSize(); i++) |
| 606 delete pFonts->GetAt(i); | 606 delete pFonts->GetAt(i); |
| 607 delete pFonts; | 607 delete pFonts; |
| 608 } | 608 } |
| 609 m_Hash2Fonts.RemoveAll(); | 609 m_Hash2Fonts.RemoveAll(); |
| 610 pos = m_IFXFont2FileRead.GetStartPosition(); | |
| 611 while (pos) { | |
| 612 CFGAS_GEFont* pFont; | |
| 613 IFX_SeekableReadStream* pFileRead; | |
| 614 m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); | |
| 615 pFileRead->Release(); | |
| 616 } | |
| 617 } | 610 } |
| 618 | 611 |
| 619 bool CFGAS_FontMgr::EnumFontsFromFontMapper() { | 612 bool CFGAS_FontMgr::EnumFontsFromFontMapper() { |
| 620 CFX_FontMapper* pFontMapper = | 613 CFX_FontMapper* pFontMapper = |
| 621 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); | 614 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper(); |
| 622 if (!pFontMapper) | 615 if (!pFontMapper) |
| 623 return false; | 616 return false; |
| 624 | 617 |
| 625 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 618 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 626 if (!pSystemFontInfo) | 619 if (!pSystemFontInfo) |
| 627 return false; | 620 return false; |
| 628 | 621 |
| 629 pSystemFontInfo->EnumFontList(pFontMapper); | 622 pSystemFontInfo->EnumFontList(pFontMapper); |
| 630 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { | 623 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { |
| 631 IFX_SeekableReadStream* pFontStream = | 624 CFX_RetainPtr<IFX_SeekableReadStream> pFontStream = |
| 632 CreateFontStream(pFontMapper, pSystemFontInfo, i); | 625 CreateFontStream(pFontMapper, pSystemFontInfo, i); |
| 633 if (!pFontStream) | 626 if (!pFontStream) |
| 634 continue; | 627 continue; |
| 635 | 628 |
| 636 CFX_WideString wsFaceName = | 629 CFX_WideString wsFaceName = |
| 637 CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str()); | 630 CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str()); |
| 638 RegisterFaces(pFontStream, &wsFaceName); | 631 RegisterFaces(pFontStream, &wsFaceName); |
| 639 pFontStream->Release(); | |
| 640 } | 632 } |
| 641 if (m_InstalledFonts.GetSize() == 0) | 633 return m_InstalledFonts.GetSize() != 0; |
| 642 return false; | |
| 643 | |
| 644 return true; | |
| 645 } | 634 } |
| 646 | 635 |
| 647 bool CFGAS_FontMgr::EnumFontsFromFiles() { | 636 bool CFGAS_FontMgr::EnumFontsFromFiles() { |
| 648 CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); | 637 CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); |
| 649 FX_POSITION pos = m_pFontSource->GetStartPosition(); | 638 FX_POSITION pos = m_pFontSource->GetStartPosition(); |
| 650 IFX_FileAccess* pFontSource = nullptr; | 639 IFX_FileAccess* pFontSource = nullptr; |
| 651 IFX_SeekableReadStream* pFontStream = nullptr; | 640 CFX_RetainPtr<IFX_SeekableReadStream> pFontStream; |
| 652 while (pos) { | 641 while (pos) { |
| 653 pFontSource = m_pFontSource->GetNext(pos); | 642 pFontSource = m_pFontSource->GetNext(pos); |
| 654 pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); | 643 pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); |
| 655 if (!pFontStream) { | 644 if (!pFontStream) { |
| 656 pFontSource->Release(); | 645 pFontSource->Release(); |
| 657 continue; | 646 continue; |
| 658 } | 647 } |
| 659 RegisterFaces(pFontStream, nullptr); | 648 RegisterFaces(pFontStream, nullptr); |
| 660 pFontStream->Release(); | |
| 661 pFontSource->Release(); | 649 pFontSource->Release(); |
| 662 } | 650 } |
| 663 if (m_InstalledFonts.GetSize() == 0) | 651 return m_InstalledFonts.GetSize() != 0; |
| 664 return false; | |
| 665 return true; | |
| 666 } | 652 } |
| 667 | 653 |
| 668 bool CFGAS_FontMgr::EnumFonts() { | 654 bool CFGAS_FontMgr::EnumFonts() { |
| 669 if (EnumFontsFromFontMapper()) | 655 if (EnumFontsFromFontMapper()) |
| 670 return true; | 656 return true; |
| 671 return EnumFontsFromFiles(); | 657 return EnumFontsFromFiles(); |
| 672 } | 658 } |
| 673 | 659 |
| 674 CFGAS_GEFont* CFGAS_FontMgr::GetFontByCodePage(uint16_t wCodePage, | 660 CFGAS_GEFont* CFGAS_FontMgr::GetFontByCodePage(uint16_t wCodePage, |
| 675 uint32_t dwFontStyles, | 661 uint32_t dwFontStyles, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 pFonts->Add(pFont); | 744 pFonts->Add(pFont); |
| 759 return pFont; | 745 return pFont; |
| 760 } | 746 } |
| 761 if (!pszFontFamily) | 747 if (!pszFontFamily) |
| 762 m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr); | 748 m_FailedUnicodes2Nullptr.SetAt(wUnicode, nullptr); |
| 763 return nullptr; | 749 return nullptr; |
| 764 } | 750 } |
| 765 | 751 |
| 766 bool CFGAS_FontMgr::VerifyUnicode(CFX_FontDescriptor* pDesc, | 752 bool CFGAS_FontMgr::VerifyUnicode(CFX_FontDescriptor* pDesc, |
| 767 FX_WCHAR wcUnicode) { | 753 FX_WCHAR wcUnicode) { |
| 768 IFX_SeekableReadStream* pFileRead = | 754 CFX_RetainPtr<IFX_SeekableReadStream> pFileRead = |
| 769 CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); | 755 CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); |
| 770 if (!pFileRead) | 756 if (!pFileRead) |
| 771 return false; | 757 return false; |
| 772 | 758 |
| 773 FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); | 759 FXFT_Face pFace = LoadFace(pFileRead, pDesc->m_nFaceIndex); |
| 774 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); | 760 FT_Error retCharmap = FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE); |
| 775 FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); | 761 FT_Error retIndex = FXFT_Get_Char_Index(pFace, wcUnicode); |
| 776 pFileRead->Release(); | |
| 777 if (!pFace) | 762 if (!pFace) |
| 778 return false; | 763 return false; |
| 779 | 764 |
| 780 if (FXFT_Get_Face_External_Stream(pFace)) | 765 if (FXFT_Get_Face_External_Stream(pFace)) |
| 781 FXFT_Clear_Face_External_Stream(pFace); | 766 FXFT_Clear_Face_External_Stream(pFace); |
| 767 |
| 782 FXFT_Done_Face(pFace); | 768 FXFT_Done_Face(pFace); |
| 783 return !retCharmap && retIndex; | 769 return !retCharmap && retIndex; |
| 784 } | 770 } |
| 785 | 771 |
| 786 bool CFGAS_FontMgr::VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode) { | 772 bool CFGAS_FontMgr::VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode) { |
| 787 if (!pFont) | 773 if (!pFont) |
| 788 return false; | 774 return false; |
| 789 | 775 |
| 790 FXFT_Face pFace = pFont->GetDevFont()->GetFace(); | 776 FXFT_Face pFace = pFont->GetDevFont()->GetFace(); |
| 791 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); | 777 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 804 int32_t* pFaceCount) { | 790 int32_t* pFaceCount) { |
| 805 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 791 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 806 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); | 792 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); |
| 807 if (!pFontMapper) | 793 if (!pFontMapper) |
| 808 return nullptr; | 794 return nullptr; |
| 809 | 795 |
| 810 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 796 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 811 if (!pSystemFontInfo) | 797 if (!pSystemFontInfo) |
| 812 return nullptr; | 798 return nullptr; |
| 813 | 799 |
| 814 IFX_SeekableReadStream* pFontStream = | 800 CFX_RetainPtr<IFX_SeekableReadStream> pFontStream = |
| 815 CreateFontStream(wsFaceName.UTF8Encode()); | 801 CreateFontStream(wsFaceName.UTF8Encode()); |
| 816 if (!pFontStream) | 802 if (!pFontStream) |
| 817 return nullptr; | 803 return nullptr; |
| 818 | 804 |
| 819 std::unique_ptr<CFX_Font> pInternalFont(new CFX_Font()); | 805 auto pInternalFont = pdfium::MakeUnique<CFX_Font>(); |
| 820 if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { | 806 if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) |
| 821 pFontStream->Release(); | |
| 822 return nullptr; | 807 return nullptr; |
| 823 } | |
| 824 | 808 |
| 825 CFGAS_GEFont* pFont = CFGAS_GEFont::LoadFont(std::move(pInternalFont), this); | 809 CFGAS_GEFont* pFont = CFGAS_GEFont::LoadFont(std::move(pInternalFont), this); |
| 826 if (!pFont) { | 810 if (!pFont) |
| 827 pFontStream->Release(); | |
| 828 return nullptr; | 811 return nullptr; |
| 829 } | |
| 830 | 812 |
| 831 m_IFXFont2FileRead.SetAt(pFont, pFontStream); | 813 m_IFXFont2FileRead[pFont] = pFontStream; |
| 832 if (pFaceCount) | 814 if (pFaceCount) |
| 833 *pFaceCount = pFont->GetDevFont()->GetFace()->num_faces; | 815 *pFaceCount = pFont->GetDevFont()->GetFace()->num_faces; |
| 834 | 816 |
| 835 return pFont; | 817 return pFont; |
| 836 } | 818 } |
| 837 | 819 |
| 838 extern "C" { | 820 extern "C" { |
| 839 | 821 |
| 840 unsigned long _ftStreamRead(FXFT_Stream stream, | 822 unsigned long _ftStreamRead(FXFT_Stream stream, |
| 841 unsigned long offset, | 823 unsigned long offset, |
| 842 unsigned char* buffer, | 824 unsigned char* buffer, |
| 843 unsigned long count) { | 825 unsigned long count) { |
| 844 if (count == 0) | 826 if (count == 0) |
| 845 return 0; | 827 return 0; |
| 846 | 828 |
| 847 IFX_SeekableReadStream* pFile = | 829 IFX_SeekableReadStream* pFile = |
| 848 (IFX_SeekableReadStream*)stream->descriptor.pointer; | 830 static_cast<IFX_SeekableReadStream*>(stream->descriptor.pointer); |
| 849 int res = pFile->ReadBlock(buffer, offset, count); | 831 if (!pFile->ReadBlock(buffer, offset, count)) |
| 850 if (res) | 832 return 0; |
| 851 return count; | 833 |
| 852 return 0; | 834 return count; |
| 853 } | 835 } |
| 854 | 836 |
| 855 void _ftStreamClose(FXFT_Stream stream) {} | 837 void _ftStreamClose(FXFT_Stream stream) {} |
| 856 | 838 |
| 857 }; // extern "C" | 839 }; // extern "C" |
| 858 | 840 |
| 859 FXFT_Face CFGAS_FontMgr::LoadFace(IFX_SeekableReadStream* pFontStream, | 841 FXFT_Face CFGAS_FontMgr::LoadFace( |
| 860 int32_t iFaceIndex) { | 842 const CFX_RetainPtr<IFX_SeekableReadStream>& pFontStream, |
| 843 int32_t iFaceIndex) { |
| 861 if (!pFontStream) | 844 if (!pFontStream) |
| 862 return nullptr; | 845 return nullptr; |
| 863 | 846 |
| 864 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 847 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 865 pFontMgr->InitFTLibrary(); | 848 pFontMgr->InitFTLibrary(); |
| 849 |
| 866 FXFT_Library library = pFontMgr->GetFTLibrary(); | 850 FXFT_Library library = pFontMgr->GetFTLibrary(); |
| 867 if (!library) | 851 if (!library) |
| 868 return nullptr; | 852 return nullptr; |
| 869 | 853 |
| 870 FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); | 854 FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); |
| 871 FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec)); | 855 FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec)); |
| 872 ftStream->base = nullptr; | 856 ftStream->base = nullptr; |
| 873 ftStream->descriptor.pointer = pFontStream; | 857 ftStream->descriptor.pointer = static_cast<void*>(pFontStream.Get()); |
| 874 ftStream->pos = 0; | 858 ftStream->pos = 0; |
| 875 ftStream->size = static_cast<unsigned long>(pFontStream->GetSize()); | 859 ftStream->size = static_cast<unsigned long>(pFontStream->GetSize()); |
| 876 ftStream->read = _ftStreamRead; | 860 ftStream->read = _ftStreamRead; |
| 877 ftStream->close = _ftStreamClose; | 861 ftStream->close = _ftStreamClose; |
| 878 | 862 |
| 879 FXFT_Open_Args ftArgs; | 863 FXFT_Open_Args ftArgs; |
| 880 FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args)); | 864 FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args)); |
| 881 ftArgs.flags |= FT_OPEN_STREAM; | 865 ftArgs.flags |= FT_OPEN_STREAM; |
| 882 ftArgs.stream = ftStream; | 866 ftArgs.stream = ftStream; |
| 883 | 867 |
| 884 FXFT_Face pFace = nullptr; | 868 FXFT_Face pFace = nullptr; |
| 885 if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { | 869 if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { |
| 886 FX_Free(ftStream); | 870 FX_Free(ftStream); |
| 887 return nullptr; | 871 return nullptr; |
| 888 } | 872 } |
| 889 | 873 |
| 890 FXFT_Set_Pixel_Sizes(pFace, 0, 64); | 874 FXFT_Set_Pixel_Sizes(pFace, 0, 64); |
| 891 return pFace; | 875 return pFace; |
| 892 } | 876 } |
| 893 | 877 |
| 894 IFX_SeekableReadStream* CFGAS_FontMgr::CreateFontStream( | 878 CFX_RetainPtr<IFX_SeekableReadStream> CFGAS_FontMgr::CreateFontStream( |
| 895 CFX_FontMapper* pFontMapper, | 879 CFX_FontMapper* pFontMapper, |
| 896 IFX_SystemFontInfo* pSystemFontInfo, | 880 IFX_SystemFontInfo* pSystemFontInfo, |
| 897 uint32_t index) { | 881 uint32_t index) { |
| 898 int iExact = 0; | 882 int iExact = 0; |
| 899 void* hFont = | 883 void* hFont = |
| 900 pSystemFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, | 884 pSystemFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, |
| 901 pFontMapper->GetFaceName(index).c_str(), iExact); | 885 pFontMapper->GetFaceName(index).c_str(), iExact); |
| 902 if (!hFont) | 886 if (!hFont) |
| 903 return nullptr; | 887 return nullptr; |
| 904 | 888 |
| 905 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); | 889 uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0); |
| 906 if (dwFileSize == 0) | 890 if (dwFileSize == 0) |
| 907 return nullptr; | 891 return nullptr; |
| 908 | 892 |
| 909 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); | 893 uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1); |
| 910 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); | 894 dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize); |
| 911 | 895 |
| 912 return IFX_MemoryStream::Create(pBuffer, dwFileSize, true); | 896 return IFX_MemoryStream::Create(pBuffer, dwFileSize, true); |
| 913 } | 897 } |
| 914 | 898 |
| 915 IFX_SeekableReadStream* CFGAS_FontMgr::CreateFontStream( | 899 CFX_RetainPtr<IFX_SeekableReadStream> CFGAS_FontMgr::CreateFontStream( |
| 916 const CFX_ByteString& bsFaceName) { | 900 const CFX_ByteString& bsFaceName) { |
| 917 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 901 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 918 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); | 902 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); |
| 919 | |
| 920 if (!pFontMapper) | 903 if (!pFontMapper) |
| 921 return nullptr; | 904 return nullptr; |
| 922 | 905 |
| 923 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); | 906 IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo(); |
| 924 if (!pSystemFontInfo) | 907 if (!pSystemFontInfo) |
| 925 return nullptr; | 908 return nullptr; |
| 926 | 909 |
| 927 pSystemFontInfo->EnumFontList(pFontMapper); | 910 pSystemFontInfo->EnumFontList(pFontMapper); |
| 928 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { | 911 for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { |
| 929 if (pFontMapper->GetFaceName(i) == bsFaceName) | 912 if (pFontMapper->GetFaceName(i) == bsFaceName) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 else | 1015 else |
| 1033 nPenalty -= 60000; | 1016 nPenalty -= 60000; |
| 1034 } | 1017 } |
| 1035 return nPenalty; | 1018 return nPenalty; |
| 1036 } | 1019 } |
| 1037 | 1020 |
| 1038 void CFGAS_FontMgr::RemoveFont(CFGAS_GEFont* pEFont) { | 1021 void CFGAS_FontMgr::RemoveFont(CFGAS_GEFont* pEFont) { |
| 1039 if (!pEFont) | 1022 if (!pEFont) |
| 1040 return; | 1023 return; |
| 1041 | 1024 |
| 1042 IFX_SeekableReadStream* pFileRead; | 1025 m_IFXFont2FileRead.erase(pEFont); |
| 1043 if (m_IFXFont2FileRead.Lookup(pEFont, pFileRead)) { | 1026 |
| 1044 pFileRead->Release(); | |
| 1045 m_IFXFont2FileRead.RemoveKey(pEFont); | |
| 1046 } | |
| 1047 FX_POSITION pos; | 1027 FX_POSITION pos; |
| 1048 pos = m_Hash2Fonts.GetStartPosition(); | 1028 pos = m_Hash2Fonts.GetStartPosition(); |
| 1049 while (pos) { | 1029 while (pos) { |
| 1050 uint32_t dwHash; | 1030 uint32_t dwHash; |
| 1051 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; | 1031 CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; |
| 1052 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); | 1032 m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
| 1053 if (pFonts) { | 1033 if (pFonts) { |
| 1054 for (int32_t i = 0; i < pFonts->GetSize(); i++) { | 1034 for (int32_t i = 0; i < pFonts->GetSize(); i++) { |
| 1055 if (pFonts->GetAt(i) == pEFont) | 1035 if (pFonts->GetAt(i) == pEFont) |
| 1056 pFonts->SetAt(i, nullptr); | 1036 pFonts->SetAt(i, nullptr); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 | 1069 |
| 1090 pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode()); | 1070 pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode()); |
| 1091 pFont->m_wsFaceName = | 1071 pFont->m_wsFaceName = |
| 1092 pFaceName ? *pFaceName | 1072 pFaceName ? *pFaceName |
| 1093 : CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace)); | 1073 : CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace)); |
| 1094 pFont->m_nFaceIndex = pFace->face_index; | 1074 pFont->m_nFaceIndex = pFace->face_index; |
| 1095 | 1075 |
| 1096 m_InstalledFonts.Add(pFont.release()); | 1076 m_InstalledFonts.Add(pFont.release()); |
| 1097 } | 1077 } |
| 1098 | 1078 |
| 1099 void CFGAS_FontMgr::RegisterFaces(IFX_SeekableReadStream* pFontStream, | 1079 void CFGAS_FontMgr::RegisterFaces( |
| 1100 const CFX_WideString* pFaceName) { | 1080 const CFX_RetainPtr<IFX_SeekableReadStream>& pFontStream, |
| 1081 const CFX_WideString* pFaceName) { |
| 1101 int32_t index = 0; | 1082 int32_t index = 0; |
| 1102 int32_t num_faces = 0; | 1083 int32_t num_faces = 0; |
| 1103 do { | 1084 do { |
| 1104 FXFT_Face pFace = LoadFace(pFontStream, index++); | 1085 FXFT_Face pFace = LoadFace(pFontStream, index++); |
| 1105 if (!pFace) | 1086 if (!pFace) |
| 1106 continue; | 1087 continue; |
| 1107 // All faces keep number of faces. It can be retrieved from any one face. | 1088 // All faces keep number of faces. It can be retrieved from any one face. |
| 1108 if (num_faces == 0) | 1089 if (num_faces == 0) |
| 1109 num_faces = pFace->num_faces; | 1090 num_faces = pFace->num_faces; |
| 1110 RegisterFace(pFace, pFaceName); | 1091 RegisterFace(pFace, pFaceName); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 } | 1188 } |
| 1208 | 1189 |
| 1209 int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1, | 1190 int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1, |
| 1210 const CFX_WideString& Name2) { | 1191 const CFX_WideString& Name2) { |
| 1211 if (Name1.Find(Name2.c_str()) != -1) | 1192 if (Name1.Find(Name2.c_str()) != -1) |
| 1212 return 1; | 1193 return 1; |
| 1213 return 0; | 1194 return 0; |
| 1214 } | 1195 } |
| 1215 | 1196 |
| 1216 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 1197 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| OLD | NEW |