fix rendering of quotes

master
Eduardo Bart 12 years ago
parent 12d75a765b
commit 243bd3a930

@ -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);

Loading…
Cancel
Save