From 81f02f4c8347890ce66d6ec48781589d10098689 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 26 Sep 2017 12:02:16 -0400 Subject: Move font source into CFGAS_FontMgr This CL moves the font source into the font manager so it doesn't need to be stored by each caller (and removes the platform dependant code). The |EnumFonts| method is exposed on the CFGAS_FontMgr so the caller can clear the manager if the enumeration fails. Change-Id: Iecce3d2e09ff01152b7bb79a34fe2b728320da9c Reviewed-on: https://pdfium-review.googlesource.com/14816 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fgas/font/cfgas_fontmgr.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'xfa/fgas/font/cfgas_fontmgr.cpp') diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 2175a23288..df7c36fd53 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -184,13 +184,8 @@ uint32_t GetFontFamilyHash(const wchar_t* pszFontFamily, } // namespace -std::unique_ptr CFGAS_FontMgr::Create( - FX_LPEnumAllFonts pEnumerator) { - return pdfium::MakeUnique(pEnumerator); -} - -CFGAS_FontMgr::CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator) - : m_pEnumerator(pEnumerator), m_FontFaces(100) { +CFGAS_FontMgr::CFGAS_FontMgr() + : m_pEnumerator(FX_GetDefFontEnumerator()), m_FontFaces(100) { if (m_pEnumerator) m_pEnumerator(&m_FontFaces, nullptr, 0xFEFF); } @@ -688,19 +683,8 @@ RetainPtr CFX_FontSourceEnum_File::GetNext() { return pAccess; } -std::unique_ptr CFGAS_FontMgr::Create( - CFX_FontSourceEnum_File* pFontEnum) { - if (!pFontEnum) - return nullptr; - - auto pFontMgr = pdfium::MakeUnique(pFontEnum); - if (!pFontMgr->EnumFonts()) - return nullptr; - return pFontMgr; -} - -CFGAS_FontMgr::CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum) - : m_pFontSource(pFontEnum) {} +CFGAS_FontMgr::CFGAS_FontMgr() + : m_pFontSource(pdfium::MakeUnique()) {} CFGAS_FontMgr::~CFGAS_FontMgr() {} -- cgit v1.2.3