mirror of https://github.com/axmolengine/axmol.git
close #3678:fix incorrect spacing between characters
This commit is contained in:
parent
2b8107d817
commit
db4dc28c1a
|
@ -130,8 +130,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
|
||||||
|
|
||||||
Rect tempRect;
|
Rect tempRect;
|
||||||
|
|
||||||
FontLetterDefinition tempDef;
|
FontLetterDefinition tempDef;
|
||||||
tempDef.offsetX = 0;
|
|
||||||
tempDef.anchorX = 0.0f;
|
tempDef.anchorX = 0.0f;
|
||||||
tempDef.anchorY = 1.0f;
|
tempDef.anchorY = 1.0f;
|
||||||
|
|
||||||
|
@ -143,7 +142,8 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
|
||||||
tempDef.width = 0;
|
tempDef.width = 0;
|
||||||
tempDef.height = 0;
|
tempDef.height = 0;
|
||||||
tempDef.U = 0;
|
tempDef.U = 0;
|
||||||
tempDef.V = 0;
|
tempDef.V = 0;
|
||||||
|
tempDef.offsetX = 0;
|
||||||
tempDef.offsetY = 0;
|
tempDef.offsetY = 0;
|
||||||
tempDef.textureID = 0;
|
tempDef.textureID = 0;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,8 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
|
||||||
tempDef.validDefinition = true;
|
tempDef.validDefinition = true;
|
||||||
tempDef.letteCharUTF16 = utf16String[i];
|
tempDef.letteCharUTF16 = utf16String[i];
|
||||||
tempDef.width = tempRect.size.width + _letterPadding;
|
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.offsetY = tempRect.origin.y;
|
||||||
tempDef.commonLineHeight = _currentPageLineHeight;
|
tempDef.commonLineHeight = _currentPageLineHeight;
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,6 @@ FontAtlas * FontDefinitionTTF::createFontAtlas()
|
||||||
if ( item.second.validDefinition )
|
if ( item.second.validDefinition )
|
||||||
{
|
{
|
||||||
FontLetterDefinition tempDefinition = item.second;
|
FontLetterDefinition tempDefinition = item.second;
|
||||||
tempDefinition.offsetX = 0;
|
|
||||||
tempDefinition.anchorX = 0.0f;
|
tempDefinition.anchorX = 0.0f;
|
||||||
tempDefinition.anchorY = 1.0f;
|
tempDefinition.anchorY = 1.0f;
|
||||||
retAtlas->addLetterDefinition(tempDefinition);
|
retAtlas->addLetterDefinition(tempDefinition);
|
||||||
|
|
|
@ -176,7 +176,7 @@ bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect) const
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// store result in the passed rectangle
|
// 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.origin.y = - (_fontRef->glyph->metrics.horiBearingY >> 6);
|
||||||
outRect.size.width = (_fontRef->glyph->metrics.width >> 6);
|
outRect.size.width = (_fontRef->glyph->metrics.width >> 6);
|
||||||
outRect.size.height = (_fontRef->glyph->metrics.height >> 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 advance = 0;
|
||||||
int kerning = 0;
|
int kerning = 0;
|
||||||
|
|
||||||
advance = getAdvanceForChar(text[c]) - getBearingXForChar(text[c]);
|
advance = getAdvanceForChar(text[c]);
|
||||||
|
|
||||||
if (c < (outNumLetters-1))
|
if (c < (outNumLetters-1))
|
||||||
kerning = getHorizontalKerningForChars(text[c], text[c+1]);
|
kerning = getHorizontalKerningForChars(text[c], text[c+1]);
|
||||||
|
@ -295,7 +295,7 @@ int FontFreeType::getAdvanceForChar(unsigned short theChar) const
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// get to the advance for this glyph
|
// 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
|
int FontFreeType::getBearingXForChar(unsigned short theChar) const
|
||||||
|
|
Loading…
Reference in New Issue