From 0b95042db2e6dab5876abd12ce485fff0a8e08fe Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 21 Sep 2017 15:49:49 -0400 Subject: Rename CFX_RetainPtr to RetainPtr This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e Reviewed-on: https://pdfium-review.googlesource.com/14616 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- xfa/fgas/font/cfgas_defaultfontmanager.cpp | 8 +-- xfa/fgas/font/cfgas_defaultfontmanager.h | 20 +++---- xfa/fgas/font/cfgas_fontmgr.cpp | 82 +++++++++++++-------------- xfa/fgas/font/cfgas_fontmgr.h | 90 +++++++++++++++--------------- xfa/fgas/font/cfgas_gefont.cpp | 36 ++++++------ xfa/fgas/font/cfgas_gefont.h | 46 ++++++++------- xfa/fgas/font/cfgas_pdffontmgr.cpp | 19 +++---- xfa/fgas/font/cfgas_pdffontmgr.h | 28 +++++----- 8 files changed, 160 insertions(+), 169 deletions(-) (limited to 'xfa/fgas/font') diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.cpp b/xfa/fgas/font/cfgas_defaultfontmanager.cpp index 480525802b..d3864be16a 100644 --- a/xfa/fgas/font/cfgas_defaultfontmanager.cpp +++ b/xfa/fgas/font/cfgas_defaultfontmanager.cpp @@ -12,13 +12,13 @@ CFGAS_DefaultFontManager::CFGAS_DefaultFontManager() {} CFGAS_DefaultFontManager::~CFGAS_DefaultFontManager() {} -CFX_RetainPtr CFGAS_DefaultFontManager::GetFont( +RetainPtr CFGAS_DefaultFontManager::GetFont( CFGAS_FontMgr* pFontMgr, const WideStringView& wsFontFamily, uint32_t dwFontStyles, uint16_t wCodePage) { WideString wsFontName(wsFontFamily); - CFX_RetainPtr pFont = + RetainPtr pFont = pFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage); if (!pFont) { const FGAS_FontInfo* pCurFont = @@ -54,12 +54,12 @@ CFX_RetainPtr CFGAS_DefaultFontManager::GetFont( return pFont; } -CFX_RetainPtr CFGAS_DefaultFontManager::GetDefaultFont( +RetainPtr CFGAS_DefaultFontManager::GetDefaultFont( CFGAS_FontMgr* pFontMgr, const WideStringView& wsFontFamily, uint32_t dwFontStyles, uint16_t wCodePage) { - CFX_RetainPtr pFont = + RetainPtr pFont = pFontMgr->LoadFont(L"Arial Narrow", dwFontStyles, wCodePage); if (!pFont) { pFont = pFontMgr->LoadFont(static_cast(nullptr), diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.h b/xfa/fgas/font/cfgas_defaultfontmanager.h index b596efc719..4e2e5e10d4 100644 --- a/xfa/fgas/font/cfgas_defaultfontmanager.h +++ b/xfa/fgas/font/cfgas_defaultfontmanager.h @@ -9,8 +9,8 @@ #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fgas/font/cfgas_gefont.h" class CFGAS_DefaultFontManager { @@ -18,17 +18,17 @@ class CFGAS_DefaultFontManager { CFGAS_DefaultFontManager(); ~CFGAS_DefaultFontManager(); - CFX_RetainPtr GetFont(CFGAS_FontMgr* pFontMgr, - const WideStringView& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); - CFX_RetainPtr GetDefaultFont(CFGAS_FontMgr* pFontMgr, - const WideStringView& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage = 0xFFFF); + RetainPtr GetFont(CFGAS_FontMgr* pFontMgr, + const WideStringView& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); + RetainPtr GetDefaultFont(CFGAS_FontMgr* pFontMgr, + const WideStringView& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage = 0xFFFF); private: - std::vector> m_CacheFonts; + std::vector> m_CacheFonts; }; #endif // XFA_FGAS_FONT_CFGAS_DEFAULTFONTMANAGER_H_ diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index f2405e9844..da1763214b 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -197,7 +197,7 @@ CFGAS_FontMgr::CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator) CFGAS_FontMgr::~CFGAS_FontMgr() {} -CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( +RetainPtr CFGAS_FontMgr::GetFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, const wchar_t* pszFontFamily) { @@ -215,7 +215,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( if (!pFD) return nullptr; - CFX_RetainPtr pFont = + RetainPtr pFont = CFGAS_GEFont::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this); if (!pFont) return nullptr; @@ -227,7 +227,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( return LoadFont(pFont, dwFontStyles, wCodePage); } -CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( +RetainPtr CFGAS_FontMgr::GetFontByUnicode( wchar_t wUnicode, uint32_t dwFontStyles, const wchar_t* pszFontFamily) { @@ -254,7 +254,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( uint16_t wCodePage = GetCodePageFromCharset(pFD->uCharSet); const wchar_t* pFontFace = pFD->wsFontFace; - CFX_RetainPtr pFont = + RetainPtr pFont = CFGAS_GEFont::LoadFont(pFontFace, dwFontStyles, wCodePage, this); if (!pFont) return nullptr; @@ -266,11 +266,10 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( return LoadFont(pFont, dwFontStyles, wCodePage); } -CFX_RetainPtr CFGAS_FontMgr::LoadFont( - const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { - CFX_RetainPtr pFont; +RetainPtr CFGAS_FontMgr::LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { + RetainPtr pFont; uint32_t dwHash = GetFontFamilyHash(pszFontFamily, dwFontStyles, wCodePage); auto it = m_FamilyFonts.find(dwHash); if (it != m_FamilyFonts.end()) @@ -298,8 +297,8 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( return LoadFont(pFont, dwFontStyles, wCodePage); } -CFX_RetainPtr CFGAS_FontMgr::LoadFont( - const CFX_RetainPtr& pSrcFont, +RetainPtr CFGAS_FontMgr::LoadFont( + const RetainPtr& pSrcFont, uint32_t dwFontStyles, uint16_t wCodePage) { if (pSrcFont->GetFontStyles() == dwFontStyles) @@ -313,7 +312,7 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( if (it != m_DeriveFonts.end() && it->second) return it->second; - CFX_RetainPtr pFont = pSrcFont->Derive(dwFontStyles, wCodePage); + RetainPtr pFont = pSrcFont->Derive(dwFontStyles, wCodePage); if (!pFont) return nullptr; @@ -325,8 +324,8 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( } void CFGAS_FontMgr::RemoveFont( - std::map>* pFontMap, - const CFX_RetainPtr& pFont) { + std::map>* pFontMap, + const RetainPtr& pFont) { auto iter = pFontMap->begin(); while (iter != pFontMap->end()) { auto old_iter = iter++; @@ -335,7 +334,7 @@ void CFGAS_FontMgr::RemoveFont( } } -void CFGAS_FontMgr::RemoveFont(const CFX_RetainPtr& pFont) { +void CFGAS_FontMgr::RemoveFont(const RetainPtr& pFont) { RemoveFont(&m_CPFonts, pFont); RemoveFont(&m_FamilyFonts, pFont); RemoveFont(&m_UnicodeFonts, pFont); @@ -680,7 +679,7 @@ bool CFX_FontSourceEnum_File::HasStartPosition() { return m_wsNext.GetLength() != 0; } -CFX_RetainPtr CFX_FontSourceEnum_File::GetNext() { +RetainPtr CFX_FontSourceEnum_File::GetNext() { if (m_wsNext.GetLength() == 0) return nullptr; @@ -717,7 +716,7 @@ bool CFGAS_FontMgr::EnumFontsFromFontMapper() { pSystemFontInfo->EnumFontList(pFontMapper); for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) { - CFX_RetainPtr pFontStream = + RetainPtr pFontStream = CreateFontStream(pFontMapper, pSystemFontInfo, i); if (!pFontStream) continue; @@ -734,9 +733,8 @@ bool CFGAS_FontMgr::EnumFontsFromFiles() { if (!m_pFontSource->HasStartPosition()) return !m_InstalledFonts.empty(); - while (CFX_RetainPtr pFontSource = - m_pFontSource->GetNext()) { - CFX_RetainPtr pFontStream = + while (RetainPtr pFontSource = m_pFontSource->GetNext()) { + RetainPtr pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); if (pFontStream) RegisterFaces(pFontStream, nullptr); @@ -748,14 +746,13 @@ bool CFGAS_FontMgr::EnumFonts() { return EnumFontsFromFontMapper() || EnumFontsFromFiles(); } -CFX_RetainPtr CFGAS_FontMgr::LoadFont( - const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { +RetainPtr CFGAS_FontMgr::LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); } -CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( +RetainPtr CFGAS_FontMgr::GetFontByCodePage( uint16_t wCodePage, uint32_t dwFontStyles, const wchar_t* pszFontFamily) { @@ -763,7 +760,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( bsHash.Format("%d, %d", wCodePage, dwFontStyles); bsHash += FX_UTF8Encode(WideStringView(pszFontFamily)); uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView(), false); - std::vector>* pFontArray = &m_Hash2Fonts[dwHash]; + std::vector>* pFontArray = &m_Hash2Fonts[dwHash]; if (!pFontArray->empty()) return (*pFontArray)[0]; @@ -780,7 +777,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( return nullptr; CFX_FontDescriptor* pDesc = (*sortedFontInfos)[0].pFont; - CFX_RetainPtr pFont = + RetainPtr pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); if (!pFont) return nullptr; @@ -790,7 +787,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByCodePage( return pFont; } -CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( +RetainPtr CFGAS_FontMgr::GetFontByUnicode( wchar_t wUnicode, uint32_t dwFontStyles, const wchar_t* pszFontFamily) { @@ -807,7 +804,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( bsHash.Format("%d, %d", wCodePage, dwFontStyles); bsHash += FX_UTF8Encode(WideStringView(pszFontFamily)); uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringView(), false); - std::vector>* pFonts = &m_Hash2Fonts[dwHash]; + std::vector>* pFonts = &m_Hash2Fonts[dwHash]; for (size_t i = 0; i < pFonts->size(); ++i) { if (VerifyUnicode((*pFonts)[i], wUnicode)) return (*pFonts)[i]; @@ -825,7 +822,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( CFX_FontDescriptor* pDesc = info.pFont; if (!VerifyUnicode(pDesc, wUnicode)) continue; - CFX_RetainPtr pFont = + RetainPtr pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr); if (!pFont) continue; @@ -840,7 +837,7 @@ CFX_RetainPtr CFGAS_FontMgr::GetFontByUnicode( bool CFGAS_FontMgr::VerifyUnicode(CFX_FontDescriptor* pDesc, wchar_t wcUnicode) { - CFX_RetainPtr pFileRead = + RetainPtr pFileRead = CreateFontStream(pDesc->m_wsFaceName.UTF8Encode()); if (!pFileRead) return false; @@ -858,7 +855,7 @@ bool CFGAS_FontMgr::VerifyUnicode(CFX_FontDescriptor* pDesc, return !retCharmap && retIndex; } -bool CFGAS_FontMgr::VerifyUnicode(const CFX_RetainPtr& pFont, +bool CFGAS_FontMgr::VerifyUnicode(const RetainPtr& pFont, wchar_t wcUnicode) { if (!pFont) return false; @@ -875,10 +872,9 @@ bool CFGAS_FontMgr::VerifyUnicode(const CFX_RetainPtr& pFont, return true; } -CFX_RetainPtr CFGAS_FontMgr::LoadFont( - const WideString& wsFaceName, - int32_t iFaceIndex, - int32_t* pFaceCount) { +RetainPtr CFGAS_FontMgr::LoadFont(const WideString& wsFaceName, + int32_t iFaceIndex, + int32_t* pFaceCount) { CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); if (!pFontMapper) @@ -888,7 +884,7 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( if (!pSystemFontInfo) return nullptr; - CFX_RetainPtr pFontStream = + RetainPtr pFontStream = CreateFontStream(wsFaceName.UTF8Encode()); if (!pFontStream) return nullptr; @@ -897,7 +893,7 @@ CFX_RetainPtr CFGAS_FontMgr::LoadFont( if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) return nullptr; - CFX_RetainPtr pFont = + RetainPtr pFont = CFGAS_GEFont::LoadFont(std::move(pInternalFont), this); if (!pFont) return nullptr; @@ -930,7 +926,7 @@ void _ftStreamClose(FXFT_Stream stream) {} }; // extern "C" FXFT_Face CFGAS_FontMgr::LoadFace( - const CFX_RetainPtr& pFontStream, + const RetainPtr& pFontStream, int32_t iFaceIndex) { if (!pFontStream) return nullptr; @@ -971,7 +967,7 @@ FXFT_Face CFGAS_FontMgr::LoadFace( return pFace; } -CFX_RetainPtr CFGAS_FontMgr::CreateFontStream( +RetainPtr CFGAS_FontMgr::CreateFontStream( CFX_FontMapper* pFontMapper, IFX_SystemFontInfo* pSystemFontInfo, uint32_t index) { @@ -992,7 +988,7 @@ CFX_RetainPtr CFGAS_FontMgr::CreateFontStream( return pdfium::MakeRetain(pBuffer, dwFileSize, true); } -CFX_RetainPtr CFGAS_FontMgr::CreateFontStream( +RetainPtr CFGAS_FontMgr::CreateFontStream( const ByteString& bsFaceName) { CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper(); @@ -1101,7 +1097,7 @@ int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled, return nPenalty; } -void CFGAS_FontMgr::RemoveFont(const CFX_RetainPtr& pEFont) { +void CFGAS_FontMgr::RemoveFont(const RetainPtr& pEFont) { if (!pEFont) return; @@ -1155,7 +1151,7 @@ void CFGAS_FontMgr::RegisterFace(FXFT_Face pFace, const WideString* pFaceName) { } void CFGAS_FontMgr::RegisterFaces( - const CFX_RetainPtr& pFontStream, + const RetainPtr& pFontStream, const WideString* pFaceName) { int32_t index = 0; int32_t num_faces = 0; diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h index 642ba6fb67..0bcee12e4d 100644 --- a/xfa/fgas/font/cfgas_fontmgr.h +++ b/xfa/fgas/font/cfgas_fontmgr.h @@ -14,10 +14,10 @@ #include #include "core/fxcrt/cfx_crtfileaccess.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/observable.h" +#include "core/fxcrt/retain_ptr.h" #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/fx_freetype.h" #include "core/fxge/ifx_systemfontinfo.h" @@ -88,24 +88,23 @@ class CFGAS_FontMgr : public Observable { explicit CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator); ~CFGAS_FontMgr(); - CFX_RetainPtr GetFontByCodePage(uint16_t wCodePage, - uint32_t dwFontStyles, - const wchar_t* pszFontFamily); - CFX_RetainPtr GetFontByUnicode(wchar_t wUnicode, - uint32_t dwFontStyles, - const wchar_t* pszFontFamily); - CFX_RetainPtr LoadFont(const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage); - void RemoveFont(const CFX_RetainPtr& pFont); + RetainPtr GetFontByCodePage(uint16_t wCodePage, + uint32_t dwFontStyles, + const wchar_t* pszFontFamily); + RetainPtr GetFontByUnicode(wchar_t wUnicode, + uint32_t dwFontStyles, + const wchar_t* pszFontFamily); + RetainPtr LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage); + void RemoveFont(const RetainPtr& pFont); private: - CFX_RetainPtr LoadFont( - const CFX_RetainPtr& pSrcFont, - uint32_t dwFontStyles, - uint16_t wCodePage); - void RemoveFont(std::map>* pFontMap, - const CFX_RetainPtr& pFont); + RetainPtr LoadFont(const RetainPtr& pSrcFont, + uint32_t dwFontStyles, + uint16_t wCodePage); + void RemoveFont(std::map>* pFontMap, + const RetainPtr& pFont); const FX_FONTDESCRIPTOR* FindFont(const wchar_t* pszFontFamily, uint32_t dwFontStyles, uint32_t dwMatchFlags, @@ -115,13 +114,13 @@ class CFGAS_FontMgr : public Observable { FX_LPEnumAllFonts m_pEnumerator; std::deque m_FontFaces; - std::vector> m_Fonts; - std::map> m_CPFonts; - std::map> m_FamilyFonts; - std::map> m_UnicodeFonts; - std::map> m_BufferFonts; - std::map> m_StreamFonts; - std::map> m_DeriveFonts; + std::vector> m_Fonts; + std::map> m_CPFonts; + std::map> m_FamilyFonts; + std::map> m_UnicodeFonts; + std::map> m_BufferFonts; + std::map> m_StreamFonts; + std::map> m_DeriveFonts; }; #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ @@ -170,7 +169,7 @@ class CFX_FontSourceEnum_File { ~CFX_FontSourceEnum_File(); bool HasStartPosition(); - CFX_RetainPtr GetNext(); + RetainPtr GetNext(); private: ByteString GetNextFile(); @@ -188,31 +187,30 @@ class CFGAS_FontMgr : public Observable { explicit CFGAS_FontMgr(CFX_FontSourceEnum_File* pFontEnum); ~CFGAS_FontMgr(); - CFX_RetainPtr GetFontByCodePage(uint16_t wCodePage, - uint32_t dwFontStyles, - const wchar_t* pszFontFamily); - CFX_RetainPtr GetFontByUnicode(wchar_t wUnicode, - uint32_t dwFontStyles, - const wchar_t* pszFontFamily); - CFX_RetainPtr LoadFont(const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage); - void RemoveFont(const CFX_RetainPtr& pFont); + RetainPtr GetFontByCodePage(uint16_t wCodePage, + uint32_t dwFontStyles, + const wchar_t* pszFontFamily); + RetainPtr GetFontByUnicode(wchar_t wUnicode, + uint32_t dwFontStyles, + const wchar_t* pszFontFamily); + RetainPtr LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage); + void RemoveFont(const RetainPtr& pFont); private: bool EnumFonts(); bool EnumFontsFromFontMapper(); bool EnumFontsFromFiles(); void RegisterFace(FXFT_Face pFace, const WideString* pFaceName); - void RegisterFaces(const CFX_RetainPtr& pFontStream, + void RegisterFaces(const RetainPtr& pFontStream, const WideString* pFaceName); void GetNames(const uint8_t* name_table, std::vector& Names); std::vector GetCharsets(FXFT_Face pFace) const; void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); uint32_t GetFlags(FXFT_Face pFace); bool VerifyUnicode(CFX_FontDescriptor* pDesc, wchar_t wcUnicode); - bool VerifyUnicode(const CFX_RetainPtr& pFont, - wchar_t wcUnicode); + bool VerifyUnicode(const RetainPtr& pFont, wchar_t wcUnicode); int32_t IsPartName(const WideString& Name1, const WideString& Name2); void MatchFonts(std::vector* MatchedFonts, uint16_t wCodePage, @@ -224,24 +222,24 @@ class CFGAS_FontMgr : public Observable { uint32_t dwFontStyles, const WideString& FontName, wchar_t wcUnicode = 0xFFFE); - CFX_RetainPtr LoadFont(const WideString& wsFaceName, - int32_t iFaceIndex, - int32_t* pFaceCount); - FXFT_Face LoadFace(const CFX_RetainPtr& pFontStream, + RetainPtr LoadFont(const WideString& wsFaceName, + int32_t iFaceIndex, + int32_t* pFaceCount); + FXFT_Face LoadFace(const RetainPtr& pFontStream, int32_t iFaceIndex); - CFX_RetainPtr CreateFontStream( + RetainPtr CreateFontStream( CFX_FontMapper* pFontMapper, IFX_SystemFontInfo* pSystemFontInfo, uint32_t index); - CFX_RetainPtr CreateFontStream( + RetainPtr CreateFontStream( const ByteString& bsFaceName); CFX_FontSourceEnum_File* const m_pFontSource; std::vector> m_InstalledFonts; std::map>> m_Hash2CandidateList; - std::map>> m_Hash2Fonts; - std::map, CFX_RetainPtr> + std::map>> m_Hash2Fonts; + std::map, RetainPtr> m_IFXFont2FileRead; std::set m_FailedUnicodesSet; }; diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index 404b23cf7b..ba79d77ca0 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -17,10 +17,10 @@ #include "xfa/fgas/font/fgas_fontutils.h" // static -CFX_RetainPtr CFGAS_GEFont::LoadFont(const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage, - CFGAS_FontMgr* pFontMgr) { +RetainPtr CFGAS_GEFont::LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage, + CFGAS_FontMgr* pFontMgr) { #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ if (!pFontMgr) return nullptr; @@ -35,8 +35,8 @@ CFX_RetainPtr CFGAS_GEFont::LoadFont(const wchar_t* pszFontFamily, } // static -CFX_RetainPtr CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, - CFGAS_FontMgr* pFontMgr) { +RetainPtr CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, + CFGAS_FontMgr* pFontMgr) { auto pFont = pdfium::MakeRetain(pFontMgr); if (!pFont->LoadFontInternal(pExternalFont)) return nullptr; @@ -44,7 +44,7 @@ CFX_RetainPtr CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, } // static -CFX_RetainPtr CFGAS_GEFont::LoadFont( +RetainPtr CFGAS_GEFont::LoadFont( std::unique_ptr pInternalFont, CFGAS_FontMgr* pFontMgr) { auto pFont = pdfium::MakeRetain(pFontMgr); @@ -64,7 +64,7 @@ CFGAS_GEFont::CFGAS_GEFont(CFGAS_FontMgr* pFontMgr) m_pFontMgr(pFontMgr) { } -CFGAS_GEFont::CFGAS_GEFont(const CFX_RetainPtr& src, +CFGAS_GEFont::CFGAS_GEFont(const RetainPtr& src, uint32_t dwFontStyles) : #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ @@ -164,9 +164,9 @@ bool CFGAS_GEFont::InitFont() { return !!m_pFontEncoding; } -CFX_RetainPtr CFGAS_GEFont::Derive(uint32_t dwFontStyles, - uint16_t wCodePage) { - CFX_RetainPtr pFont(this); +RetainPtr CFGAS_GEFont::Derive(uint32_t dwFontStyles, + uint16_t wCodePage) { + RetainPtr pFont(this); if (GetFontStyles() == dwFontStyles) return pFont; return pdfium::MakeRetain(pFont, dwFontStyles); @@ -223,9 +223,9 @@ bool CFGAS_GEFont::GetCharWidthInternal(wchar_t wUnicode, return true; if (!m_pProvider || - !m_pProvider->GetCharWidth(CFX_RetainPtr(this), wUnicode, + !m_pProvider->GetCharWidth(RetainPtr(this), wUnicode, bCharCode, &iWidth)) { - CFX_RetainPtr pFont; + RetainPtr pFont; int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); if (iGlyph != 0xFFFF && pFont) { if (pFont.Get() == this) { @@ -260,7 +260,7 @@ bool CFGAS_GEFont::GetCharBBoxInternal(wchar_t wUnicode, return true; } - CFX_RetainPtr pFont; + RetainPtr pFont; int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); if (!pFont || iGlyph == 0xFFFF) return false; @@ -296,7 +296,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(wchar_t wUnicode, bool bCharCode) { int32_t CFGAS_GEFont::GetGlyphIndex(wchar_t wUnicode, bool bRecursive, - CFX_RetainPtr* ppFont, + RetainPtr* ppFont, bool bCharCode) { int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); if (iGlyphIndex > 0) { @@ -330,7 +330,7 @@ int32_t CFGAS_GEFont::GetGlyphIndex(wchar_t wUnicode, return 0xFFFF; WideString wsFamily = GetFamilyName(); - CFX_RetainPtr pFont = + RetainPtr pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), wsFamily.c_str()); #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ if (!pFont) @@ -358,9 +358,9 @@ int32_t CFGAS_GEFont::GetDescent() const { return m_pFont->GetDescent(); } -CFX_RetainPtr CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) { +RetainPtr CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) { iGlyphIndex = static_cast(iGlyphIndex) >> 24; if (iGlyphIndex == 0) - return CFX_RetainPtr(this); + return RetainPtr(this); return m_SubstFonts[iGlyphIndex - 1]; } diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h index c83fc4319d..f88f8b4cd9 100644 --- a/xfa/fgas/font/cfgas_gefont.h +++ b/xfa/fgas/font/cfgas_gefont.h @@ -11,9 +11,9 @@ #include #include -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_memory.h" +#include "core/fxcrt/retain_ptr.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fgas/font/cfgas_pdffontmgr.h" @@ -22,25 +22,24 @@ class CFGAS_FontMgr; class CFX_UnicodeEncoding; -class CFGAS_GEFont : public CFX_Retainable { +class CFGAS_GEFont : public Retainable { public: template - friend class CFX_RetainPtr; + friend class RetainPtr; template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + friend RetainPtr pdfium::MakeRetain(Args&&... args); - static CFX_RetainPtr LoadFont(const wchar_t* pszFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage, - CFGAS_FontMgr* pFontMgr); - static CFX_RetainPtr LoadFont(CFX_Font* pExternalFont, - CFGAS_FontMgr* pFontMgr); - static CFX_RetainPtr LoadFont( + static RetainPtr LoadFont(const wchar_t* pszFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage, + CFGAS_FontMgr* pFontMgr); + static RetainPtr LoadFont(CFX_Font* pExternalFont, + CFGAS_FontMgr* pFontMgr); + static RetainPtr LoadFont( std::unique_ptr pInternalFont, CFGAS_FontMgr* pFontMgr); - CFX_RetainPtr Derive(uint32_t dwFontStyles, - uint16_t wCodePage = 0); + RetainPtr Derive(uint32_t dwFontStyles, uint16_t wCodePage = 0); uint32_t GetFontStyles() const; bool GetCharWidth(wchar_t wUnicode, int32_t& iWidth, bool bCharCode); int32_t GetGlyphIndex(wchar_t wUnicode, bool bCharCode = false); @@ -48,7 +47,7 @@ class CFGAS_GEFont : public CFX_Retainable { int32_t GetDescent() const; bool GetCharBBox(wchar_t wUnicode, CFX_Rect* bbox, bool bCharCode = false); bool GetBBox(CFX_Rect* bbox); - CFX_RetainPtr GetSubstFont(int32_t iGlyphIndex); + RetainPtr GetSubstFont(int32_t iGlyphIndex); CFX_Font* GetDevFont() const { return m_pFont; } void SetFontProvider(CFGAS_PDFFontMgr* pProvider) { m_pProvider.Reset(pProvider); @@ -62,7 +61,7 @@ class CFGAS_GEFont : public CFX_Retainable { private: explicit CFGAS_GEFont(CFGAS_FontMgr* pFontMgr); - CFGAS_GEFont(const CFX_RetainPtr& src, uint32_t dwFontStyles); + CFGAS_GEFont(const RetainPtr& src, uint32_t dwFontStyles); ~CFGAS_GEFont() override; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ @@ -70,9 +69,8 @@ class CFGAS_GEFont : public CFX_Retainable { uint32_t dwFontStyles, uint16_t wCodePage); bool LoadFontInternal(const uint8_t* pBuffer, int32_t length); - bool LoadFontInternal( - const CFX_RetainPtr& pFontStream, - bool bSaveStream); + bool LoadFontInternal(const RetainPtr& pFontStream, + bool bSaveStream); #endif bool LoadFontInternal(CFX_Font* pExternalFont); bool LoadFontInternal(std::unique_ptr pInternalFont); @@ -87,7 +85,7 @@ class CFGAS_GEFont : public CFX_Retainable { bool bCharCode); int32_t GetGlyphIndex(wchar_t wUnicode, bool bRecursive, - CFX_RetainPtr* ppFont, + RetainPtr* ppFont, bool bCharCode = false); WideString GetFamilyName() const; @@ -97,16 +95,16 @@ class CFGAS_GEFont : public CFX_Retainable { #endif CFX_Font* m_pFont; bool m_bExternalFont; - CFX_RetainPtr m_pSrcFont; // Only set by ctor, so no cycles. + RetainPtr m_pSrcFont; // Only set by ctor, so no cycles. CFGAS_FontMgr::ObservedPtr m_pFontMgr; CFGAS_PDFFontMgr::ObservedPtr m_pProvider; - CFX_RetainPtr m_pStream; - CFX_RetainPtr m_pFileRead; + RetainPtr m_pStream; + RetainPtr m_pFileRead; std::unique_ptr m_pFontEncoding; std::map m_CharWidthMap; std::map m_BBoxMap; - std::vector> m_SubstFonts; - std::map> m_FontMapper; + std::vector> m_SubstFonts; + std::map> m_FontMapper; }; #endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_ diff --git a/xfa/fgas/font/cfgas_pdffontmgr.cpp b/xfa/fgas/font/cfgas_pdffontmgr.cpp index 2b8e30e5ee..0fd18aa9b9 100644 --- a/xfa/fgas/font/cfgas_pdffontmgr.cpp +++ b/xfa/fgas/font/cfgas_pdffontmgr.cpp @@ -32,12 +32,11 @@ CFGAS_PDFFontMgr::CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr) CFGAS_PDFFontMgr::~CFGAS_PDFFontMgr() {} -CFX_RetainPtr CFGAS_PDFFontMgr::FindFont( - const ByteString& strPsName, - bool bBold, - bool bItalic, - CPDF_Font** pDstPDFFont, - bool bStrictMatch) { +RetainPtr CFGAS_PDFFontMgr::FindFont(const ByteString& strPsName, + bool bBold, + bool bItalic, + CPDF_Font** pDstPDFFont, + bool bStrictMatch) { CPDF_Dictionary* pFontSetDict = m_pDoc->GetRoot()->GetDictFor("AcroForm")->GetDictFor("DR"); if (!pFontSetDict) @@ -73,7 +72,7 @@ CFX_RetainPtr CFGAS_PDFFontMgr::FindFont( return nullptr; } -CFX_RetainPtr CFGAS_PDFFontMgr::GetFont( +RetainPtr CFGAS_PDFFontMgr::GetFont( const WideStringView& wsFontFamily, uint32_t dwFontStyles, CPDF_Font** pPDFFont, @@ -89,7 +88,7 @@ CFX_RetainPtr CFGAS_PDFFontMgr::GetFont( bool bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold; bool bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic; ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic); - CFX_RetainPtr pFont = + RetainPtr pFont = FindFont(strFontName, bBold, bItalic, pPDFFont, bStrictMatch); if (pFont) m_FontMap[strKey] = pFont; @@ -185,7 +184,7 @@ bool CFGAS_PDFFontMgr::PsNameMatchDRFontName(const ByteStringView& bsPsName, return true; } -bool CFGAS_PDFFontMgr::GetCharWidth(const CFX_RetainPtr& pFont, +bool CFGAS_PDFFontMgr::GetCharWidth(const RetainPtr& pFont, wchar_t wUnicode, bool bCharCode, int32_t* pWidth) { @@ -201,7 +200,7 @@ bool CFGAS_PDFFontMgr::GetCharWidth(const CFX_RetainPtr& pFont, return true; } -void CFGAS_PDFFontMgr::SetFont(const CFX_RetainPtr& pFont, +void CFGAS_PDFFontMgr::SetFont(const RetainPtr& pFont, CPDF_Font* pPDFFont) { m_FDE2PDFFont[pFont] = pPDFFont; } diff --git a/xfa/fgas/font/cfgas_pdffontmgr.h b/xfa/fgas/font/cfgas_pdffontmgr.h index a31d865cec..1f7d49a4e7 100644 --- a/xfa/fgas/font/cfgas_pdffontmgr.h +++ b/xfa/fgas/font/cfgas_pdffontmgr.h @@ -11,9 +11,9 @@ #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_document.h" -#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/observable.h" +#include "core/fxcrt/retain_ptr.h" class CFGAS_FontMgr; class CFGAS_GEFont; @@ -25,22 +25,22 @@ class CFGAS_PDFFontMgr : public Observable { explicit CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr); ~CFGAS_PDFFontMgr(); - CFX_RetainPtr GetFont(const WideStringView& wsFontFamily, - uint32_t dwFontStyles, - CPDF_Font** pPDFFont, - bool bStrictMatch); - bool GetCharWidth(const CFX_RetainPtr& pFont, + RetainPtr GetFont(const WideStringView& wsFontFamily, + uint32_t dwFontStyles, + CPDF_Font** pPDFFont, + bool bStrictMatch); + bool GetCharWidth(const RetainPtr& pFont, wchar_t wUnicode, bool bCharCode, int32_t* pWidth); - void SetFont(const CFX_RetainPtr& pFont, CPDF_Font* pPDFFont); + void SetFont(const RetainPtr& pFont, CPDF_Font* pPDFFont); private: - CFX_RetainPtr FindFont(const ByteString& strFamilyName, - bool bBold, - bool bItalic, - CPDF_Font** pPDFFont, - bool bStrictMatch); + RetainPtr FindFont(const ByteString& strFamilyName, + bool bBold, + bool bItalic, + CPDF_Font** pPDFFont, + bool bStrictMatch); ByteString PsNameToFontName(const ByteString& strPsName, bool bBold, bool bItalic); @@ -52,8 +52,8 @@ class CFGAS_PDFFontMgr : public Observable { CFX_UnownedPtr const m_pDoc; CFX_UnownedPtr const m_pFontMgr; - std::map, CPDF_Font*> m_FDE2PDFFont; - std::map> m_FontMap; + std::map, CPDF_Font*> m_FDE2PDFFont; + std::map> m_FontMap; }; #endif // XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_ -- cgit v1.2.3