From 70dde9c60e2ed9f8b9a15bc5c656fda972e69d97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 25 Mar 2011 18:06:33 +0100 Subject: Fixed underline offset after raster coordinate system change. This avoids the double-thickness lines at low point sizes which were caused by a line just barely straddling two pixels. Re-applying eeca1aee72a69584aa20bdb9f5c4e48d7e3cbc16. Reviewed-by: Jens Bache-Wiig --- src/gui/painting/qpainter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 64ef549..50d65e6 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6468,7 +6468,8 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const const qreal underlineOffset = fe->underlinePosition().toReal(); // deliberately ceil the offset to avoid the underline coming too close to // the text above it. - const qreal underlinePos = pos.y() + qCeil(underlineOffset); + const qreal aliasedCoordinateDelta = 0.5 - 0.015625; + const qreal underlinePos = pos.y() + qCeil(underlineOffset) - aliasedCoordinateDelta; if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle)); -- cgit v0.12 From bf03b38d2b32a0cfca181398597884e4252466f4 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 1 Apr 2011 13:51:06 +0200 Subject: Make sure we don't use subpixel positions in full hinting mode Some of the text can start from subpixel positions (start from 100.5 for instance), we need to make sure they stick to pixel grid in this case. Reviewed-by: Eskil --- src/gui/painting/qpaintengine_raster.cpp | 7 +------ src/gui/painting/qtextureglyphcache.cpp | 2 +- src/gui/text/qfontengine_ft.cpp | 2 ++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9f3b9b9..6902543 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3191,15 +3191,10 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, rightShift = 3; // divide by 8 int margin = cache->glyphMargin(); - - bool supportsSubPixelPositions = fontEngine->supportsSubPixelPositions(); - const uchar *bits = image.bits(); for (int i=0; isubPixelPositionForX(positions[i].x); + QFixed subPixelPosition = cache->subPixelPositionForX(positions[i].x); QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphs[i], subPixelPosition); const QTextureGlyphCache::Coord &c = cache->coords[glyph]; if (c.isNull()) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index f0db805..727852d 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -102,7 +102,7 @@ int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const QFixed QTextureGlyphCache::subPixelPositionForX(QFixed x) const { - if (m_subPixelPositionCount == 0) + if (m_subPixelPositionCount <= 1) return QFixed(); QFixed subPixelPosition; diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index db0156a..08eb6bb 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1430,6 +1430,8 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor QFixed QFontEngineFT::subPixelPositionForX(QFixed x) { int m_subPixelPositionCount = 4; + if (!supportsSubPixelPositions()) + return 0; QFixed subPixelPosition; if (x != 0) { -- cgit v0.12