fix rendering of quotes

This commit is contained in:
Eduardo Bart 2012-04-25 22:58:36 -03:00
parent 12d75a765b
commit 243bd3a930
1 changed files with 6 additions and 15 deletions

View File

@ -261,28 +261,19 @@ void Font::calculateGlyphsWidthsAutomatically(const ImagePtr& image, const Size&
glyphSize.width(), glyphSize.width(),
m_glyphHeight); m_glyphHeight);
int width = glyphSize.width(); int width = glyphSize.width();
int lastColumnFilledPixels = 0;
bool foundAnything = false;
for(int x = glyphCoords.left(); x <= glyphCoords.right(); ++x) { for(int x = glyphCoords.left(); x <= glyphCoords.right(); ++x) {
int columnFilledPixels = 0; int filledPixels = 0;
// check if all vertical pixels are alpha // check if all vertical pixels are alpha
for(int y = glyphCoords.top(); y <= glyphCoords.bottom(); ++y) { for(int y = glyphCoords.top(); y <= glyphCoords.bottom(); ++y) {
if(texturePixels[(y * image->getSize().width() * 4) + (x*4) + 3] != 0) { if(texturePixels[(y * image->getSize().width() * 4) + (x*4) + 3] != 0)
columnFilledPixels++; filledPixels++;
foundAnything = true;
}
} }
if(filledPixels > 0) {
// if all pixels were alpha we found the width width = x - glyphCoords.left() + 1;
if(columnFilledPixels == 0 && foundAnything) {
width = x - glyphCoords.left();
width += m_glyphSpacing.width(); width += m_glyphSpacing.width();
if(m_glyphHeight >= 16 && lastColumnFilledPixels >= m_glyphHeight/3) if(m_glyphHeight >= 16 && filledPixels >= m_glyphHeight/3)
width += 1; width += 1;
break;
} }
lastColumnFilledPixels = columnFilledPixels;
} }
// store glyph size // store glyph size
m_glyphsSize[glyph].resize(width, m_glyphHeight); m_glyphsSize[glyph].resize(width, m_glyphHeight);