summaryrefslogtreecommitdiff
path: root/xfa/fgas/font
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas/font')
-rw-r--r--xfa/fgas/font/fgas_gefont.cpp52
-rw-r--r--xfa/fgas/font/fgas_gefont.h17
2 files changed, 22 insertions, 47 deletions
diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp
index 48635cabf7..7492de246b 100644
--- a/xfa/fgas/font/fgas_gefont.cpp
+++ b/xfa/fgas/font/fgas_gefont.cpp
@@ -77,12 +77,6 @@ CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr)
m_pFontMgr(pFontMgr),
m_iRefCount(1),
m_bExtFont(FALSE),
- m_pStream(nullptr),
- m_pFileRead(nullptr),
- m_pFontEncoding(nullptr),
- m_pCharWidthMap(nullptr),
- m_pRectArray(nullptr),
- m_pBBoxMap(nullptr),
m_pProvider(nullptr) {
}
@@ -96,12 +90,6 @@ CFGAS_GEFont::CFGAS_GEFont(const CFGAS_GEFont& src, uint32_t dwFontStyles)
m_pFontMgr(src.m_pFontMgr),
m_iRefCount(1),
m_bExtFont(FALSE),
- m_pStream(nullptr),
- m_pFileRead(nullptr),
- m_pFontEncoding(nullptr),
- m_pCharWidthMap(nullptr),
- m_pRectArray(nullptr),
- m_pBBoxMap(nullptr),
m_pProvider(nullptr) {
ASSERT(src.m_pFont);
m_pFont = new CFX_Font;
@@ -125,16 +113,7 @@ CFGAS_GEFont::~CFGAS_GEFont() {
m_SubstFonts.RemoveAll();
m_FontMapper.clear();
- if (m_pFileRead)
- m_pFileRead->Release();
- if (m_pStream)
- m_pStream->Release();
-
- delete m_pFontEncoding;
- delete m_pCharWidthMap;
- delete m_pRectArray;
- delete m_pBBoxMap;
if (!m_bExtFont)
delete m_pFont;
}
@@ -213,22 +192,17 @@ FX_BOOL CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) {
FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream,
FX_BOOL bSaveStream) {
- if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) {
+ if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1)
return FALSE;
- }
- if (bSaveStream) {
- m_pStream = pFontStream;
- }
- m_pFileRead = FX_CreateFileRead(pFontStream, FALSE);
+ if (bSaveStream)
+ m_pStream.reset(pFontStream);
+
+ m_pFileRead.reset(FX_CreateFileRead(pFontStream, FALSE));
m_pFont = new CFX_Font;
- FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead);
- if (bRet) {
- bRet = InitFont();
- } else {
- m_pFileRead->Release();
- m_pFileRead = nullptr;
- }
- return bRet;
+ if (m_pFont->LoadFile(m_pFileRead.get()))
+ return InitFont();
+ m_pFileRead.reset();
+ return FALSE;
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -245,16 +219,16 @@ FX_BOOL CFGAS_GEFont::InitFont() {
if (!m_pFont)
return FALSE;
if (!m_pFontEncoding) {
- m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont);
+ m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont));
if (!m_pFontEncoding)
return FALSE;
}
if (!m_pCharWidthMap)
- m_pCharWidthMap = new CFX_DiscreteArrayTemplate<uint16_t>(1024);
+ m_pCharWidthMap.reset(new CFX_DiscreteArrayTemplate<uint16_t>(1024));
if (!m_pRectArray)
- m_pRectArray = new CFX_MassArrayTemplate<CFX_Rect>(16);
+ m_pRectArray.reset(new CFX_MassArrayTemplate<CFX_Rect>(16));
if (!m_pBBoxMap)
- m_pBBoxMap = new CFX_MapPtrToPtr(16);
+ m_pBBoxMap.reset(new CFX_MapPtrToPtr(16));
return TRUE;
}
diff --git a/xfa/fgas/font/fgas_gefont.h b/xfa/fgas/font/fgas_gefont.h
index a94583fa65..37aa03eda9 100644
--- a/xfa/fgas/font/fgas_gefont.h
+++ b/xfa/fgas/font/fgas_gefont.h
@@ -9,6 +9,7 @@
#include <map>
+#include "core/fxcrt/include/fx_memory.h"
#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/font/fgas_font.h"
@@ -92,16 +93,16 @@ class CFGAS_GEFont {
uint32_t m_dwLogFontStyle;
#endif
CFX_Font* m_pFont;
- IFGAS_FontMgr* m_pFontMgr;
+ IFGAS_FontMgr* const m_pFontMgr;
int32_t m_iRefCount;
FX_BOOL m_bExtFont;
- IFX_Stream* m_pStream;
- IFX_FileRead* m_pFileRead;
- CFX_UnicodeEncoding* m_pFontEncoding;
- CFX_DiscreteArrayTemplate<uint16_t>* m_pCharWidthMap;
- CFX_MassArrayTemplate<CFX_Rect>* m_pRectArray;
- CFX_MapPtrToPtr* m_pBBoxMap;
- CXFA_PDFFontMgr* m_pProvider;
+ std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> m_pStream;
+ std::unique_ptr<IFX_FileRead, ReleaseDeleter<IFX_FileRead>> m_pFileRead;
+ std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
+ std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap;
+ 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;
};