From a82601db72532b01e35ecae2c5585e7ae924db4a Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 29 Jan 2013 22:43:39 +0000 Subject: [PATCH] - playing a bit with ttf fonts: bugfix + shadow rendering --- client/UIFramework/Fonts.cpp | 10 ++++++++-- config/fonts.json | 12 ++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/client/UIFramework/Fonts.cpp b/client/UIFramework/Fonts.cpp index 4e7f66eb4..57e203d19 100644 --- a/client/UIFramework/Fonts.cpp +++ b/client/UIFramework/Fonts.cpp @@ -256,13 +256,19 @@ size_t CTrueTypeFont::getStringWidth(const std::string & data) const void CTrueTypeFont::renderText(SDL_Surface * surface, const std::string & data, const SDL_Color & color, const Point & pos) const { + if (color.r != 0 && color.g != 0 && color.b != 0) // not black - add shadow + { + SDL_Color black = { 0, 0, 0, SDL_ALPHA_OPAQUE}; + renderText(surface, data, black, Point(pos.x + 1, pos.y + 1)); + } + if (!data.empty()) { SDL_Surface * rendered; if (blended) - rendered = TTF_RenderText_Solid(font.get(), data.c_str(), color); - else rendered = TTF_RenderText_Blended(font.get(), data.c_str(), color); + else + rendered = TTF_RenderText_Solid(font.get(), data.c_str(), color); assert(rendered); diff --git a/config/fonts.json b/config/fonts.json index af6be5050..7aa8360cb 100644 --- a/config/fonts.json +++ b/config/fonts.json @@ -24,14 +24,14 @@ // "blend" - if set to true, font will be antialiased "trueType": { - //"BIGFONT" : { "file" : "TimesNewRoman.ttf", "size" : 20, "style" : ["bold"], "blend" : true}, + //"BIGFONT" : { "file" : "LiberationSerif-Bold.ttf", "size" : 22, "blend" : true}, //"CALLI10R" : { "file" : "Georgia.ttf", "size" : 10}, - //"CREDITS" : { "file" : "TimesNewRoman.ttf", "size" : 13, "blend" : true}, + //"CREDITS" : { "file" : "LiberationSerif-Bold.ttf", "size" : 28}, //"HISCORE" : { "file" : "Georgia.ttf", "size" : 13}, - //"MEDFONT" : { "file" : "TimesNewRoman.ttf", "size" : 16, "blend" : true}, - //"SMALFONT" : { "file" : "Georgia.ttf", "size" : 13}, - //"TIMES08R" : { "file" : "TimesNewRoman.ttf", "size" : 8, "blend" : true}, - //"TINY" : { "file" : "Georgia.ttf", "size" : 10}, + //"MEDFONT" : { "file" : "LiberationSerif-Bold.ttf", "size" : 16}, // breaks messages (from map events) + //"SMALFONT" : { "file" : "LiberationSerif-Regular.ttf", "size" : 13, "blend" : true}, + //"TIMES08R" : { "file" : "LiberationSerif-Regular.ttf", "size" : 11, "blend" : true}, + //"TINY" : { "file" : "LiberationSerif-Regular.ttf", "size" : 11, "blend" : true}, //"VERD10B" : { "file" : "Georgia.ttf", "size" : 13} } }