From a4478b28966c5f630ba3d93b97bc91a3cec2fdbe Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 4 Jul 2013 10:34:16 +0200 Subject: REG: Fix character size when exporting PDF on Windows In Qt 4, there was a special case in qpdf.cpp which would use the tmHeight from TEXTMETRIC to calculate the height of the text instead of the pixel size. This was removed when all code inside Q_WS_WIN was removed from QtGui. The tmHeight is defined to be the same as ascent + descent, so we reinsert this code for Windows. It could be that this code is okay cross-platform, since the font height and the pixel size are supposed to be the same, though for some reason not on Windows. However, the safer approach is to #ifdef it for Windows, since the bug is not present on other platforms, and since it was #ifdef'd in Qt 4. Task-number: QTBUG-30875 Change-Id: If0817768bf0ca5ce216842119422a0be944df0bf Reviewed-by: Konstantin Ritt Reviewed-by: Lars Knoll --- src/gui/painting/qpdf.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gui/painting/qpdf.cpp') diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 345ebefea7..1ca54f0432 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -2518,6 +2518,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 glyphs; QVarLengthArray positions; QTransform m = QTransform::fromTranslate(p.x(), p.y()); -- cgit v1.2.3