summaryrefslogtreecommitdiff
path: root/xfa/fgas/font/cfgas_gefont.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-11-16 21:41:47 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-16 21:41:47 +0000
commit40d522134a11867adb95f77c0b7891932e0739a2 (patch)
tree07164d786b15348783d10cccc9babb9427ff1abe /xfa/fgas/font/cfgas_gefont.cpp
parent3f9549e7f00b649471c4d658bbfb6bf031b8f53e (diff)
downloadpdfium-40d522134a11867adb95f77c0b7891932e0739a2.tar.xz
Refactor CFGAS_FontMgr's Windows implementation
This CL unifies a bit the public methods of CFGAS_FontMgr. It does so by replacing the multiple maps on the Windows implementation to a single map from hash to font. Also, cloning CFX_Fonts is avoided with the use of SetLogicalFontStyle. These Windows changes are just mimicking other OS's. As a side-effect, some members of CFX_Fonts are now owned so the raw pointers are replaced with unique_ptrs. Change-Id: I576d438572ccbe6c48f8f5cc434d66fc6adba372 Reviewed-on: https://pdfium-review.googlesource.com/18131 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'xfa/fgas/font/cfgas_gefont.cpp')
-rw-r--r--xfa/fgas/font/cfgas_gefont.cpp42
1 files changed, 0 insertions, 42 deletions
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 43d019f0f5..83b7ad68d7 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -56,43 +56,13 @@ RetainPtr<CFGAS_GEFont> CFGAS_GEFont::LoadFont(
CFGAS_GEFont::CFGAS_GEFont(CFGAS_FontMgr* pFontMgr)
:
-#if _FX_PLATFORM_ != _FX_PLATFORM_WINDOWS_
m_bUseLogFontStyle(false),
m_dwLogFontStyle(0),
-#endif
m_pFont(nullptr),
m_bExternalFont(false),
m_pFontMgr(pFontMgr) {
}
-CFGAS_GEFont::CFGAS_GEFont(const RetainPtr<CFGAS_GEFont>& src,
- uint32_t dwFontStyles)
- :
-#if _FX_PLATFORM_ != _FX_PLATFORM_WINDOWS_
- m_bUseLogFontStyle(false),
- m_dwLogFontStyle(0),
-#endif
- m_pFont(nullptr),
- m_bExternalFont(false),
- m_pSrcFont(src),
- m_pFontMgr(src->m_pFontMgr) {
- ASSERT(m_pSrcFont->m_pFont);
- m_pFont = new CFX_Font;
- m_pFont->LoadClone(m_pSrcFont->m_pFont);
-
- CFX_SubstFont* pSubst = m_pFont->GetSubstFont();
- if (!pSubst) {
- pSubst = new CFX_SubstFont;
- m_pFont->SetSubstFont(std::unique_ptr<CFX_SubstFont>(pSubst));
- }
- pSubst->m_Weight =
- FontStyleIsBold(dwFontStyles) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
- if (FontStyleIsItalic(dwFontStyles))
- pSubst->m_bFlagItalic = true;
-
- InitFont();
-}
-
CFGAS_GEFont::~CFGAS_GEFont() {
if (!m_bExternalFont)
delete m_pFont;
@@ -155,16 +125,6 @@ bool CFGAS_GEFont::InitFont() {
return !!m_pFontEncoding;
}
-#if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
-RetainPtr<CFGAS_GEFont> CFGAS_GEFont::Derive(uint32_t dwFontStyles,
- uint16_t wCodePage) {
- RetainPtr<CFGAS_GEFont> pFont(this);
- if (GetFontStyles() == dwFontStyles)
- return pFont;
- return pdfium::MakeRetain<CFGAS_GEFont>(pFont, dwFontStyles);
-}
-#endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
-
WideString CFGAS_GEFont::GetFamilyName() const {
if (!m_pFont->GetSubstFont() ||
m_pFont->GetSubstFont()->m_Family.GetLength() == 0) {
@@ -176,10 +136,8 @@ WideString CFGAS_GEFont::GetFamilyName() const {
uint32_t CFGAS_GEFont::GetFontStyles() const {
ASSERT(m_pFont);
-#if _FX_PLATFORM_ != _FX_PLATFORM_WINDOWS_
if (m_bUseLogFontStyle)
return m_dwLogFontStyle;
-#endif
uint32_t dwStyles = 0;
auto* pSubstFont = m_pFont->GetSubstFont();