From 40d522134a11867adb95f77c0b7891932e0739a2 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Thu, 16 Nov 2017 21:41:47 +0000 Subject: Refactor CFGAS_FontMgr's Windows implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Nicolás Peña Moreno --- core/fxge/cfx_font.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core/fxge/cfx_font.h') diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h index ecb64e5009..13cb892c19 100644 --- a/core/fxge/cfx_font.h +++ b/core/fxge/cfx_font.h @@ -46,7 +46,6 @@ class CFX_Font { #ifdef PDF_ENABLE_XFA bool LoadFile(const RetainPtr& pFile, int nFaceIndex); - bool LoadClone(const CFX_Font* pFont); void SetFace(FXFT_Face face); void SetSubstFont(std::unique_ptr subst) { m_pSubstFont = std::move(subst); @@ -79,8 +78,8 @@ class CFX_Font { bool IsTTFont() const; bool GetBBox(FX_RECT& bbox); bool IsEmbedded() const { return m_bEmbedded; } - uint8_t* GetSubData() const { return m_pGsubData; } - void SetSubData(uint8_t* data) { m_pGsubData = data; } + uint8_t* GetSubData() const { return m_pGsubData.get(); } + void SetSubData(uint8_t* data) { m_pGsubData.reset(data); } #if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ void* GetPlatformFont() const { return m_pPlatformFont; } void SetPlatformFont(void* font) { m_pPlatformFont = font; } @@ -100,13 +99,14 @@ class CFX_Font { #ifdef PDF_ENABLE_XFA protected: - bool m_bShallowCopy; - FXFT_StreamRec* m_pOwnedStream; + std::unique_ptr m_pOwnedStream; #endif // PDF_ENABLE_XFA private: CFX_FaceCache* GetFaceCache() const; +#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ void ReleasePlatformResource(); +#endif // _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ void DeleteFace(); void ClearFaceCache(); @@ -115,7 +115,7 @@ class CFX_Font { std::unique_ptr m_pSubstFont; std::vector m_pFontDataAllocation; uint8_t* m_pFontData; - uint8_t* m_pGsubData; + std::unique_ptr m_pGsubData; uint32_t m_dwSize; #if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ void* m_pPlatformFont; -- cgit v1.2.3