From d74da7bb34abdae254df64ba2c0da7a581f6dae0 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 4 May 2017 13:30:29 -0700 Subject: Make CPDF_Font member variables protected. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5d452ea907f4d243645ddae3512776096a827522 Reviewed-on: https://pdfium-review.googlesource.com/4872 Commit-Queue: Lei Zhang Reviewed-by: Nicolás Peña --- core/fpdfapi/render/cpdf_renderstatus.cpp | 11 +++++------ core/fpdfapi/render/cpdf_textrenderer.cpp | 24 ++++++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'core/fpdfapi/render') diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index d41561c057..0b304747d4 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -66,7 +66,7 @@ namespace { void ReleaseCachedType3(CPDF_Type3Font* pFont) { - CPDF_Document* pDoc = pFont->m_pDocument; + CPDF_Document* pDoc = pFont->GetDocument(); if (!pDoc) return; @@ -1799,7 +1799,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, CFX_RetainPtr CPDF_RenderStatus::GetCachedType3( CPDF_Type3Font* pFont) { - CPDF_Document* pDoc = pFont->m_pDocument; + CPDF_Document* pDoc = pFont->GetDocument(); if (!pDoc) return nullptr; @@ -2000,10 +2000,9 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, CharPosList.Load(textobj->m_CharCodes, textobj->m_CharPos, pFont, font_size); for (uint32_t i = 0; i < CharPosList.m_nChars; i++) { FXTEXT_CHARPOS& charpos = CharPosList.m_pCharPos[i]; - auto* font = - charpos.m_FallbackFontPosition == -1 - ? &pFont->m_Font - : pFont->m_FontFallbacks[charpos.m_FallbackFontPosition].get(); + auto* font = charpos.m_FallbackFontPosition == -1 + ? pFont->GetFont() + : pFont->GetFontFallback(charpos.m_FallbackFontPosition); const CFX_PathData* pPath = font->LoadGlyphPath(charpos.m_GlyphIndex, charpos.m_FontCharWidth); if (!pPath) diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp index c45c1ef792..83e61478da 100644 --- a/core/fpdfapi/render/cpdf_textrenderer.cpp +++ b/core/fpdfapi/render/cpdf_textrenderer.cpp @@ -15,6 +15,14 @@ #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" +namespace { + +CFX_Font* GetFont(CPDF_Font* pFont, int32_t position) { + return position == -1 ? pFont->GetFont() : pFont->GetFontFallback(position); +} + +} // namespace + // static bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, const std::vector& charCodes, @@ -40,9 +48,8 @@ bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, int32_t curFontPosition = CharPosList.m_pCharPos[i].m_FallbackFontPosition; if (fontPosition == curFontPosition) continue; - auto* font = fontPosition == -1 - ? &pFont->m_Font - : pFont->m_FontFallbacks[fontPosition].get(); + + CFX_Font* font = GetFont(pFont, fontPosition); if (!pDevice->DrawTextPath(i - startIndex, CharPosList.m_pCharPos + startIndex, font, font_size, pText2User, pUser2Device, pGraphState, @@ -52,8 +59,7 @@ bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, fontPosition = curFontPosition; startIndex = i; } - auto* font = fontPosition == -1 ? &pFont->m_Font - : pFont->m_FontFallbacks[fontPosition].get(); + CFX_Font* font = GetFont(pFont, fontPosition); if (!pDevice->DrawTextPath(CharPosList.m_nChars - startIndex, CharPosList.m_pCharPos + startIndex, font, font_size, pText2User, pUser2Device, pGraphState, @@ -145,9 +151,8 @@ bool CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, int32_t curFontPosition = CharPosList.m_pCharPos[i].m_FallbackFontPosition; if (fontPosition == curFontPosition) continue; - auto* font = fontPosition == -1 - ? &pFont->m_Font - : pFont->m_FontFallbacks[fontPosition].get(); + + CFX_Font* font = GetFont(pFont, fontPosition); if (!pDevice->DrawNormalText( i - startIndex, CharPosList.m_pCharPos + startIndex, font, font_size, pText2Device, fill_argb, FXGE_flags)) { @@ -156,8 +161,7 @@ bool CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, fontPosition = curFontPosition; startIndex = i; } - auto* font = fontPosition == -1 ? &pFont->m_Font - : pFont->m_FontFallbacks[fontPosition].get(); + CFX_Font* font = GetFont(pFont, fontPosition); if (!pDevice->DrawNormalText(CharPosList.m_nChars - startIndex, CharPosList.m_pCharPos + startIndex, font, font_size, pText2Device, fill_argb, -- cgit v1.2.3