| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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/src/fpdfapi/fpdf_page/pageint.h" | 7 #include "core/src/fpdfapi/fpdf_page/pageint.h" |
| 8 | 8 |
| 9 #include "core/include/fpdfapi/fpdf_module.h" | 9 #include "core/include/fpdfapi/fpdf_module.h" |
| 10 #include "core/include/fpdfapi/fpdf_page.h" | 10 #include "core/include/fpdfapi/fpdf_page.h" |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 FX_FLOAT fInitKerning, | 1344 FX_FLOAT fInitKerning, |
| 1345 FX_FLOAT* pKerning, | 1345 FX_FLOAT* pKerning, |
| 1346 int nsegs) { | 1346 int nsegs) { |
| 1347 CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont(); | 1347 CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont(); |
| 1348 if (!pFont) { | 1348 if (!pFont) { |
| 1349 return; | 1349 return; |
| 1350 } | 1350 } |
| 1351 if (fInitKerning != 0) { | 1351 if (fInitKerning != 0) { |
| 1352 if (!pFont->IsVertWriting()) { | 1352 if (!pFont->IsVertWriting()) { |
| 1353 m_pCurStates->m_TextX -= | 1353 m_pCurStates->m_TextX -= |
| 1354 FXSYS_Mul(fInitKerning, m_pCurStates->m_TextState.GetFontSize()) / | 1354 (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000; |
| 1355 1000; | |
| 1356 } else { | 1355 } else { |
| 1357 m_pCurStates->m_TextY -= | 1356 m_pCurStates->m_TextY -= |
| 1358 FXSYS_Mul(fInitKerning, m_pCurStates->m_TextState.GetFontSize()) / | 1357 (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000; |
| 1359 1000; | |
| 1360 } | 1358 } |
| 1361 } | 1359 } |
| 1362 if (nsegs == 0) { | 1360 if (nsegs == 0) { |
| 1363 return; | 1361 return; |
| 1364 } | 1362 } |
| 1365 int textmode; | 1363 int textmode; |
| 1366 if (pFont->GetFontType() == PDFFONT_TYPE3) { | 1364 if (pFont->GetFontType() == PDFFONT_TYPE3) { |
| 1367 textmode = 0; | 1365 textmode = 0; |
| 1368 } else { | 1366 } else { |
| 1369 textmode = m_pCurStates->m_TextState.GetObject()->m_TextMode; | 1367 textmode = m_pCurStates->m_TextState.GetObject()->m_TextMode; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1389 m_pCurStates->m_TextHorzScale, m_Level); | 1387 m_pCurStates->m_TextHorzScale, m_Level); |
| 1390 m_pCurStates->m_TextX += x_advance; | 1388 m_pCurStates->m_TextX += x_advance; |
| 1391 m_pCurStates->m_TextY += y_advance; | 1389 m_pCurStates->m_TextY += y_advance; |
| 1392 if (textmode > 3) | 1390 if (textmode > 3) |
| 1393 m_ClipTextList.Add(pText->Clone()); | 1391 m_ClipTextList.Add(pText->Clone()); |
| 1394 m_pObjectHolder->GetPageObjectList()->push_back(std::move(pText)); | 1392 m_pObjectHolder->GetPageObjectList()->push_back(std::move(pText)); |
| 1395 } | 1393 } |
| 1396 if (pKerning && pKerning[nsegs - 1] != 0) { | 1394 if (pKerning && pKerning[nsegs - 1] != 0) { |
| 1397 if (!pFont->IsVertWriting()) { | 1395 if (!pFont->IsVertWriting()) { |
| 1398 m_pCurStates->m_TextX -= | 1396 m_pCurStates->m_TextX -= |
| 1399 FXSYS_Mul(pKerning[nsegs - 1], | 1397 (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) / |
| 1400 m_pCurStates->m_TextState.GetFontSize()) / | |
| 1401 1000; | 1398 1000; |
| 1402 } else { | 1399 } else { |
| 1403 m_pCurStates->m_TextY -= | 1400 m_pCurStates->m_TextY -= |
| 1404 FXSYS_Mul(pKerning[nsegs - 1], | 1401 (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) / |
| 1405 m_pCurStates->m_TextState.GetFontSize()) / | |
| 1406 1000; | 1402 1000; |
| 1407 } | 1403 } |
| 1408 } | 1404 } |
| 1409 } | 1405 } |
| 1410 | 1406 |
| 1411 void CPDF_StreamContentParser::Handle_ShowText() { | 1407 void CPDF_StreamContentParser::Handle_ShowText() { |
| 1412 CFX_ByteString str = GetString(0); | 1408 CFX_ByteString str = GetString(0); |
| 1413 if (str.IsEmpty()) { | 1409 if (str.IsEmpty()) { |
| 1414 return; | 1410 return; |
| 1415 } | 1411 } |
| 1416 AddTextObject(&str, 0, NULL, 1); | 1412 AddTextObject(&str, 0, NULL, 1); |
| 1417 } | 1413 } |
| 1418 | 1414 |
| 1419 void CPDF_StreamContentParser::Handle_ShowText_Positioning() { | 1415 void CPDF_StreamContentParser::Handle_ShowText_Positioning() { |
| 1420 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL; | 1416 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL; |
| 1421 if (!pArray) { | 1417 if (!pArray) { |
| 1422 return; | 1418 return; |
| 1423 } | 1419 } |
| 1424 int n = pArray->GetCount(); | 1420 int n = pArray->GetCount(); |
| 1425 int nsegs = 0; | 1421 int nsegs = 0; |
| 1426 for (int i = 0; i < n; i++) { | 1422 for (int i = 0; i < n; i++) { |
| 1427 if (pArray->GetElementValue(i)->IsString()) | 1423 if (pArray->GetElementValue(i)->IsString()) |
| 1428 nsegs++; | 1424 nsegs++; |
| 1429 } | 1425 } |
| 1430 if (nsegs == 0) { | 1426 if (nsegs == 0) { |
| 1431 for (int i = 0; i < n; i++) { | 1427 for (int i = 0; i < n; i++) { |
| 1432 m_pCurStates->m_TextX -= | 1428 m_pCurStates->m_TextX -= |
| 1433 FXSYS_Mul(pArray->GetNumberAt(i), | 1429 (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) / |
| 1434 m_pCurStates->m_TextState.GetFontSize()) / | |
| 1435 1000; | 1430 1000; |
| 1436 } | 1431 } |
| 1437 return; | 1432 return; |
| 1438 } | 1433 } |
| 1439 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; | 1434 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; |
| 1440 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); | 1435 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); |
| 1441 int iSegment = 0; | 1436 int iSegment = 0; |
| 1442 FX_FLOAT fInitKerning = 0; | 1437 FX_FLOAT fInitKerning = 0; |
| 1443 for (int i = 0; i < n; i++) { | 1438 for (int i = 0; i < n; i++) { |
| 1444 CPDF_Object* pObj = pArray->GetElementValue(i); | 1439 CPDF_Object* pObj = pArray->GetElementValue(i); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 } else { | 1811 } else { |
| 1817 PDF_ReplaceAbbr(pElement); | 1812 PDF_ReplaceAbbr(pElement); |
| 1818 } | 1813 } |
| 1819 } | 1814 } |
| 1820 break; | 1815 break; |
| 1821 } | 1816 } |
| 1822 default: | 1817 default: |
| 1823 break; | 1818 break; |
| 1824 } | 1819 } |
| 1825 } | 1820 } |
| OLD | NEW |