summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
authorrbpotter <rbpotter@chromium.org>2018-02-14 01:35:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-14 01:35:53 +0000
commit2f68cb53f5938e2dd572db79fc5689c987cb350d (patch)
tree2846fce152b286c24eac8474f1fc949fc0125166 /core/fxge
parentdab8649b70284a3f0e109510996c35c7882cbd87 (diff)
downloadpdfium-2f68cb53f5938e2dd572db79fc5689c987cb350d.tar.xz
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 <thestig@chromium.org> Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Diffstat (limited to 'core/fxge')
-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 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 <algorithm>
#include <memory>
#include <sstream>
@@ -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)