From 6365f002a9b090c8b76c722eeac2e2fa96d2b722 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 18 Mar 2013 16:14:20 +0100 Subject: 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 --- src/gui/painting/qtextureglyphcache.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/gui/painting/qtextureglyphcache.cpp') 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 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; } -- cgit v1.2.3