Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: core/fpdfapi/page/cpdf_streamcontentparser.cpp

Issue 2542743002: Fix initial kerning when there is a horzscale set (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/page/cpdf_streamcontentparser.h" 7 #include "core/fpdfapi/page/cpdf_streamcontentparser.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 FX_FLOAT fInitKerning, 1264 FX_FLOAT fInitKerning,
1265 FX_FLOAT* pKerning, 1265 FX_FLOAT* pKerning,
1266 int nsegs) { 1266 int nsegs) {
1267 CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont(); 1267 CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont();
1268 if (!pFont) { 1268 if (!pFont) {
1269 return; 1269 return;
1270 } 1270 }
1271 if (fInitKerning != 0) { 1271 if (fInitKerning != 0) {
1272 if (!pFont->IsVertWriting()) { 1272 if (!pFont->IsVertWriting()) {
1273 m_pCurStates->m_TextX -= 1273 m_pCurStates->m_TextX -=
1274 (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000; 1274 (fInitKerning * m_pCurStates->m_TextState.GetFontSize() *
1275 m_pCurStates->m_TextHorzScale) /
1276 1000;
1275 } else { 1277 } else {
1276 m_pCurStates->m_TextY -= 1278 m_pCurStates->m_TextY -=
1277 (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000; 1279 (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000;
1278 } 1280 }
1279 } 1281 }
1280 if (nsegs == 0) { 1282 if (nsegs == 0) {
1281 return; 1283 return;
1282 } 1284 }
1283 const TextRenderingMode text_mode = 1285 const TextRenderingMode text_mode =
1284 pFont->IsType3Font() ? TextRenderingMode::MODE_FILL 1286 pFont->IsType3Font() ? TextRenderingMode::MODE_FILL
(...skipping 21 matching lines...) Expand all
1306 m_pCurStates->m_TextY += y_advance; 1308 m_pCurStates->m_TextY += y_advance;
1307 if (TextRenderingModeIsClipMode(text_mode)) { 1309 if (TextRenderingModeIsClipMode(text_mode)) {
1308 m_ClipTextList.push_back( 1310 m_ClipTextList.push_back(
1309 std::unique_ptr<CPDF_TextObject>(pText->Clone())); 1311 std::unique_ptr<CPDF_TextObject>(pText->Clone()));
1310 } 1312 }
1311 m_pObjectHolder->GetPageObjectList()->push_back(std::move(pText)); 1313 m_pObjectHolder->GetPageObjectList()->push_back(std::move(pText));
1312 } 1314 }
1313 if (pKerning && pKerning[nsegs - 1] != 0) { 1315 if (pKerning && pKerning[nsegs - 1] != 0) {
1314 if (!pFont->IsVertWriting()) { 1316 if (!pFont->IsVertWriting()) {
1315 m_pCurStates->m_TextX -= 1317 m_pCurStates->m_TextX -=
1316 (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) / 1318 (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize() *
1319 m_pCurStates->m_TextHorzScale) /
1317 1000; 1320 1000;
1318 } else { 1321 } else {
1319 m_pCurStates->m_TextY -= 1322 m_pCurStates->m_TextY -=
1320 (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) / 1323 (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) /
1321 1000; 1324 1000;
1322 } 1325 }
1323 } 1326 }
1324 } 1327 }
1325 1328
1326 void CPDF_StreamContentParser::Handle_ShowText() { 1329 void CPDF_StreamContentParser::Handle_ShowText() {
(...skipping 11 matching lines...) Expand all
1338 1341
1339 size_t n = pArray->GetCount(); 1342 size_t n = pArray->GetCount();
1340 size_t nsegs = 0; 1343 size_t nsegs = 0;
1341 for (size_t i = 0; i < n; i++) { 1344 for (size_t i = 0; i < n; i++) {
1342 if (pArray->GetDirectObjectAt(i)->IsString()) 1345 if (pArray->GetDirectObjectAt(i)->IsString())
1343 nsegs++; 1346 nsegs++;
1344 } 1347 }
1345 if (nsegs == 0) { 1348 if (nsegs == 0) {
1346 for (size_t i = 0; i < n; i++) { 1349 for (size_t i = 0; i < n; i++) {
1347 m_pCurStates->m_TextX -= 1350 m_pCurStates->m_TextX -=
1348 (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) / 1351 (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize() *
1352 m_pCurStates->m_TextHorzScale) /
1349 1000; 1353 1000;
1350 } 1354 }
1351 return; 1355 return;
1352 } 1356 }
1353 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; 1357 CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
1354 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); 1358 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
1355 size_t iSegment = 0; 1359 size_t iSegment = 0;
1356 FX_FLOAT fInitKerning = 0; 1360 FX_FLOAT fInitKerning = 0;
1357 for (size_t i = 0; i < n; i++) { 1361 for (size_t i = 0; i < n; i++) {
1358 CPDF_Object* pObj = pArray->GetDirectObjectAt(i); 1362 CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 if (!bProcessed) { 1663 if (!bProcessed) {
1660 m_pSyntax->SetPos(last_pos); 1664 m_pSyntax->SetPos(last_pos);
1661 return; 1665 return;
1662 } 1666 }
1663 } 1667 }
1664 } 1668 }
1665 1669
1666 CPDF_StreamContentParser::ContentParam::ContentParam() {} 1670 CPDF_StreamContentParser::ContentParam::ContentParam() {}
1667 1671
1668 CPDF_StreamContentParser::ContentParam::~ContentParam() {} 1672 CPDF_StreamContentParser::ContentParam::~ContentParam() {}
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698