From 122ee21e38a15554c8c61edd21fda8c110be6072 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 21 Oct 2015 17:07:24 -0700 Subject: Merge to XFA: Make CFX_FontMgr member variables private. (try 2) R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1412733011 . (cherry picked from commit 5a5b6fb3759daf1201ffc9702f626f4b243922d0) Review URL: https://codereview.chromium.org/1414463006 . --- xfa/src/fgas/src/font/fx_stdfontmgr.cpp | 52 ++++++++++++++------------------- 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'xfa') diff --git a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp b/xfa/src/fgas/src/font/fx_stdfontmgr.cpp index f339555c6b..83c6dff120 100644 --- a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp +++ b/xfa/src/fgas/src/font/fx_stdfontmgr.cpp @@ -610,14 +610,9 @@ CFX_FontMgrImp::CFX_FontMgrImp(IFX_FontSourceEnum* pFontEnum, : m_pFontSource(pFontEnum), m_pDelegate(pDelegate), m_pUserData(pUserData) {} + FX_BOOL CFX_FontMgrImp::EnumFonts() { - FXFT_Library& library = CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary; - if (library == NULL) { - FXFT_Init_FreeType(&library); - } - if (library == NULL) { - return FALSE; - } + CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); FXFT_Face pFace = NULL; FX_POSITION pos = m_pFontSource->GetStartPosition(); IFX_FileAccess* pFontSource = NULL; @@ -1003,45 +998,42 @@ unsigned long _ftStreamRead(FXFT_Stream stream, } void _ftStreamClose(FXFT_Stream stream) {} }; + FXFT_Face CFX_FontMgrImp::LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex) { - FXFT_Library& library = CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary; - FXFT_Open_Args ftArgs; + if (!pFontStream) + return nullptr; + + CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); + pFontMgr->InitFTLibrary(); + FXFT_Library library = pFontMgr->GetFTLibrary(); + if (!library) + return nullptr; + FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1); - FXFT_Face pFace = NULL; - if (library == NULL) { - FXFT_Init_FreeType(&library); - } - if (library == NULL) { - goto BadRet; - } - FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args)); - if (NULL == ftStream) { - goto BadRet; - } FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec)); - if (NULL == pFontStream) { - goto BadRet; - } ftStream->base = NULL; ftStream->descriptor.pointer = pFontStream; ftStream->pos = 0; ftStream->size = (unsigned long)pFontStream->GetSize(); ftStream->read = _ftStreamRead; ftStream->close = _ftStreamClose; + + FXFT_Open_Args ftArgs; + FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args)); ftArgs.flags |= FT_OPEN_STREAM; ftArgs.stream = ftStream; - if (0 != FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { - goto BadRet; + + FXFT_Face pFace = NULL; + if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) { + FX_Free(ftStream); + return nullptr; } + FXFT_Set_Pixel_Sizes(pFace, 0, 64); return pFace; -BadRet: - if (NULL != ftStream) { - FX_Free(ftStream); - } - return NULL; } + int32_t CFX_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, FX_WORD wCodePage, FX_DWORD dwFontStyles, -- cgit v1.2.3