diff options
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_color.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_textstate.cpp | 24 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_textstate.h | 3 |
3 files changed, 16 insertions, 14 deletions
diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp index 6e772aadb1..ca0e621530 100644 --- a/core/fpdfapi/page/cpdf_color.cpp +++ b/core/fpdfapi/page/cpdf_color.cpp @@ -91,8 +91,7 @@ void CPDF_Color::SetValue(CPDF_Pattern* pPattern, float* comps, int ncomps) { PatternValue* pvalue = (PatternValue*)m_pBuffer; if (pvalue->m_pPattern) { pDocPageData = pvalue->m_pPattern->document()->GetPageData(); - if (pDocPageData) - pDocPageData->ReleasePattern(pvalue->m_pPattern->pattern_obj()); + pDocPageData->ReleasePattern(pvalue->m_pPattern->pattern_obj()); } pvalue->m_nComps = ncomps; pvalue->m_pPattern = pPattern; diff --git a/core/fpdfapi/page/cpdf_textstate.cpp b/core/fpdfapi/page/cpdf_textstate.cpp index 6dbad55ba6..bd236a2f28 100644 --- a/core/fpdfapi/page/cpdf_textstate.cpp +++ b/core/fpdfapi/page/cpdf_textstate.cpp @@ -115,25 +115,16 @@ CPDF_TextState::TextData::TextData(const TextData& that) for (int i = 0; i < 4; ++i) m_CTM[i] = that.m_CTM[i]; - if (m_pDocument && m_pFont) { + if (m_pDocument && m_pFont) m_pFont = m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict()); - } } CPDF_TextState::TextData::~TextData() { - if (m_pDocument && m_pFont) { - CPDF_DocPageData* pPageData = m_pDocument->GetPageData(); - if (pPageData && !pPageData->IsForceClear()) - pPageData->ReleaseFont(m_pFont->GetFontDict()); - } + ReleaseFont(); } void CPDF_TextState::TextData::SetFont(CPDF_Font* pFont) { - CPDF_Document* pDoc = m_pDocument; - CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr; - if (pPageData && m_pFont && !pPageData->IsForceClear()) - pPageData->ReleaseFont(m_pFont->GetFontDict()); - + ReleaseFont(); m_pDocument = pFont ? pFont->GetDocument() : nullptr; m_pFont = pFont; } @@ -154,6 +145,15 @@ float CPDF_TextState::TextData::GetShearAngle() const { return GetBaselineAngle() + atan2(m_Matrix[1], m_Matrix[3]); } +void CPDF_TextState::TextData::ReleaseFont() { + if (!m_pDocument || !m_pFont) + return; + + CPDF_DocPageData* pPageData = m_pDocument->GetPageData(); + if (pPageData && !pPageData->IsForceClear()) + pPageData->ReleaseFont(m_pFont->GetFontDict()); +} + bool SetTextRenderingModeFromInt(int iMode, TextRenderingMode* mode) { if (iMode < 0 || iMode > 7) return false; diff --git a/core/fpdfapi/page/cpdf_textstate.h b/core/fpdfapi/page/cpdf_textstate.h index 07bee5ed04..84d2c13a6c 100644 --- a/core/fpdfapi/page/cpdf_textstate.h +++ b/core/fpdfapi/page/cpdf_textstate.h @@ -79,6 +79,9 @@ class CPDF_TextState { TextRenderingMode m_TextMode; float m_Matrix[4]; float m_CTM[4]; + + private: + void ReleaseFont(); }; CFX_SharedCopyOnWrite<TextData> m_Ref; |