Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: xfa/fgas/font/fgas_stdfontmgr.cpp

Issue 2033243004: Make GetDevFont() return a CFX_Font* instead of void* (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: One more file. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fwl/basewidget/fwl_barcodeimp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/fxge/include/fx_ge.h" 10 #include "core/fxge/include/fx_ge.h"
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 if (FXFT_Get_Face_External_Stream(pFace)) 806 if (FXFT_Get_Face_External_Stream(pFace))
807 FXFT_Clear_Face_External_Stream(pFace); 807 FXFT_Clear_Face_External_Stream(pFace);
808 FXFT_Done_Face(pFace); 808 FXFT_Done_Face(pFace);
809 return !retCharmap && retIndex; 809 return !retCharmap && retIndex;
810 } 810 }
811 811
812 FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(IFGAS_Font* pFont, FX_WCHAR wcUnicode) { 812 FX_BOOL CFGAS_FontMgrImp::VerifyUnicode(IFGAS_Font* pFont, FX_WCHAR wcUnicode) {
813 if (!pFont) 813 if (!pFont)
814 return FALSE; 814 return FALSE;
815 815
816 FXFT_Face pFace = ((CFX_Font*)pFont->GetDevFont())->GetFace(); 816 FXFT_Face pFace = pFont->GetDevFont()->GetFace();
817 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace); 817 FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace);
818 if (FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE) != 0) 818 if (FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE) != 0)
819 return FALSE; 819 return FALSE;
820 820
821 if (FXFT_Get_Char_Index(pFace, wcUnicode) == 0) { 821 if (FXFT_Get_Char_Index(pFace, wcUnicode) == 0) {
822 FXFT_Set_Charmap(pFace, charmap); 822 FXFT_Set_Charmap(pFace, charmap);
823 return FALSE; 823 return FALSE;
824 } 824 }
825 return TRUE; 825 return TRUE;
826 } 826 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 FX_BOOL bWantCache) { 882 FX_BOOL bWantCache) {
883 uint32_t dwHash = 0; 883 uint32_t dwHash = 0;
884 IFGAS_Font* pFont = nullptr; 884 IFGAS_Font* pFont = nullptr;
885 if (bWantCache) { 885 if (bWantCache) {
886 CFX_ByteString bsHash; 886 CFX_ByteString bsHash;
887 bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex); 887 bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex);
888 dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false); 888 dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
889 if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) { 889 if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) {
890 if (pFont) { 890 if (pFont) {
891 if (pFaceCount) 891 if (pFaceCount)
892 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; 892 *pFaceCount = pFont->GetDevFont()->GetFace()->num_faces;
893 return pFont->Retain(); 893 return pFont->Retain();
894 } 894 }
895 } 895 }
896 } 896 }
897 897
898 CFX_Font* pInternalFont = new CFX_Font; 898 CFX_Font* pInternalFont = new CFX_Font;
899 IFX_FileRead* pFontStream = 899 IFX_FileRead* pFontStream =
900 pFontAccess->CreateFileStream(FX_FILEMODE_ReadOnly); 900 pFontAccess->CreateFileStream(FX_FILEMODE_ReadOnly);
901 if (!pFontStream) { 901 if (!pFontStream) {
902 delete pInternalFont; 902 delete pInternalFont;
903 return nullptr; 903 return nullptr;
904 } 904 }
905 if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) { 905 if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) {
906 delete pInternalFont; 906 delete pInternalFont;
907 pFontStream->Release(); 907 pFontStream->Release();
908 return nullptr; 908 return nullptr;
909 } 909 }
910 pFont = IFGAS_Font::LoadFont(pInternalFont, this, TRUE); 910 pFont = IFGAS_Font::LoadFont(pInternalFont, this, TRUE);
911 if (!pFont) { 911 if (!pFont) {
912 delete pInternalFont; 912 delete pInternalFont;
913 pFontStream->Release(); 913 pFontStream->Release();
914 return nullptr; 914 return nullptr;
915 } 915 }
916 if (bWantCache) 916 if (bWantCache)
917 m_FileAccess2IFXFont.SetAt(dwHash, pFont); 917 m_FileAccess2IFXFont.SetAt(dwHash, pFont);
918 918
919 m_IFXFont2FileRead.SetAt(pFont, pFontStream); 919 m_IFXFont2FileRead.SetAt(pFont, pFontStream);
920 if (pFaceCount) 920 if (pFaceCount)
921 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; 921 *pFaceCount = pFont->GetDevFont()->GetFace()->num_faces;
922 922
923 return pFont; 923 return pFont;
924 } 924 }
925 925
926 IFGAS_Font* CFGAS_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName, 926 IFGAS_Font* CFGAS_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName,
927 int32_t iFaceIndex, 927 int32_t iFaceIndex,
928 int32_t* pFaceCount) { 928 int32_t* pFaceCount) {
929 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); 929 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
930 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); 930 CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
931 if (!pFontMapper) 931 if (!pFontMapper)
(...skipping 19 matching lines...) Expand all
951 } 951 }
952 952
953 IFGAS_Font* pFont = IFGAS_Font::LoadFont(pInternalFont, this, FALSE); 953 IFGAS_Font* pFont = IFGAS_Font::LoadFont(pInternalFont, this, FALSE);
954 if (!pFont) { 954 if (!pFont) {
955 pFontStream->Release(); 955 pFontStream->Release();
956 return nullptr; 956 return nullptr;
957 } 957 }
958 958
959 m_IFXFont2FileRead.SetAt(pFont, pFontStream); 959 m_IFXFont2FileRead.SetAt(pFont, pFontStream);
960 if (pFaceCount) 960 if (pFaceCount)
961 *pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces; 961 *pFaceCount = pFont->GetDevFont()->GetFace()->num_faces;
962 962
963 return pFont; 963 return pFont;
964 } 964 }
965 965
966 extern "C" { 966 extern "C" {
967 967
968 unsigned long _ftStreamRead(FXFT_Stream stream, 968 unsigned long _ftStreamRead(FXFT_Stream stream,
969 unsigned long offset, 969 unsigned long offset,
970 unsigned char* buffer, 970 unsigned char* buffer,
971 unsigned long count) { 971 unsigned long count) {
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 } 1494 }
1495 } 1495 }
1496 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, 1496 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1,
1497 const CFX_WideString& Name2) { 1497 const CFX_WideString& Name2) {
1498 if (Name1.Find(Name2.c_str()) != -1) { 1498 if (Name1.Find(Name2.c_str()) != -1) {
1499 return 1; 1499 return 1;
1500 } 1500 }
1501 return 0; 1501 return 0;
1502 } 1502 }
1503 #endif 1503 #endif
OLDNEW
« no previous file with comments | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fwl/basewidget/fwl_barcodeimp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698