mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-03-02 06:47:03 +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;
|
Font::GlyphInfo glyph;
|
||||||
if(FontInst->GetRect(TextData[i], glyph))
|
if(FontInst->GetRect(TextData[i], glyph))
|
||||||
{
|
{
|
||||||
imageWidth += glyph.Advance;
|
imageWidth += glyph.Advance;
|
||||||
imageHeight = (imageHeight >= glyph.Rect.h) ? imageHeight : glyph.Rect.h;
|
imageHeight = (imageHeight >= glyph.Rect.h) ? imageHeight : glyph.Rect.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float scale = (float)info->GetFontSize() / (float)imageHeight;
|
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());
|
SDL::RenderCopy(t, static_cast<char>(info->GetAlpha() * 255), &charRect, &rect, info->GetAngle());
|
||||||
rect.x += static_cast<int>(glyph.Advance * scale);
|
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