summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2018-08-24 17:55:00 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-24 17:55:00 +0000
commit1cb4d6b14cc9375dc04f57d3f2149eccb9e327a8 (patch)
tree09da0a3718ee821e22df75b0c55906f339979933 /core
parentce26d7d03d6c80f7dd1db0f650cac6f93fd53fee (diff)
downloadpdfium-1cb4d6b14cc9375dc04f57d3f2149eccb9e327a8.tar.xz
Cleanup CalculateBaseSpace in CPDF_TextPage
Change-Id: Iaa3e8d88083d7ac15762ff2d5d74a378f626483c Reviewed-on: https://pdfium-review.googlesource.com/41350 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdftext/cpdf_textpage.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 8375d1f8cc..7ddf6d9282 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -48,26 +48,27 @@ float NormalizeThreshold(float threshold, int t1, int t2, int t3) {
float CalculateBaseSpace(const CPDF_TextObject* pTextObj,
const CFX_Matrix& matrix) {
- float baseSpace = 0.0;
const size_t nItems = pTextObj->CountItems();
- if (pTextObj->m_TextState.GetCharSpace() && nItems >= 3) {
- bool bAllChar = true;
- float spacing =
- matrix.TransformDistance(pTextObj->m_TextState.GetCharSpace());
- baseSpace = spacing;
- for (size_t i = 0; i < nItems; ++i) {
- CPDF_TextObjectItem item;
- pTextObj->GetItemInfo(i, &item);
- if (item.m_CharCode == static_cast<uint32_t>(-1)) {
- float fontsize_h = pTextObj->m_TextState.GetFontSizeH();
- float kerning = -fontsize_h * item.m_Origin.x / 1000;
- baseSpace = std::min(baseSpace, kerning + spacing);
- bAllChar = false;
- }
+ if (!pTextObj->m_TextState.GetCharSpace() || nItems < 3)
+ return 0.0f;
+
+ bool bAllChar = true;
+ float spacing =
+ matrix.TransformDistance(pTextObj->m_TextState.GetCharSpace());
+ float baseSpace = spacing;
+ for (size_t i = 0; i < nItems; ++i) {
+ CPDF_TextObjectItem item;
+ pTextObj->GetItemInfo(i, &item);
+ if (item.m_CharCode == static_cast<uint32_t>(-1)) {
+ float fontsize_h = pTextObj->m_TextState.GetFontSizeH();
+ float kerning = -fontsize_h * item.m_Origin.x / 1000;
+ baseSpace = std::min(baseSpace, kerning + spacing);
+ bAllChar = false;
}
- if (baseSpace < 0.0 || (nItems == 3 && !bAllChar))
- baseSpace = 0.0;
}
+ if (baseSpace < 0.0 || (nItems == 3 && !bAllChar))
+ return 0.0f;
+
return baseSpace;
}
@@ -90,7 +91,7 @@ size_t Unicode_GetNormalization(wchar_t wch, wchar_t* pDst) {
wFind >>= 12;
const uint16_t* pMap = g_UnicodeData_Normalization_Maps[wFind - 2] + wch;
if (wFind == 4)
- wFind = (wchar_t)(*pMap++);
+ wFind = static_cast<wchar_t>(*pMap++);
if (pDst) {
wchar_t n = wFind;