summaryrefslogtreecommitdiff
path: root/xfa/src
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-21 17:07:24 -0700
committerLei Zhang <thestig@chromium.org>2015-10-21 17:07:24 -0700
commit122ee21e38a15554c8c61edd21fda8c110be6072 (patch)
tree208031600c134d48a8af2488fc337dab2e110bde /xfa/src
parentafaa98eeb161d60e76506a16d8b986203a7ec0b3 (diff)
downloadpdfium-122ee21e38a15554c8c61edd21fda8c110be6072.tar.xz
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 .
Diffstat (limited to 'xfa/src')
-rw-r--r--xfa/src/fgas/src/font/fx_stdfontmgr.cpp52
1 files changed, 22 insertions, 30 deletions
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,