From c62980ec7539fa5ae2065ba5f287aada3a814173 Mon Sep 17 00:00:00 2001 From: npm Date: Wed, 30 Nov 2016 15:23:11 -0800 Subject: Fix initial kerning when there is a horzscale set Reasoning: the pTextAdvanceX in CPDF_TextObject::CalcPositionData is being multiplied by horz_scale in CPDF_TextObject::CalcPositionData. Then, m_pCurStates->m_TextX is updated by this amount. So multiply by the scale also when updating with initial and final kerning and when nsegs = 0. BUG=528103 Review-Url: https://codereview.chromium.org/2542743002 --- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index df0d5f1117..45a468f7a6 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -1271,7 +1271,9 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs, if (fInitKerning != 0) { if (!pFont->IsVertWriting()) { m_pCurStates->m_TextX -= - (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000; + (fInitKerning * m_pCurStates->m_TextState.GetFontSize() * + m_pCurStates->m_TextHorzScale) / + 1000; } else { m_pCurStates->m_TextY -= (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000; @@ -1313,7 +1315,8 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs, if (pKerning && pKerning[nsegs - 1] != 0) { if (!pFont->IsVertWriting()) { m_pCurStates->m_TextX -= - (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) / + (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize() * + m_pCurStates->m_TextHorzScale) / 1000; } else { m_pCurStates->m_TextY -= @@ -1345,7 +1348,8 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { if (nsegs == 0) { for (size_t i = 0; i < n; i++) { m_pCurStates->m_TextX -= - (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) / + (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize() * + m_pCurStates->m_TextHorzScale) / 1000; } return; -- cgit v1.2.3