Merge pull request #5105 from Dhilan007/develop_label

close #3678:fix incorrect spacing between characters
This commit is contained in:
James Chen 2014-01-16 23:18:44 -08:00
commit 0a6316a2f3
3 changed files with 8 additions and 8 deletions

View File

@ -130,8 +130,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
Rect tempRect;
FontLetterDefinition tempDef;
tempDef.offsetX = 0;
FontLetterDefinition tempDef;
tempDef.anchorX = 0.0f;
tempDef.anchorY = 1.0f;
@ -143,7 +142,8 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
tempDef.width = 0;
tempDef.height = 0;
tempDef.U = 0;
tempDef.V = 0;
tempDef.V = 0;
tempDef.offsetX = 0;
tempDef.offsetY = 0;
tempDef.textureID = 0;
}
@ -152,7 +152,8 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
tempDef.validDefinition = true;
tempDef.letteCharUTF16 = utf16String[i];
tempDef.width = tempRect.size.width + _letterPadding;
tempDef.height = _currentPageLineHeight - 1;
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