ソースを参照

- playing a bit with ttf fonts: bugfix + shadow rendering

Ivan Savenko 12 年 前
コミット
a82601db72
2 ファイル変更14 行追加8 行削除
  1. 8 2
      client/UIFramework/Fonts.cpp
  2. 6 6
      config/fonts.json

+ 8 - 2
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);
 

+ 6 - 6
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}
 	}
 }