diff options
author | Yoann Lopes <yoann.lopes@digia.com> | 2013-03-18 16:14:20 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-19 15:14:46 +0100 |
commit | 6365f002a9b090c8b76c722eeac2e2fa96d2b722 (patch) | |
tree | de04fe0b4520e7c3203320e3ea846c7d5f5380d3 | |
parent | 8d8f5de4415c796552958abed8c49c3c059c37ed (diff) |
Fixed QTextureGlyphCache glyph padding.
Padding was correctly added between glyphs but it was missing at the
texture edges.
Change-Id: I6d5e1206194f6aecefcfc45ead22d54c1207de4f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 2ffdc9cd59..ed0473749e 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -109,7 +109,8 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const m_current_fontengine = fontEngine; const int margin = m_current_fontengine->glyphMargin(m_type); - const int paddingDoubled = glyphPadding() * 2; + const int padding = glyphPadding(); + const int paddingDoubled = padding * 2; bool supportsSubPixelPositions = fontEngine->supportsSubPixelPositions(); if (fontEngine->m_subPixelPositionCount == 0) { @@ -122,6 +123,11 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const } } + if (m_cx == 0 && m_cy == 0) { + m_cx = padding; + m_cy = padding; + } + QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates; int rowHeight = 0; @@ -202,21 +208,21 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2); - if (m_cx + c.w > requiredWidth) { + if (m_cx + c.w + padding > requiredWidth) { int new_width = requiredWidth*2; - while (new_width < m_cx + c.w) + while (new_width < m_cx + c.w + padding) new_width *= 2; if (new_width <= maxTextureWidth()) { requiredWidth = new_width; } else { // no room on the current line, start new glyph strip - m_cx = 0; + m_cx = padding; m_cy += m_currentRowHeight + paddingDoubled; m_currentRowHeight = c.h + margin * 2; // New row } } - if (maxTextureHeight() > 0 && m_cy + c.h > maxTextureHeight()) { + if (maxTextureHeight() > 0 && m_cy + c.h + padding > maxTextureHeight()) { // We can't make a cache of the required size, so we bail out return false; } |