1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

IGUIFont / CGUITTFont code cleanups (#15581)

This commit is contained in:
sfan5 2024-12-23 12:49:47 +01:00 committed by GitHub
parent 0bfd9bc09e
commit c49ff76955
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 135 additions and 626 deletions

View file

@ -74,10 +74,12 @@ void CGUIStaticText::draw()
IGUIFont *font = getActiveFont();
if (font) {
s32 kerningHeight = font->getKerning(L'A').Y;
if (!WordWrap) {
if (VAlign == EGUIA_LOWERRIGHT) {
frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y -
font->getDimension(L"A").Height - font->getKerningHeight();
font->getDimension(L"A").Height - kerningHeight;
}
if (HAlign == EGUIA_LOWERRIGHT) {
frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X -
@ -92,7 +94,7 @@ void CGUIStaticText::draw()
breakText();
core::rect<s32> r = frameRect;
s32 height = font->getDimension(L"A").Height + font->getKerningHeight();
s32 height = font->getDimension(L"A").Height + kerningHeight;
s32 totalHeight = height * BrokenText.size();
if (VAlign == EGUIA_CENTER) {
r.UpperLeftCorner.Y = r.getCenter().Y - (totalHeight / 2);
@ -471,7 +473,7 @@ s32 CGUIStaticText::getTextHeight() const
return 0;
if (WordWrap) {
s32 height = font->getDimension(L"A").Height + font->getKerningHeight();
s32 height = font->getDimension(L"A").Height + font->getKerning(L'A').Y;
return height * BrokenText.size();
} else {
// TODO: Text can have multiple lines which are not in BrokenText