summaryrefslogtreecommitdiff
path: root/core/fxge
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 /core/fxge
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 'core/fxge')
-rw-r--r--core/fxge/cfx_font.cpp47
-rw-r--r--core/fxge/cfx_font.h12
2 files changed, 8 insertions, 51 deletions
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index 3f4f1356f8..bca711f0bb 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -211,10 +211,6 @@ const uint8_t CFX_Font::s_WeightPow_SHIFTJIS[] = {
CFX_Font::CFX_Font()
:
-#ifdef PDF_ENABLE_XFA
- m_bShallowCopy(false),
- m_pOwnedStream(nullptr),
-#endif // PDF_ENABLE_XFA
m_Face(nullptr),
m_FaceCache(nullptr),
m_pFontData(nullptr),
@@ -228,48 +224,13 @@ CFX_Font::CFX_Font()
}
#ifdef PDF_ENABLE_XFA
-bool CFX_Font::LoadClone(const CFX_Font* pFont) {
- if (!pFont)
- return false;
-
- m_bShallowCopy = true;
- if (pFont->m_pSubstFont) {
- m_pSubstFont = pdfium::MakeUnique<CFX_SubstFont>();
- m_pSubstFont->m_Charset = pFont->m_pSubstFont->m_Charset;
- m_pSubstFont->m_bFlagMM = pFont->m_pSubstFont->m_bFlagMM;
-#ifdef PDF_ENABLE_XFA
- m_pSubstFont->m_bFlagItalic = pFont->m_pSubstFont->m_bFlagItalic;
-#endif // PDF_ENABLE_XFA
- m_pSubstFont->m_Weight = pFont->m_pSubstFont->m_Weight;
- m_pSubstFont->m_Family = pFont->m_pSubstFont->m_Family;
- m_pSubstFont->m_ItalicAngle = pFont->m_pSubstFont->m_ItalicAngle;
- }
- m_Face = pFont->m_Face;
- m_bEmbedded = pFont->m_bEmbedded;
- m_bVertical = pFont->m_bVertical;
- m_dwSize = pFont->m_dwSize;
- m_pFontData = pFont->m_pFontData;
- m_pGsubData = pFont->m_pGsubData;
-#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
- m_pPlatformFont = pFont->m_pPlatformFont;
-#endif
- m_pOwnedStream = pFont->m_pOwnedStream;
- m_FaceCache = pFont->GetFaceCache();
- return true;
-}
-
void CFX_Font::SetFace(FXFT_Face face) {
ClearFaceCache();
m_Face = face;
}
-
#endif // PDF_ENABLE_XFA
CFX_Font::~CFX_Font() {
-#ifdef PDF_ENABLE_XFA
- if (m_bShallowCopy)
- return;
-#endif // PDF_ENABLE_XFA
if (m_Face) {
#ifndef PDF_ENABLE_XFA
if (FXFT_Get_Face_External_Stream(m_Face)) {
@@ -278,11 +239,7 @@ CFX_Font::~CFX_Font() {
#endif // PDF_ENABLE_XFA
DeleteFace();
}
-#ifdef PDF_ENABLE_XFA
- delete m_pOwnedStream;
-#endif // PDF_ENABLE_XFA
- FX_Free(m_pGsubData);
-#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ && !defined _SKIA_SUPPORT_
+#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
ReleasePlatformResource();
#endif
}
@@ -328,7 +285,7 @@ bool CFX_Font::LoadFile(const RetainPtr<IFX_SeekableReadStream>& pFile,
if (!LoadFileImp(library, &m_Face, pFile, nFaceIndex, &stream))
return false;
- m_pOwnedStream = stream.release();
+ m_pOwnedStream = std::move(stream);
FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
return true;
}
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<IFX_SeekableReadStream>& pFile, int nFaceIndex);
- bool LoadClone(const CFX_Font* pFont);
void SetFace(FXFT_Face face);
void SetSubstFont(std::unique_ptr<CFX_SubstFont> 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<FXFT_StreamRec> 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<CFX_SubstFont> m_pSubstFont;
std::vector<uint8_t> m_pFontDataAllocation;
uint8_t* m_pFontData;
- uint8_t* m_pGsubData;
+ std::unique_ptr<uint8_t, FxFreeDeleter> m_pGsubData;
uint32_t m_dwSize;
#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
void* m_pPlatformFont;