summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_textstate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/page/cpdf_textstate.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_textstate.cpp24
1 files changed, 12 insertions, 12 deletions
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;