diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-09-07 11:57:07 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-09-09 15:12:04 (GMT) |
commit | b7ef9d49a969f512ecbc7ad940642f3a74e348ad (patch) | |
tree | a73e4b3fd5a8ffd6b2055f83618f56dfd6ef129a /src/gui/text/qfontengine_mac.mm | |
parent | de1b1cd7a6a15755bd5f049533791554c933686c (diff) | |
download | Qt-b7ef9d49a969f512ecbc7ad940642f3a74e348ad.zip Qt-b7ef9d49a969f512ecbc7ad940642f3a74e348ad.tar.gz Qt-b7ef9d49a969f512ecbc7ad940642f3a74e348ad.tar.bz2 |
Support sub pixel positioning of glyphs in raster engine
For the raster engine to provide the same quality of text rendering
as the native engine on Mac Cocoa, we need to support rendering to
different sub pixel positions for each glyph. The number of
subpixel positions is arbitrary and has to be detected, but it's
usually three or four.
Each position will give slightly different coverages inside the
pixel and thus different rasterizations. Other font engines which
support sub pixel positioning of glyphs can provide the same
functionality by implementing supportsSubPixelPositions() to return
true, and then adding the subPixelPosition argument to the x
coordinate used in alphaRGBMapForGlyph().
Task-number: QTBUG-5053
Reviewed-by: Jiang Jiang
Diffstat (limited to 'src/gui/text/qfontengine_mac.mm')
-rw-r--r-- | src/gui/text/qfontengine_mac.mm | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 2bbf9f2..1ca6ec3 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -663,7 +663,7 @@ QFont QCoreTextFontEngine::createExplicitFont() const return createExplicitFontWithName(familyName); } -QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, int margin, bool aa) +QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition, int /*margin*/, bool aa) { const glyph_metrics_t br = boundingBox(glyph); QImage im(qRound(br.width)+2, qRound(br.height)+2, QImage::Format_RGB32); @@ -700,7 +700,8 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, int margin, bool aa) QCFType<CGFontRef> cgFont = CGFontCreateWithPlatformFont(&atsfont); CGContextSetFont(ctx, cgFont); - qreal pos_x = -br.x.toReal()+1, pos_y = im.height()+br.y.toReal(); + qreal pos_x = -br.x.toReal() + subPixelPosition.toReal(); + qreal pos_y = im.height()+br.y.toReal(); CGContextSetTextPosition(ctx, pos_x, pos_y); CGSize advance; @@ -721,7 +722,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, int margin, bool aa) QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph) { - QImage im = imageForGlyph(glyph, 0, false); + QImage im = imageForGlyph(glyph, QFixed(), 0, false); QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); QVector<QRgb> colors(256); @@ -742,12 +743,12 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph) return indexed; } -QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &x) +QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, const QTransform &x) { if (x.type() >= QTransform::TxScale) - return QFontEngine::alphaRGBMapForGlyph(glyph, margin, x); + return QFontEngine::alphaRGBMapForGlyph(glyph, subPixelPosition, margin, x); - QImage im = imageForGlyph(glyph, margin, true); + QImage im = imageForGlyph(glyph, subPixelPosition, margin, true); qmacfontengine_gamma_correct(&im); return im; } @@ -1706,7 +1707,7 @@ QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph) return indexed; } -QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &t) +QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, QFixed, int margin, const QTransform &t) { QImage im = imageForGlyph(glyph, margin, true); |