summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpdf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qpdf.cpp')
-rw-r--r--src/gui/painting/qpdf.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 345ebefea7..9105e8b396 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1469,7 +1469,12 @@ int QPdfEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const
return val;
}
+static inline QSizeF pageSizeToPostScriptPoints(const QSizeF &pageSizeMM)
+{
#define Q_MM(n) int((n * 720 + 127) / 254)
+ return QSizeF(Q_MM(pageSizeMM.width()), Q_MM(pageSizeMM.height()));
+#undef Q_MM
+}
QPdfEnginePrivate::QPdfEnginePrivate()
: clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false),
@@ -1477,7 +1482,7 @@ QPdfEnginePrivate::QPdfEnginePrivate()
fullPage(false), embedFonts(true),
landscape(false),
grayscale(false),
- paperSize(Q_MM(210), Q_MM(297)), // A4
+ paperSize(pageSizeToPostScriptPoints(QSizeF(210, 297))), // A4
leftMargin(10), topMargin(10), rightMargin(10), bottomMargin(10) // ~3.5 mm
{
resolution = 1200;
@@ -1491,6 +1496,11 @@ QPdfEnginePrivate::QPdfEnginePrivate()
stream = new QDataStream;
}
+void QPdfEnginePrivate::setPaperSize(const QSizeF &pageSizeMM)
+{
+ paperSize = pageSizeToPostScriptPoints(pageSizeMM);
+}
+
bool QPdfEngine::begin(QPaintDevice *pdev)
{
Q_D(QPdfEngine);
@@ -2518,6 +2528,10 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti)
qreal size = ti.fontEngine->fontDef.pixelSize;
+#if defined(Q_OS_WIN)
+ size = (ti.fontEngine->ascent() + ti.fontEngine->descent()).toReal();
+#endif
+
QVarLengthArray<glyph_t> glyphs;
QVarLengthArray<QFixedPoint> positions;
QTransform m = QTransform::fromTranslate(p.x(), p.y());