summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-04-11 09:35:52 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-04-11 08:01:44 +0000
commit17fc188aec5806167d3c6165b0ad299a8d2a6bcf (patch)
tree99fab3aeed47d6856b6cc343f96a40ebcd2dfafa
parentda1be671cf4081fe41ed886113d6b50723df17d4 (diff)
Implement maxCharWidth() for DirectWrite engine
This is used to create the bounding box in QFontEngine::properties(), which in turn is used for the FontBBox when generating PDFs. The result was that the bounding width in the output was 0 and Adobe Reader complained that the PDF was malformed. We could implement the proper bounding rect in properties() at some point, instead of assuming an origin at x = 0 for instance. The metrics for that are in the head table. But for silencing the warning in Reader, just implementing the maxCharWidth() function is sufficient. [ChangeLog][Windows][PDF] Fixed a bug in PDF output when using high-dpi scaling which was causing the display of warnings when opening the file in Adobe Reader. Task-number: QTBUG-58954 Change-Id: I2540571863d4dd0f85af533b591f75dad3f0d75b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp12
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h1
2 files changed, 11 insertions, 2 deletions
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
index 683b7f65ad..6f2755a05a 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
@@ -355,6 +355,13 @@ void QWindowsFontEngineDirectWrite::collectMetrics()
m_faceId.filename = QFile::encodeName(filenameFromFontFile(fontFile));
fontFile->Release();
}
+
+ QByteArray table = getSfntTable(MAKE_TAG('h', 'h', 'e', 'a'));
+ const int advanceWidthMaxLocation = 10;
+ if (table.size() >= advanceWidthMaxLocation + sizeof(quint16)) {
+ quint16 advanceWidthMax = qFromBigEndian<quint16>(table.constData() + advanceWidthMaxLocation);
+ m_maxAdvanceWidth = DESIGN_TO_LOGICAL(advanceWidthMax);
+ }
}
QFixed QWindowsFontEngineDirectWrite::underlinePosition() const
@@ -607,8 +614,9 @@ QFixed QWindowsFontEngineDirectWrite::xHeight() const
qreal QWindowsFontEngineDirectWrite::maxCharWidth() const
{
- // ###
- return 0;
+ return fontDef.styleStrategy & QFont::ForceIntegerMetrics
+ ? m_maxAdvanceWidth.round().toReal()
+ : m_maxAdvanceWidth.toReal();
}
QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h
index 65b16b9ba7..db4e79e44f 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h
@@ -143,6 +143,7 @@ private:
QFixed m_descent;
QFixed m_xHeight;
QFixed m_lineGap;
+ QFixed m_maxAdvanceWidth;
FaceId m_faceId;
QString m_uniqueFamilyName;
};