close #3678:fix incorrect spacing between characters

This commit is contained in:
Dhilan007 2014-01-17 14:04:52 +08:00
parent 2b8107d817
commit db4dc28c1a
3 changed files with 8 additions and 8 deletions

View File

@ -131,7 +131,6 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
Rect tempRect;
FontLetterDefinition tempDef;
tempDef.offsetX = 0;
tempDef.anchorX = 0.0f;
tempDef.anchorY = 1.0f;
@ -144,6 +143,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
tempDef.height = 0;
tempDef.U = 0;
tempDef.V = 0;
tempDef.offsetX = 0;
tempDef.offsetY = 0;
tempDef.textureID = 0;
}
@ -153,6 +153,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
tempDef.letteCharUTF16 = utf16String[i];
tempDef.width = tempRect.size.width + _letterPadding;
tempDef.height = _currentPageLineHeight - 1;
tempDef.offsetX = tempRect.origin.x;
tempDef.offsetY = tempRect.origin.y;
tempDef.commonLineHeight = _currentPageLineHeight;

View File

@ -222,7 +222,6 @@ FontAtlas * FontDefinitionTTF::createFontAtlas()
if ( item.second.validDefinition )
{
FontLetterDefinition tempDefinition = item.second;
tempDefinition.offsetX = 0;
tempDefinition.anchorX = 0.0f;
tempDefinition.anchorY = 1.0f;
retAtlas->addLetterDefinition(tempDefinition);

View File

@ -176,7 +176,7 @@ bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect) const
return false;
// store result in the passed rectangle
outRect.origin.x = 0;
outRect.origin.x = _fontRef->glyph->metrics.horiBearingX >> 6;
outRect.origin.y = - (_fontRef->glyph->metrics.horiBearingY >> 6);
outRect.size.width = (_fontRef->glyph->metrics.width >> 6);
outRect.size.height = (_fontRef->glyph->metrics.height >> 6);
@ -268,7 +268,7 @@ Size * FontFreeType::getAdvancesForTextUTF16(unsigned short *text, int &outNumLe
int advance = 0;
int kerning = 0;
advance = getAdvanceForChar(text[c]) - getBearingXForChar(text[c]);
advance = getAdvanceForChar(text[c]);
if (c < (outNumLetters-1))
kerning = getHorizontalKerningForChars(text[c], text[c+1]);
@ -295,7 +295,7 @@ int FontFreeType::getAdvanceForChar(unsigned short theChar) const
return 0;
// get to the advance for this glyph
return (static_cast<int>(_fontRef->glyph->advance.x >> 6));
return (static_cast<int>(_fontRef->glyph->metrics.horiAdvance >> 6));
}
int FontFreeType::getBearingXForChar(unsigned short theChar) const