diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-05-14 16:57:15 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-15 14:34:04 +0200 |
commit | 8b4bf5f81634aa113029ac72721ebd9143c9ed80 (patch) | |
tree | 8eedef4172b08af5b6be651298aae1629188d167 /src/plugins/platforms/windows | |
parent | c241d8921ea6384c30a1731a036aec8edc7609ab (diff) |
Fix font printing on Windows using the native engine.
- Add HFONT, LOGFONT, trueType as properties of the
Windows font engine, make it a real Q_OBJECT.
- Query properties in the Windows print engine and use the HFONT,
LOGFONT there.
Change-Id: I5c35275b32ef6580d7fa15ed83c6e79e33dc3334
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsfontdatabase.cpp | 6 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsfontengine.cpp | 4 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsfontengine.h | 21 |
3 files changed, 25 insertions, 6 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 7e8c70ee44..814a6a930b 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -1115,6 +1115,12 @@ void QWindowsFontDatabase::populate(const QString &family) QWindowsFontDatabase::QWindowsFontDatabase() : m_fontEngineData(new QWindowsFontEngineData) { + // Properties accessed by QWin32PrintEngine (QtPrintSupport) + static const int hfontMetaTypeId = qRegisterMetaType<HFONT>(); + static const int logFontMetaTypeId = qRegisterMetaType<LOGFONT>(); + Q_UNUSED(hfontMetaTypeId) + Q_UNUSED(logFontMetaTypeId) + if (QWindowsContext::verboseFonts) qDebug() << __FUNCTION__ << "Clear type: " << m_fontEngineData->clearTypeEnabled << "gamma: " diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 801dba2e79..d8a18655bb 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -283,7 +283,7 @@ int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLa QWindowsFontEngine::QWindowsFontEngine(const QString &name, HFONT _hfont, bool stockFontIn, LOGFONT lf, - QSharedPointer<QWindowsFontEngineData> fontEngineData) : + const QSharedPointer<QWindowsFontEngineData> &fontEngineData) : m_fontEngineData(fontEngineData), _name(name), hfont(_hfont), @@ -1318,7 +1318,7 @@ void QWindowsMultiFontEngine::loadEngine(int at) const QString fam = fallbacks.at(at-1); QWindowsFontEngine *fe = static_cast<QWindowsFontEngine*>(engines.at(0)); - LOGFONT lf = fe->logfont(); + LOGFONT lf = fe->logFont(); memcpy(lf.lfFaceName, fam.utf16(), sizeof(wchar_t) * qMin(fam.length() + 1, 32)); // 32 = Windows hard-coded HFONT hfont = CreateFontIndirect(&lf); diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h index c869095769..b4c4463e51 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.h +++ b/src/plugins/platforms/windows/qwindowsfontengine.h @@ -57,6 +57,7 @@ #include <QtGui/QImage> #include <QtCore/QSharedPointer> +#include <QtCore/QMetaType> #include "qtwindows_additional.h" @@ -67,10 +68,14 @@ class QWindowsFontEngineData; class QWindowsFontEngine : public QFontEngine { - Q_DISABLE_COPY(QWindowsFontEngine) + Q_OBJECT + Q_PROPERTY(HFONT hFont READ hFont STORED false) + Q_PROPERTY(LOGFONT logFont READ logFont STORED false) + Q_PROPERTY(bool trueType READ trueType STORED false) + public: QWindowsFontEngine(const QString &name, HFONT, bool, LOGFONT, - QSharedPointer<QWindowsFontEngineData> fontEngineData); + const QSharedPointer<QWindowsFontEngineData> &fontEngineData); ~QWindowsFontEngine(); void initFontInfo(const QFontDef &request, @@ -128,8 +133,13 @@ public: bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const; - QSharedPointer<QWindowsFontEngineData> fontEngineData() const { return m_fontEngineData; } - LOGFONT logfont() const { return m_logfont; } + const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; } + + // Properties accessed by QWin32PrintEngine (QtPrintSupport) + LOGFONT logFont() const { return m_logfont; } + HFONT hFont() const { return hfont; } + bool trueType() const { return ttf; } + void setUniqueFamilyName(const QString &newName) { uniqueFamilyName = newName; } private: @@ -176,5 +186,8 @@ public: QT_END_NAMESPACE +Q_DECLARE_METATYPE(HFONT) +Q_DECLARE_METATYPE(LOGFONT) + #endif // QWINDOWSFONTENGINE_H |