From 2f68cb53f5938e2dd572db79fc5689c987cb350d Mon Sep 17 00:00:00 2001 From: rbpotter Date: Wed, 14 Feb 2018 01:35:53 +0000 Subject: Pdfium: Allow negative font sizes for PostScript printing Bug: chromium:806746 Change-Id: I0b642c457c55d828dd48988eadfc5fa964de1216 Reviewed-on: https://pdfium-review.googlesource.com/26630 Reviewed-by: Lei Zhang Commit-Queue: Rebekah Potter --- core/fxge/win32/cfx_psrenderer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index b79de57db2..6c4b8ec6f3 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -6,6 +6,7 @@ #include "core/fxge/win32/cfx_psrenderer.h" +#include #include #include @@ -639,15 +640,19 @@ bool CFX_PSRenderer::DrawText(int nChars, const CFX_Matrix* pObject2Device, float font_size, uint32_t color) { - // Do not send zero or negative font sizes to printers. See crbug.com/767343. - if (font_size <= 0.0) - return true; - + // Check object to device matrix first, since it can scale the font size. if ((pObject2Device->a == 0 && pObject2Device->b == 0) || (pObject2Device->c == 0 && pObject2Device->d == 0)) { return true; } + // Do not send near zero font sizes to printers. See crbug.com/767343. + float scale = + std::min(pObject2Device->GetXUnit(), pObject2Device->GetYUnit()); + static constexpr float kEpsilon = 0.01f; + if (std::fabs(font_size * scale) < kEpsilon) + return true; + StartRendering(); int alpha = FXARGB_A(color); if (alpha < 255) -- cgit v1.2.3