summaryrefslogtreecommitdiff
path: root/xfa/fgas/font
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas/font')
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp24
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.h16
2 files changed, 11 insertions, 29 deletions
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> CFGAS_FontMgr::Create(
- FX_LPEnumAllFonts pEnumerator) {
- return pdfium::MakeUnique<CFGAS_FontMgr>(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_CRTFileAccess> CFX_FontSourceEnum_File::GetNext() {
return pAccess;
}
-std::unique_ptr<CFGAS_FontMgr> CFGAS_FontMgr::Create(
- CFX_FontSourceEnum_File* pFontEnum) {
- if (!pFontEnum)
- return nullptr;
-
- auto pFontMgr = pdfium::MakeUnique<CFGAS_FontMgr>(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<CFX_FontSourceEnum_File>()) {}
CFGAS_FontMgr::~CFGAS_FontMgr() {}
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index 9424cd9657..d0d73bb688 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -83,9 +83,7 @@ FX_LPEnumAllFonts FX_GetDefFontEnumerator();
class CFGAS_FontMgr : public Observable<CFGAS_FontMgr> {
public:
- static std::unique_ptr<CFGAS_FontMgr> Create(FX_LPEnumAllFonts pEnumerator);
-
- explicit CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator);
+ CFGAS_FontMgr();
~CFGAS_FontMgr();
RetainPtr<CFGAS_GEFont> GetFontByCodePage(uint16_t wCodePage,
@@ -99,6 +97,8 @@ class CFGAS_FontMgr : public Observable<CFGAS_FontMgr> {
uint16_t wCodePage);
void RemoveFont(const RetainPtr<CFGAS_GEFont>& pFont);
+ bool EnumFonts() { return true; }
+
private:
RetainPtr<CFGAS_GEFont> LoadFont(const RetainPtr<CFGAS_GEFont>& pSrcFont,
uint32_t dwFontStyles,
@@ -181,10 +181,7 @@ class CFX_FontSourceEnum_File {
class CFGAS_FontMgr : public Observable<CFGAS_FontMgr> {
public:
- static std::unique_ptr<CFGAS_FontMgr> Create(
- CFX_FontSourceEnum_File* pFontEnum);
-
- explicit CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum);
+ CFGAS_FontMgr();
~CFGAS_FontMgr();
RetainPtr<CFGAS_GEFont> GetFontByCodePage(uint16_t wCodePage,
@@ -198,8 +195,9 @@ class CFGAS_FontMgr : public Observable<CFGAS_FontMgr> {
uint16_t wCodePage);
void RemoveFont(const RetainPtr<CFGAS_GEFont>& pFont);
- private:
bool EnumFonts();
+
+ private:
bool EnumFontsFromFontMapper();
bool EnumFontsFromFiles();
void RegisterFace(FXFT_Face pFace, const WideString* pFaceName);
@@ -234,7 +232,7 @@ class CFGAS_FontMgr : public Observable<CFGAS_FontMgr> {
RetainPtr<IFX_SeekableReadStream> CreateFontStream(
const ByteString& bsFaceName);
- CFX_FontSourceEnum_File* const m_pFontSource;
+ std::unique_ptr<CFX_FontSourceEnum_File> m_pFontSource;
std::vector<std::unique_ptr<CFX_FontDescriptor>> m_InstalledFonts;
std::map<uint32_t, std::unique_ptr<std::vector<CFX_FontDescriptorInfo>>>
m_Hash2CandidateList;