diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-23 17:35:47 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-24 14:56:56 (GMT) |
commit | 47ce3672058d4cc6ca479f8b40d6cb821c38dd51 (patch) | |
tree | abb1c34a72e5f1cdc0206f87b23ac38c8fe85321 /src/gui/text/qfontengine_ft.cpp | |
parent | dcdc7eccf7ff32396816059dc932c358f73cf12b (diff) | |
download | Qt-47ce3672058d4cc6ca479f8b40d6cb821c38dd51.zip Qt-47ce3672058d4cc6ca479f8b40d6cb821c38dd51.tar.gz Qt-47ce3672058d4cc6ca479f8b40d6cb821c38dd51.tar.bz2 |
Fixed remaining issues in subpixel positioning with FreeType
1. Merge QStaticText and QGlyphs drawing code of raster engine
into glyph drawing code for normal QTextItem, it simplify
the caching system (we don't use QImageTextureGlyphCache for
raster anymore, just glyph set cache in FreeType engine is
enough), and fix some regressions in QStaticText and QGlyphs
drawing.
2. Fix subpixel positioning support for OpenGL texture glyph
cache. Including a transform handling regression introduced
by the initial patch.
3. Disable subpixel positioning for bitmap fonts (mono format).
After this change, we only have two code paths for glyph rendering
with FreeType: raster will always use the simple code path (with
QFontEngine_FT cache) while GL will always use QTextureGlyphCache.
Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text/qfontengine_ft.cpp')
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index e90a12f..6c6781c 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -944,7 +944,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, FT_Face face = freetype->face; FT_Vector v; - v.x = FT_Pos((subPixelPosition).toReal() * 64); + v.x = format == Format_Mono ? 0 : FT_Pos(subPixelPosition.toReal() * 64); v.y = 0; FT_Set_Transform(face, &freetype->matrix, &v); @@ -1049,7 +1049,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, int hpixels = TRUNC(right - left); // subpixel position requires one more pixel - if (subPixelPosition > 0) + if (subPixelPosition > 0 && format != Format_Mono) hpixels++; if (hsubpixel) @@ -1440,8 +1440,8 @@ QFixed QFontEngineFT::subPixelPositionForX(QFixed x) return subPixelPosition; } -bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, - QVarLengthArray<QFixedPoint> &positions, +bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, const glyph_t *glyphs, int num_glyphs, + const QFixedPoint *positions, GlyphFormat format) { FT_Face face = 0; @@ -1866,16 +1866,16 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, const QTransfo return overall; } -QImage QFontEngineFT::alphaMapForGlyph(glyph_t g) +QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition) { lockFace(); GlyphFormat glyph_format = antialias ? Format_A8 : Format_Mono; - Glyph *glyph = defaultGlyphSet.outline_drawing ? 0 : loadGlyph(g, 0, glyph_format); + Glyph *glyph = defaultGlyphSet.outline_drawing ? 0 : loadGlyph(g, subPixelPosition, glyph_format); if (!glyph) { unlockFace(); - return QFontEngine::alphaMapForGlyph(g); + return QFontEngine::alphaMapForGlyph(g, subPixelPosition); } const int pitch = antialias ? (glyph->width + 3) & ~3 : ((glyph->width + 31)/32) * 4; |