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

Unified Diff: xfa/src/fgas/src/font/fx_stdfontmgr.cpp

Issue 1414463006: Merge to XFA: Make CFX_FontMgr member variables private. (try 2) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Make XFA build Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« core/src/fxge/ge/fx_ge_font.cpp ('K') | « fpdfsdk/src/fsdk_mgr.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/src/fgas/src/font/fx_stdfontmgr.cpp
diff --git a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp b/xfa/src/fgas/src/font/fx_stdfontmgr.cpp
index f339555c6b3936fa61de4fde757c75db0f07e850..7a90aceebdf6c031467c5844c1fbd82c477896f1 100644
--- a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp
+++ b/xfa/src/fgas/src/font/fx_stdfontmgr.cpp
@@ -611,13 +611,6 @@ CFX_FontMgrImp::CFX_FontMgrImp(IFX_FontSourceEnum* pFontEnum,
m_pDelegate(pDelegate),
m_pUserData(pUserData) {}
FX_BOOL CFX_FontMgrImp::EnumFonts() {
- FXFT_Library& library = CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary;
Lei Zhang 2015/10/21 00:51:24 |library| is not used here - initialization not ne
Tom Sepez 2015/10/21 20:03:55 May still need it in case any of our callees expec
Lei Zhang 2015/10/21 23:29:02 I'll just call it anyway.
- if (library == NULL) {
- FXFT_Init_FreeType(&library);
- }
- if (library == NULL) {
- return FALSE;
- }
FXFT_Face pFace = NULL;
FX_POSITION pos = m_pFontSource->GetStartPosition();
IFX_FileAccess* pFontSource = NULL;
@@ -1003,45 +996,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);
Lei Zhang 2015/10/21 00:51:24 Not sure if |ftStream| needs to be freed if FXFT_O
Tom Sepez 2015/10/21 20:03:55 Acknowledged.
+ return nullptr;
}
+
FXFT_Set_Pixel_Sizes(pFace, 0, 64);
return pFace;
-BadRet:
Lei Zhang 2015/10/21 00:51:24 Die gotos die!
- if (NULL != ftStream) {
- FX_Free(ftStream);
- }
- return NULL;
}
+
int32_t CFX_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts,
FX_WORD wCodePage,
FX_DWORD dwFontStyles,
« core/src/fxge/ge/fx_ge_font.cpp ('K') | « fpdfsdk/src/fsdk_mgr.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698