summaryrefslogtreecommitdiff
path: root/src/gui/widgets/browserbox.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-07-10 13:44:10 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-07-15 11:40:25 +0200
commitf83b1d648fc6ec2c64fd2c3483fede23c973c20f (patch)
tree04dd7950cbea1331870190d1caf9061011dfca05 /src/gui/widgets/browserbox.cpp
parent32bcf41f01d4ed4a3a08030095611e75d6186d60 (diff)
downloadmana-f83b1d648fc6ec2c64fd2c3483fede23c973c20f.tar.gz
mana-f83b1d648fc6ec2c64fd2c3483fede23c973c20f.tar.bz2
mana-f83b1d648fc6ec2c64fd2c3483fede23c973c20f.tar.xz
mana-f83b1d648fc6ec2c64fd2c3483fede23c973c20f.zip
Render font outlines using TTF_SetFontOutlineHEADmaster
Rather than rendering the same texture 4 additional times, render a specific outline version of the text. While reducing the number of times the text is drawn, it does increase font texture use. Result is a generally prettier outline due to rendering it properly at sharp corners of the characters. The shadow for outlined text is now also thicker, as appropriate. As part of this change, the `TextRenderer` class was merged into the `Graphics` and `TrueTypeFont` classes. There seemed to be little point in having a separate function for this, apart from needing more static casts to `Graphics*`. Also fixed an issue where the font style was not being restored after adjusting the font scale, when using an older SDL_ttf than 2.0.18. Closes #87
Diffstat (limited to 'src/gui/widgets/browserbox.cpp')
-rw-r--r--src/gui/widgets/browserbox.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 1deea30b..bf337a0f 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -23,7 +23,6 @@
#include "gui/widgets/browserbox.h"
#include "keyboardconfig.h"
-#include "textrenderer.h"
#include "gui/gui.h"
#include "gui/truetypefont.h"
@@ -292,6 +291,8 @@ void BrowserBox::draw(gcn::Graphics *graphics)
}
}
+ auto g = static_cast<Graphics*>(graphics);
+
for (const auto &row : mTextRows)
{
for (const auto &part : row.parts)
@@ -301,16 +302,15 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (part.y > yEnd)
return;
- TextRenderer::renderText(graphics,
- part.text,
- part.x,
- part.y,
- Graphics::LEFT,
- part.color,
- part.font,
- part.outlineColor.has_value() || mOutline,
- mShadows,
- part.outlineColor);
+ g->drawText(part.text,
+ part.x,
+ part.y,
+ Graphics::LEFT,
+ part.color,
+ part.font,
+ part.outlineColor.has_value() || mOutline,
+ mShadows,
+ part.outlineColor);
}
}
}