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>
This commit is contained in:
parent
8d8f5de441
commit
6365f002a9
@ -109,7 +109,8 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
|
|||||||
|
|
||||||
m_current_fontengine = fontEngine;
|
m_current_fontengine = fontEngine;
|
||||||
const int margin = m_current_fontengine->glyphMargin(m_type);
|
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();
|
bool supportsSubPixelPositions = fontEngine->supportsSubPixelPositions();
|
||||||
if (fontEngine->m_subPixelPositionCount == 0) {
|
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;
|
QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates;
|
||||||
int rowHeight = 0;
|
int rowHeight = 0;
|
||||||
|
|
||||||
@ -202,21 +208,21 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
|
|||||||
|
|
||||||
m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2);
|
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;
|
int new_width = requiredWidth*2;
|
||||||
while (new_width < m_cx + c.w)
|
while (new_width < m_cx + c.w + padding)
|
||||||
new_width *= 2;
|
new_width *= 2;
|
||||||
if (new_width <= maxTextureWidth()) {
|
if (new_width <= maxTextureWidth()) {
|
||||||
requiredWidth = new_width;
|
requiredWidth = new_width;
|
||||||
} else {
|
} else {
|
||||||
// no room on the current line, start new glyph strip
|
// no room on the current line, start new glyph strip
|
||||||
m_cx = 0;
|
m_cx = padding;
|
||||||
m_cy += m_currentRowHeight + paddingDoubled;
|
m_cy += m_currentRowHeight + paddingDoubled;
|
||||||
m_currentRowHeight = c.h + margin * 2; // New row
|
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
|
// We can't make a cache of the required size, so we bail out
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user