Index: core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp |
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp |
index 8053718c190fef0413ae94c8a1857a2a30f136ca..99bb5b89cd03b14640286bce705ec0a2d2f4fbe7 100644 |
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp |
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp |
@@ -285,6 +285,7 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, FX_FLOAT* pValue, |
CPDF_TextStateData::CPDF_TextStateData() |
{ |
m_pFont = NULL; |
+ m_pDocument = NULL; |
m_FontSize = 1.0f; |
m_WordSpace = 0; |
m_CharSpace = 0; |
@@ -296,27 +297,35 @@ CPDF_TextStateData::CPDF_TextStateData() |
} |
CPDF_TextStateData::CPDF_TextStateData(const CPDF_TextStateData& src) |
{ |
+ if (this == &src) { |
+ return; |
+ } |
FXSYS_memcpy32(this, &src, sizeof(CPDF_TextStateData)); |
- if (m_pFont && m_pFont->m_pDocument) { |
- m_pFont = m_pFont->m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict(), FALSE); |
+ if (m_pDocument && m_pFont) { |
+ m_pFont = m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict(), FALSE); |
} |
} |
CPDF_TextStateData::~CPDF_TextStateData() |
{ |
- CPDF_Font* pFont = m_pFont; |
- if (pFont && pFont->m_pDocument) { |
- pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict()); |
+ if (m_pDocument && m_pFont) { |
+ CPDF_DocPageData *pPageData = m_pDocument->GetPageData(); |
+ if (pPageData && !pPageData->IsForceClear()) { |
+ pPageData->ReleaseFont(m_pFont->GetFontDict()); |
+ } |
} |
} |
void CPDF_TextState::SetFont(CPDF_Font* pFont) |
{ |
- CPDF_Font*& pStateFont = GetModify()->m_pFont; |
- CPDF_DocPageData* pDocPageData = NULL; |
- if (pStateFont && pStateFont->m_pDocument) { |
- pDocPageData = pStateFont->m_pDocument->GetPageData(); |
- pDocPageData->ReleaseFont(pStateFont->GetFontDict()); |
+ CPDF_TextStateData* pStateData = GetModify(); |
+ if (pStateData) { |
+ CPDF_Document* pDoc = pStateData->m_pDocument; |
+ CPDF_DocPageData *pPageData = pDoc ? pDoc->GetPageData() : NULL; |
+ if (pPageData && pStateData->m_pFont && !pPageData->IsForceClear()) { |
+ pPageData->ReleaseFont(pStateData->m_pFont->GetFontDict()); |
+ } |
+ pStateData->m_pDocument = pFont ? pFont->m_pDocument : NULL; |
+ pStateData->m_pFont = pFont; |
} |
- pStateFont = pFont; |
} |
FX_FLOAT CPDF_TextState::GetFontSizeV() const |
{ |