mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-25 16:18:52 +01:00
Add clipping for text max width.
This commit is contained in:
parent
9f7290bb12
commit
0725ef60dc
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user