Add clipping for text max width.

This commit is contained in:
Don Honerbrink 2015-02-10 14:58:31 -06:00
parent 9f7290bb12
commit 0725ef60dc

View File

@ -66,10 +66,11 @@ void Text::Draw()
{
Font::GlyphInfo glyph;
if(FontInst->GetRect(TextData[i], glyph))
{
imageWidth += glyph.Advance;
imageHeight = (imageHeight >= glyph.Rect.h) ? imageHeight : glyph.Rect.h;
{
imageWidth += glyph.Advance;
imageHeight = (imageHeight >= glyph.Rect.h) ? imageHeight : glyph.Rect.h;
}
}
float scale = (float)info->GetFontSize() / (float)imageHeight;
@ -106,6 +107,11 @@ void Text::Draw()
SDL::RenderCopy(t, static_cast<char>(info->GetAlpha() * 255), &charRect, &rect, info->GetAngle());
rect.x += static_cast<int>(glyph.Advance * scale);
if(static_cast<float>(rect.x) - xOrigin) > info->getMaxWidth())
{
break;
}
}
}
}