diff options
author | axis <qt-info@nokia.com> | 2009-05-11 08:30:34 +0200 |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-05-11 08:30:34 +0200 |
commit | 804a0ff4ad8c27ece2d403b8d9a4f6f65cdcf867 (patch) | |
tree | 0258fb5f685ccaa710f8ea8ec9da9b6aa9f91d35 /src/gui/text/qfontengine.cpp | |
parent | efb3e7288eec748db11c35de87239a1eff4d457c (diff) | |
parent | 842ba1b3878c2973b24936b18a7ee55bdd980be6 (diff) | |
download | qt4-tools-804a0ff4ad8c27ece2d403b8d9a4f6f65cdcf867.tar.gz |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
tests/auto/qtemporaryfile/qtemporaryfile.pro
Diffstat (limited to 'src/gui/text/qfontengine.cpp')
-rw-r--r-- | src/gui/text/qfontengine.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 5a8977d045..c2c23eed60 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -624,6 +624,45 @@ QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int /* margin */, const Q return rgbMask; } +QImage QFontEngine::alphaMapForGlyph(glyph_t glyph) +{ + glyph_metrics_t gm = boundingBox(glyph); + int glyph_x = qFloor(gm.x.toReal()); + int glyph_y = qFloor(gm.y.toReal()); + int glyph_width = qCeil((gm.x + gm.width).toReal()) - glyph_x; + int glyph_height = qCeil((gm.y + gm.height).toReal()) - glyph_y; + + if (glyph_width <= 0 || glyph_height <= 0) + return QImage(); + QFixedPoint pt; + pt.x = 0; + pt.y = -glyph_y; // the baseline + QPainterPath path; + QImage im(glyph_width + qAbs(glyph_x) + 4, glyph_height, QImage::Format_ARGB32_Premultiplied); + im.fill(Qt::transparent); + QPainter p(&im); + p.setRenderHint(QPainter::Antialiasing); + addGlyphsToPath(&glyph, &pt, 1, &path, 0); + p.setPen(Qt::NoPen); + p.setBrush(Qt::black); + p.drawPath(path); + p.end(); + + QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); + QVector<QRgb> colors(256); + for (int i=0; i<256; ++i) + colors[i] = qRgba(0, 0, 0, i); + indexed.setColorTable(colors); + + for (int y=0; y<im.height(); ++y) { + uchar *dst = (uchar *) indexed.scanLine(y); + uint *src = (uint *) im.scanLine(y); + for (int x=0; x<im.width(); ++x) + dst[x] = qAlpha(src[x]); + } + + return indexed; +} void QFontEngine::removeGlyphFromCache(glyph_t) { |