(Font) Added spaceAdvance SizeInfo

Former-commit-id: 2767915c2554103615918347c6e742cb324092c5
This commit is contained in:
Lynix 2015-01-16 12:42:27 +01:00
parent 1781e93462
commit 9d83f3f474
2 changed files with 10 additions and 0 deletions

View File

@ -98,6 +98,7 @@ class NAZARA_API NzFont : public NzResource, NzAbstractAtlas::Listener, NzNonCop
struct SizeInfo
{
int spaceAdvance;
unsigned int lineHeight;
float underlinePosition;
float underlineThickness;

View File

@ -202,6 +202,15 @@ const NzFont::SizeInfo& NzFont::GetSizeInfo(unsigned int characterSize) const
sizeInfo.underlinePosition = m_data->QueryUnderlinePosition(characterSize);
sizeInfo.underlineThickness = m_data->QueryUnderlineThickness(characterSize);
NzFontGlyph glyph;
if (m_data->ExtractGlyph(characterSize, ' ', nzTextStyle_None, &glyph))
sizeInfo.spaceAdvance = glyph.advance;
else
{
NazaraWarning("Failed to extract space character from font, using half the size");
sizeInfo.spaceAdvance = characterSize/2;
}
it = m_sizeInfoCache.insert(std::make_pair(characterSize, sizeInfo)).first;
}