diff options
author | Lei Zhang <thestig@chromium.org> | 2018-05-15 00:19:29 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-15 00:19:29 +0000 |
commit | 96805eb6531fca59dc420c4d330f092a851eb8ca (patch) | |
tree | f353fc0378d06c2fbb9f842cdf8bc14077a14160 /core/fpdftext | |
parent | 08d96f1cadb14d91b051e7568de0c43804ba7340 (diff) | |
download | pdfium-96805eb6531fca59dc420c4d330f092a851eb8ca.tar.xz |
Return earlier in CPDF_TextPage::ProcessInsertObject() when possible.
Change-Id: Ibc446d9f4606d29f997ee3521f31f0fbcf1ad84b
Reviewed-on: https://pdfium-review.googlesource.com/32176
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fpdftext')
-rw-r--r-- | core/fpdftext/cpdf_textpage.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 2daaea4abb..dae973bea9 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -1019,7 +1019,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { if (wstrItem.IsEmpty()) wstrItem += (wchar_t)item.m_CharCode; wchar_t curChar = wstrItem[0]; - if (curChar == 0x2D || curChar == 0xAD) + if (IsHyphenCode(curChar)) return; } while (m_TempTextBuf.GetSize() > 0 && @@ -1340,16 +1340,20 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( : GenerateCharacter::LineBreak; } - if (pObj->CountChars() == 1 && (0x2D == curChar || 0xAD == curChar) && - IsHyphen(curChar)) { + if (pObj->CountChars() == 1 && IsHyphenCode(curChar) && IsHyphen(curChar)) return GenerateCharacter::Hyphen; - } + + if (curChar == L' ') + return GenerateCharacter::None; + WideString PrevStr = m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode); wchar_t preChar = PrevStr.Last(); + if (preChar == L' ') + return GenerateCharacter::None; + CFX_Matrix matrix = pObj->GetTextMatrix(); matrix.Concat(formMatrix); - float threshold2 = static_cast<float>(std::max(nLastWidth, nThisWidth)); threshold2 = NormalizeThreshold(threshold2, 400, 700, 800); if (nLastWidth >= nThisWidth) { @@ -1364,8 +1368,6 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( (threshold2 < 1.39001 && threshold2 > 1.38999)) { threshold2 *= 1.5; } - if (curChar == L' ' || preChar == L' ') - return GenerateCharacter::None; return GenerateSpace(pos, last_pos, this_width, last_width, threshold2) ? GenerateCharacter::Space : GenerateCharacter::None; |