summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp6
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h3
-rw-r--r--xfa/fxfa/cxfa_fontmgr.cpp16
-rw-r--r--xfa/fxfa/cxfa_fontmgr.h3
4 files changed, 10 insertions, 18 deletions
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index b3ff3c9930..316987fcc3 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -241,7 +241,9 @@ int32_t CXFA_FFDoc::DoLoad() {
}
void CXFA_FFDoc::StopLoad() {
- m_pApp->GetXFAFontMgr()->LoadDocFonts(this);
+ m_pPDFFontMgr = pdfium::MakeUnique<CFGAS_PDFFontMgr>(
+ GetPDFDoc(), GetApp()->GetFDEFontMgr());
+
m_dwDocType = XFA_DocType::Static;
CXFA_Node* pConfig = ToNode(
m_pDocumentParser->GetDocument()->GetXFAObject(XFA_HASHCODE_Config));
@@ -327,7 +329,7 @@ void CXFA_FFDoc::CloseDoc() {
doc->ClearLayoutData();
m_pNotify.reset();
- m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this);
+ m_pPDFFontMgr.reset();
m_HashToDibDpiMap.clear();
m_pApp->ClearEventTargets();
}
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index 7984d7425b..1d35c669da 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -15,6 +15,7 @@
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_document_parser.h"
+class CFGAS_PDFFontMgr;
class CFX_ChecksumContext;
class CXFA_FFApp;
class CXFA_FFNotify;
@@ -72,6 +73,7 @@ class CXFA_FFDoc {
CFX_RetainPtr<CFX_DIBitmap> GetPDFNamedImage(const WideStringView& wsName,
int32_t& iImageXDpi,
int32_t& iImageYDpi);
+ CFGAS_PDFFontMgr* GetPDFFontMgr() const { return m_pPDFFontMgr.get(); }
bool SavePackage(XFA_HashCode code,
const CFX_RetainPtr<IFX_SeekableStream>& pFile,
@@ -88,6 +90,7 @@ class CXFA_FFDoc {
CFX_UnownedPtr<CPDF_Document> m_pPDFDoc;
std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap;
std::unique_ptr<CXFA_FFDocView> m_DocView;
+ std::unique_ptr<CFGAS_PDFFontMgr> m_pPDFFontMgr;
XFA_DocType m_dwDocType;
};
diff --git a/xfa/fxfa/cxfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp
index d5ba2ea807..5a11dd5dc0 100644
--- a/xfa/fxfa/cxfa_fontmgr.cpp
+++ b/xfa/fxfa/cxfa_fontmgr.cpp
@@ -36,9 +36,8 @@ CFX_RetainPtr<CFGAS_GEFont> CXFA_FontMgr::GetFont(
return iter->second;
WideString wsEnglishName = FGAS_FontNameToEnglishName(wsFontFamily);
- auto it = m_PDFFontMgrMap.find(hDoc);
- CFGAS_PDFFontMgr* pMgr =
- it != m_PDFFontMgrMap.end() ? it->second.get() : nullptr;
+
+ CFGAS_PDFFontMgr* pMgr = hDoc->GetPDFFontMgr();
CPDF_Font* pPDFFont = nullptr;
CFX_RetainPtr<CFGAS_GEFont> pFont;
if (pMgr) {
@@ -62,6 +61,7 @@ CFX_RetainPtr<CFGAS_GEFont> CXFA_FontMgr::GetFont(
pFont = m_pDefFontMgr->GetDefaultFont(
hDoc->GetApp()->GetFDEFontMgr(), wsFontFamily, dwFontStyles, wCodePage);
}
+
if (pFont) {
if (pPDFFont) {
pMgr->SetFont(pFont, pPDFFont);
@@ -72,16 +72,6 @@ CFX_RetainPtr<CFGAS_GEFont> CXFA_FontMgr::GetFont(
return pFont;
}
-void CXFA_FontMgr::LoadDocFonts(CXFA_FFDoc* hDoc) {
- if (!m_PDFFontMgrMap[hDoc])
- m_PDFFontMgrMap[hDoc] = pdfium::MakeUnique<CFGAS_PDFFontMgr>(
- hDoc->GetPDFDoc(), hDoc->GetApp()->GetFDEFontMgr());
-}
-
-void CXFA_FontMgr::ReleaseDocFonts(CXFA_FFDoc* hDoc) {
- m_PDFFontMgrMap.erase(hDoc);
-}
-
void CXFA_FontMgr::SetDefFontMgr(
std::unique_ptr<CFGAS_DefaultFontManager> pFontMgr) {
m_pDefFontMgr = std::move(pFontMgr);
diff --git a/xfa/fxfa/cxfa_fontmgr.h b/xfa/fxfa/cxfa_fontmgr.h
index 988964dab2..b7d1f51ff2 100644
--- a/xfa/fxfa/cxfa_fontmgr.h
+++ b/xfa/fxfa/cxfa_fontmgr.h
@@ -30,13 +30,10 @@ class CXFA_FontMgr {
const WideStringView& wsFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage = 0xFFFF);
- void LoadDocFonts(CXFA_FFDoc* hDoc);
- void ReleaseDocFonts(CXFA_FFDoc* hDoc);
void SetDefFontMgr(std::unique_ptr<CFGAS_DefaultFontManager> pFontMgr);
private:
std::unique_ptr<CFGAS_DefaultFontManager> m_pDefFontMgr;
- std::map<CXFA_FFDoc*, std::unique_ptr<CFGAS_PDFFontMgr>> m_PDFFontMgrMap;
std::map<ByteString, CFX_RetainPtr<CFGAS_GEFont>> m_FontMap;
};