summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-05-27 23:36:18 +0300
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_fr>2010-05-27 23:24:59 +0200
commit6c91c7eed18ad377484e7f0edf6eff520f056c13 (patch)
tree1dc0ae52cb45b9393429e7092f6501d4b073179c /src/gui
parentad34e7cf98b7a4d7096b66c743e4a087d9b432dd (diff)
downloadmana-client-6c91c7eed18ad377484e7f0edf6eff520f056c13.tar.gz
mana-client-6c91c7eed18ad377484e7f0edf6eff520f056c13.tar.bz2
mana-client-6c91c7eed18ad377484e7f0edf6eff520f056c13.tar.xz
mana-client-6c91c7eed18ad377484e7f0edf6eff520f056c13.zip
Fix drawing incorrect utf8 strings issue.
Reviewed-by: Bertram Resolve: Manasource Mantis #143
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/truetypefont.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp
index 3bf1febe..55d1a18a 100644
--- a/src/gui/truetypefont.cpp
+++ b/src/gui/truetypefont.cpp
@@ -26,9 +26,11 @@
#include "resources/image.h"
+#include "utils/stringutils.h"
+
#include <guichan/exception.hpp>
-#define CACHE_SIZE 256
+const unsigned int CACHE_SIZE = 256;
class TextChunk
{
@@ -55,8 +57,10 @@ class TextChunk
sdlCol.r = color.r;
sdlCol.g = color.g;
+ const char* str = getSafeUtf8String(text);
SDL_Surface *surface = TTF_RenderUTF8_Blended(
- font, text.c_str(), sdlCol);
+ font, str, sdlCol);
+ delete[] str;
if (!surface)
{
@@ -175,7 +179,8 @@ int TrueTypeFont::getWidth(const std::string &text) const
}
int w, h;
- TTF_SizeUTF8(mFont, text.c_str(), &w, &h);
+ const char* str = getSafeUtf8String(text);
+ TTF_SizeUTF8(mFont, str, &w, &h);
return w;
}