From 96805eb6531fca59dc420c4d330f092a851eb8ca Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 15 May 2018 00:19:29 +0000 Subject: Return earlier in CPDF_TextPage::ProcessInsertObject() when possible. Change-Id: Ibc446d9f4606d29f997ee3521f31f0fbcf1ad84b Reviewed-on: https://pdfium-review.googlesource.com/32176 Commit-Queue: Lei Zhang Reviewed-by: Ryan Harrison --- core/fpdftext/cpdf_textpage.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'core/fpdftext/cpdf_textpage.cpp') 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(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; -- cgit v1.2.3