diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-03-27 08:30:47 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-27 12:33:42 +0200 |
commit | 4f92f9b7251addef556b25e8ab88e00acfaf61b0 (patch) | |
tree | cadb3a0fe7e4c2564e609c3d27d2bc47be516029 /src/plugins/platforms/windows | |
parent | 8d28f263aa14cc450085c9df3623a483b6021c56 (diff) |
Introduce FontSmoothingGamma as a platform style hint.
- Allocate gamma tables on the heap in a thread-safe way, use
font smoothing returned by the style hints of the platform to
calculate them.
- Improve font rendering on Windows.
Change-Id: I8cd39b51cf03cbd642474c02b9076814baecd597
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsfontdatabase.cpp | 28 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsfontdatabase.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsintegration.cpp | 2 |
3 files changed, 20 insertions, 12 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index e0be731b53..7d0bd53e8b 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -68,8 +68,10 @@ QT_BEGIN_NAMESPACE */ QWindowsFontEngineData::QWindowsFontEngineData() + : clearTypeEnabled(false) + , fontSmoothingGamma(QWindowsFontDatabase::fontSmoothingGamma()) #if !defined(QT_NO_DIRECTWRITE) - : directWriteFactory(0) + , directWriteFactory(0) , directWriteGdiInterop(0) #endif { @@ -78,17 +80,6 @@ QWindowsFontEngineData::QWindowsFontEngineData() if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0)) clearTypeEnabled = (result == FE_FONTSMOOTHINGCLEARTYPE); - int winSmooth; - if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) { - fontSmoothingGamma = winSmooth / qreal(1000.0); - } else { - fontSmoothingGamma = 1.0; - } - - // Safeguard ourselves against corrupt registry values... - if (fontSmoothingGamma > 5 || fontSmoothingGamma < 1) - fontSmoothingGamma = qreal(1.4); - const qreal gray_gamma = 2.31; for (int i=0; i<256; ++i) pow_gamma[i] = uint(qRound(qPow(i / qreal(255.), gray_gamma) * 2047)); @@ -110,6 +101,19 @@ QWindowsFontEngineData::~QWindowsFontEngineData() #endif } +qreal QWindowsFontDatabase::fontSmoothingGamma() +{ + int winSmooth; + qreal result = 1; + if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) + result = qreal(winSmooth) / qreal(1000.0); + + // Safeguard ourselves against corrupt registry values... + if (result > 5 || result < 1) + result = qreal(1.4); + return result; +} + #if !defined(QT_NO_DIRECTWRITE) static inline bool initDirectWrite(QWindowsFontEngineData *d) { diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h index f8f2a1eb85..774a203a55 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h @@ -96,6 +96,8 @@ public: static HFONT systemFont(); static QFont LOGFONT_to_QFont(const LOGFONT& lf, int verticalDPI = 0); + static qreal fontSmoothingGamma(); + private: void populate(const QString &family = QString()); QSharedPointer<QWindowsFontEngineData> m_fontEngineData; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index ee58a19ca9..fa63d77dd7 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -317,6 +317,8 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co case QPlatformIntegration::KeyboardInputInterval: case QPlatformIntegration::ShowIsFullScreen: break; // Not implemented + case QPlatformIntegration::FontSmoothingGamma: + return QVariant(QWindowsFontDatabase::fontSmoothingGamma()); } return QPlatformIntegration::styleHint(hint); } |