summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-15 23:37:17 +0000
committerLei Zhang <thestig@chromium.org>2018-02-15 23:37:17 +0000
commit6d69dfca14621c907ca9d6c6bd3d3a5d4428e85b (patch)
tree8c850c9d906c2dfb9b5195bee7a1176758190006
parentad3e2461b811a70c433e9f62c75f8ddb1d1253ab (diff)
downloadpdfium-6d69dfca14621c907ca9d6c6bd3d3a5d4428e85b.tar.xz
M65: Allow negative font sizes for PostScript printing
Bug: chromium:806746 TBR: rbpotter@chromium.org Change-Id: I0b642c457c55d828dd48988eadfc5fa964de1216 Reviewed-on: https://pdfium-review.googlesource.com/26630 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Rebekah Potter <rbpotter@chromium.org> (cherry picked from commit 2f68cb53f5938e2dd572db79fc5689c987cb350d) Reviewed-on: https://pdfium-review.googlesource.com/26992
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 1513c07c68..1e79669225 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 <algorithm>
#include <memory>
#include <sstream>
@@ -644,15 +645,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)