diff options
Diffstat (limited to 'chromium/third_party/pdfium')
3 files changed, 29 insertions, 24 deletions
diff --git a/chromium/third_party/pdfium/core/fpdftext/cpdf_textpage.cpp b/chromium/third_party/pdfium/core/fpdftext/cpdf_textpage.cpp index fd33fb2f2fc..d528c6994f7 100644 --- a/chromium/third_party/pdfium/core/fpdftext/cpdf_textpage.cpp +++ b/chromium/third_party/pdfium/core/fpdftext/cpdf_textpage.cpp @@ -1218,25 +1218,26 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode( } bool CPDF_TextPage::IsHyphen(wchar_t curChar) const { - WideStringView curText; - if (!m_TempTextBuf.IsEmpty()) - curText = m_TempTextBuf.AsStringView(); - else if (!m_TextBuf.IsEmpty()) + WideStringView curText = m_TempTextBuf.AsStringView(); + if (curText.IsEmpty()) curText = m_TextBuf.AsStringView(); - else - return false; - curText = curText.TrimmedRight(0x20); - if (curText.GetLength() < 2) + if (curText.IsEmpty()) return false; - // Extracting the last 2 characters, since they are all that matter - curText = curText.Right(2); - if (!IsHyphenCode(curText.Last())) + auto iter = curText.rbegin(); + for (; (iter + 1) != curText.rend() && *iter == 0x20; iter++) { + // Do nothing + } + + if (!IsHyphenCode(*iter)) return false; - if (FXSYS_iswalpha(curText.First() && FXSYS_iswalnum(curChar))) - return true; + if ((iter + 1) != curText.rend()) { + iter++; + if (FXSYS_iswalpha(*iter) && FXSYS_iswalpha(*iter)) + return true; + } const PAGECHAR_INFO* preInfo; if (!m_TempCharList.empty()) @@ -1355,9 +1356,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( } WideString PrevStr = m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode); - if (PrevStr.IsEmpty()) - return GenerateCharacter::None; - wchar_t preChar = PrevStr[PrevStr.GetLength() - 1]; + wchar_t preChar = PrevStr.Last(); CFX_Matrix matrix = pObj->GetTextMatrix(); matrix.Concat(formMatrix); diff --git a/chromium/third_party/pdfium/core/fxge/win32/cfx_psrenderer.cpp b/chromium/third_party/pdfium/core/fxge/win32/cfx_psrenderer.cpp index d97391822a3..ecfab49c385 100644 --- a/chromium/third_party/pdfium/core/fxge/win32/cfx_psrenderer.cpp +++ b/chromium/third_party/pdfium/core/fxge/win32/cfx_psrenderer.cpp @@ -644,16 +644,20 @@ bool CFX_PSRenderer::DrawText(int nChars, const CFX_Matrix* pObject2Device, float font_size, uint32_t color) { - StartRendering(); - int alpha = FXARGB_A(color); - if (alpha < 255) - return false; + // Do not send zero or negative font sizes to printers. See crbug.com/767343. + if (font_size <= 0.0) + return true; if ((pObject2Device->a == 0 && pObject2Device->b == 0) || (pObject2Device->c == 0 && pObject2Device->d == 0)) { return true; } + StartRendering(); + int alpha = FXARGB_A(color); + if (alpha < 255) + return false; + SetColor(color); std::ostringstream buf; buf << "q[" << pObject2Device->a << " " << pObject2Device->b << " " diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp index af1d0db1afa..069a7239fd6 100644 --- a/chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp +++ b/chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp @@ -869,10 +869,12 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPage(HDC dc, // of masks. Full page bitmaps result in large spool sizes, so they should // only be used when necessary. For large numbers of masks, rendering each // individually is inefficient and unlikely to significantly improve spool - // size. - const bool bNewBitmap = - pPage->BackgroundAlphaNeeded() || - (pPage->HasImageMask() && pPage->GetMaskBoundingBoxes().size() > 100); + // size. TODO (rbpotter): Find out why this still breaks printing for some + // PDFs (see crbug.com/777837). + const bool bEnableImageMasks = false; + const bool bNewBitmap = pPage->BackgroundAlphaNeeded() || + (pPage->HasImageMask() && !bEnableImageMasks) || + pPage->GetMaskBoundingBoxes().size() > 100; const bool bHasMask = pPage->HasImageMask() && !bNewBitmap; if (bNewBitmap || bHasMask) { pBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); |