Index: xfa/fgas/font/cfgas_gefont.h |
diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h |
index 86e5e4c955001cca41e17b5e5a4af58ff66d8d14..962b93fbb5824ad62bcfa686e5ce2e8ce53067db 100644 |
--- a/xfa/fgas/font/cfgas_gefont.h |
+++ b/xfa/fgas/font/cfgas_gefont.h |
@@ -9,40 +9,47 @@ |
#include <map> |
#include <memory> |
+#include <vector> |
+#include "core/fxcrt/cfx_retain_ptr.h" |
#include "core/fxcrt/fx_memory.h" |
#include "xfa/fgas/crt/fgas_utils.h" |
#include "xfa/fgas/font/cfgas_fontmgr.h" |
#define FXFONT_SUBST_ITALIC 0x02 |
+class CFGAS_FontMgr; |
class CFX_UnicodeEncoding; |
class CXFA_PDFFontMgr; |
-class CFGAS_GEFont { |
+class CFGAS_GEFont : public CFX_Retainable { |
public: |
- static CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
- uint32_t dwFontStyles, |
- uint16_t wCodePage, |
- CFGAS_FontMgr* pFontMgr); |
- static CFGAS_GEFont* LoadFont(CFX_Font* pExternalFont, |
- CFGAS_FontMgr* pFontMgr); |
- static CFGAS_GEFont* LoadFont(std::unique_ptr<CFX_Font> pInternalFont, |
- CFGAS_FontMgr* pFontMgr); |
+ template <typename T, typename... Args> |
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); |
+ |
+ static CFX_RetainPtr<CFGAS_GEFont> LoadFont(const FX_WCHAR* pszFontFamily, |
+ uint32_t dwFontStyles, |
+ uint16_t wCodePage, |
+ CFGAS_FontMgr* pFontMgr); |
+ static CFX_RetainPtr<CFGAS_GEFont> LoadFont(CFX_Font* pExternalFont, |
+ CFGAS_FontMgr* pFontMgr); |
+ static CFX_RetainPtr<CFGAS_GEFont> LoadFont( |
+ std::unique_ptr<CFX_Font> pInternalFont, |
+ CFGAS_FontMgr* pFontMgr); |
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
- static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, |
- int32_t iLength, |
- CFGAS_FontMgr* pFontMgr); |
- static CFGAS_GEFont* LoadFont(const CFX_RetainPtr<IFGAS_Stream>& pFontStream, |
- CFGAS_FontMgr* pFontMgr, |
- bool bSaveStream); |
+ static CFX_RetainPtr<CFGAS_GEFont> LoadFont(const uint8_t* pBuffer, |
+ int32_t iLength, |
+ CFGAS_FontMgr* pFontMgr); |
+ static CFX_RetainPtr<CFGAS_GEFont> LoadFont( |
+ const CFX_RetainPtr<IFGAS_Stream>& pFontStream, |
+ CFGAS_FontMgr* pFontMgr, |
+ bool bSaveStream); |
#endif |
- ~CFGAS_GEFont(); |
+ ~CFGAS_GEFont() override; |
- void Release(); |
- CFGAS_GEFont* Retain(); |
- CFGAS_GEFont* Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); |
+ CFX_RetainPtr<CFGAS_GEFont> Derive(uint32_t dwFontStyles, |
+ uint16_t wCodePage = 0); |
uint32_t GetFontStyles() const; |
bool GetCharWidth(FX_WCHAR wUnicode, int32_t& iWidth, bool bCharCode); |
int32_t GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode = false); |
@@ -50,7 +57,7 @@ class CFGAS_GEFont { |
int32_t GetDescent() const; |
bool GetCharBBox(FX_WCHAR wUnicode, CFX_Rect& bbox, bool bCharCode = false); |
bool GetBBox(CFX_Rect& bbox); |
- CFGAS_GEFont* GetSubstFont(int32_t iGlyphIndex) const; |
+ CFX_RetainPtr<CFGAS_GEFont> GetSubstFont(int32_t iGlyphIndex) const; |
CFX_Font* GetDevFont() const { return m_pFont; } |
void SetFontProvider(CXFA_PDFFontMgr* pProvider) { m_pProvider = pProvider; } |
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
@@ -62,7 +69,7 @@ class CFGAS_GEFont { |
private: |
explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); |
- CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles); |
+ CFGAS_GEFont(const CFX_RetainPtr<CFGAS_GEFont>& src, uint32_t dwFontStyles); |
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
bool LoadFontInternal(const FX_WCHAR* pszFontFamily, |
@@ -85,7 +92,7 @@ class CFGAS_GEFont { |
bool bCharCode); |
int32_t GetGlyphIndex(FX_WCHAR wUnicode, |
bool bRecursive, |
- CFGAS_GEFont** ppFont, |
+ CFX_RetainPtr<CFGAS_GEFont>* ppFont, |
bool bCharCode = false); |
CFX_WideString GetFamilyName() const; |
@@ -94,9 +101,8 @@ class CFGAS_GEFont { |
uint32_t m_dwLogFontStyle; |
#endif |
CFX_Font* m_pFont; |
- CFGAS_GEFont* const m_pSrcFont; |
+ CFX_RetainPtr<CFGAS_GEFont> m_pSrcFont; // Only set by ctor, so no cycles. |
CFGAS_FontMgr* const m_pFontMgr; |
- int32_t m_iRefCount; |
bool m_bExternalFont; |
CFX_RetainPtr<IFGAS_Stream> m_pStream; |
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead; |
@@ -105,8 +111,8 @@ class CFGAS_GEFont { |
std::unique_ptr<CFX_MassArrayTemplate<CFX_Rect>> m_pRectArray; |
std::unique_ptr<CFX_MapPtrToPtr> m_pBBoxMap; |
CXFA_PDFFontMgr* m_pProvider; // not owned. |
- CFX_ArrayTemplate<CFGAS_GEFont*> m_SubstFonts; |
- std::map<FX_WCHAR, CFGAS_GEFont*> m_FontMapper; |
+ std::vector<CFX_RetainPtr<CFGAS_GEFont>> m_SubstFonts; |
+ std::map<FX_WCHAR, CFX_RetainPtr<CFGAS_GEFont>> m_FontMapper; |
}; |
#endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ |