diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-07-10 13:44:10 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-07-15 11:40:25 +0200 |
commit | f83b1d648fc6ec2c64fd2c3483fede23c973c20f (patch) | |
tree | 04dd7950cbea1331870190d1caf9061011dfca05 /src/gui/widgets/browserbox.cpp | |
parent | 32bcf41f01d4ed4a3a08030095611e75d6186d60 (diff) | |
download | mana-f83b1d648fc6ec2c64fd2c3483fede23c973c20f.tar.gz mana-f83b1d648fc6ec2c64fd2c3483fede23c973c20f.tar.bz2 mana-f83b1d648fc6ec2c64fd2c3483fede23c973c20f.tar.xz mana-f83b1d648fc6ec2c64fd2c3483fede23c973c20f.zip |
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.cpp | 22 |
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); } } } |