summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine_win.cpp
diff options
context:
space:
mode:
authorTrond Kjernaasen <trond@trolltech.com>2009-06-05 12:32:51 +0200
committerTrond Kjernaasen <trond@trolltech.com>2009-06-05 12:36:29 +0200
commit35bdd8942716c716113e5b795186ca76199e8d96 (patch)
treed3792228bcd9c6c750d47a9d349e357dd5ab5339 /src/gui/text/qfontengine_win.cpp
parent799a9ddf0a53ecdd6e097b2efd7418fd6ab9b655 (diff)
Fixed text drawing on Windows in 16 bit mode.
There were several problems with antialiased text in 16 bit mode under Windows. No gamma correction was done, yet we prepared the cached glyphs for gamma correction. The mask format we rendered the glyphs into was also set to the desktop depth, which implied that information was lost and the text looked rather odd. Reviewed-by: Samuel BT: yes
Diffstat (limited to 'src/gui/text/qfontengine_win.cpp')
-rw-r--r--src/gui/text/qfontengine_win.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index 7341665586..dc2e1ff294 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -1335,7 +1335,7 @@ bool QFontEngineWin::getSfntTableData(uint tag, uchar *buffer, uint *length) con
QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin,
- const QTransform &t)
+ const QTransform &t, QImage::Format mask_format)
{
glyph_metrics_t gm = boundingBox(glyph);
@@ -1408,7 +1408,7 @@ QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin
QNativeImage *ni = new QNativeImage(iw + 2 * margin + 4,
ih + 2 * margin + 4,
- QNativeImage::systemFormat(), true);
+ mask_format, true);
ni->image.fill(0xffffffff);
HDC hdc = ni->hdc;
@@ -1448,8 +1448,12 @@ QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
lf.lfQuality = ANTIALIASED_QUALITY;
font = CreateFontIndirectW(&lf);
}
+ QImage::Format mask_format = QNativeImage::systemFormat();
+#ifndef Q_OS_WINCE
+ mask_format = QImage::Format_RGB32;
+#endif
- QNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform);
+ QNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
if (mask == 0)
return QImage();
@@ -1466,22 +1470,20 @@ QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
// Alpha channel of the ni.image pixels...
for (int y=0; y<mask->height(); ++y) {
uchar *dest = indexed.scanLine(y);
- if (mask->systemFormat() == QImage::Format_RGB16) {
+ if (mask->image.format() == QImage::Format_RGB16) {
const qint16 *src = (qint16 *) ((const QImage &) mask->image).scanLine(y);
- for (int x=0; x<mask->width(); ++x) {
-#ifdef Q_OS_WINCE
+ for (int x=0; x<mask->width(); ++x)
dest[x] = 255 - qGray(src[x]);
-#else
- dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
-#endif
- }
} else {
const uint *src = (uint *) ((const QImage &) mask->image).scanLine(y);
for (int x=0; x<mask->width(); ++x) {
#ifdef Q_OS_WINCE
dest[x] = 255 - qGray(src[x]);
#else
- dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
+ if (QNativeImage::systemFormat() == QImage::Format_RGB16)
+ dest[x] = 255 - qGray(src[x]);
+ else
+ dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
#endif
}
}
@@ -1507,7 +1509,7 @@ QImage QFontEngineWin::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTra
SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0);
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0);
- QNativeImage *mask = drawGDIGlyph(font, glyph, margin, t);
+ QNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32);
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) contrast, 0);
if (mask == 0)