浏览代码

Integrated Noto fonts into vcmi

Ivan Savenko 1 年之前
父节点
当前提交
97e24ff126

二进制
Mods/vcmi/Data/NotoSans-Medium.ttf


二进制
Mods/vcmi/Data/NotoSerif-Black.ttf


二进制
Mods/vcmi/Data/NotoSerif-Bold.ttf


二进制
Mods/vcmi/Data/NotoSerif-Medium.ttf


+ 1 - 1
client/gui/InterfaceObjectConfigurable.cpp

@@ -285,7 +285,7 @@ EFonts InterfaceObjectConfigurable::readFont(const JsonNode & config) const
 			return EFonts::FONT_CALLI;
 	}
 	logGlobal->debug("Unknown font attribute");
-	return EFonts::FONT_TIMES;
+	return EFonts::FONT_MEDIUM;
 }
 
 std::pair<std::string, std::string> InterfaceObjectConfigurable::readHintText(const JsonNode & config) const

+ 12 - 4
client/renderSDL/CTrueTypeFont.cpp

@@ -62,12 +62,14 @@ int CTrueTypeFont::getFontStyle(const JsonNode &config) const
 CTrueTypeFont::CTrueTypeFont(const JsonNode & fontConfig):
 	data(loadData(fontConfig)),
 	font(loadFont(fontConfig), TTF_CloseFont),
-	dropShadow(fontConfig["blend"].Bool()),
-	blended(fontConfig["blend"].Bool())
+	dropShadow(!fontConfig["noShadow"].Bool()),
+	outline(fontConfig["outline"].Bool()),
+	blended(true)
 {
 	assert(font);
 
 	TTF_SetFontStyle(font.get(), getFontStyle(fontConfig));
+	TTF_SetFontHinting(font.get(),TTF_HINTING_MONO);
 
 	std::string fallbackName = fontConfig["fallback"].String();
 
@@ -111,8 +113,14 @@ void CTrueTypeFont::renderText(SDL_Surface * surface, const std::string & data,
 		return;
 	}
 
-	if (dropShadow && color.r != 0 && color.g != 0 && color.b != 0) // not black - add shadow
-		renderText(surface, data, Colors::BLACK, pos + Point(1,1) * getScalingFactor());
+	if (color.r != 0 && color.g != 0 && color.b != 0) // not black - add shadow
+	{
+		if (outline)
+			renderText(surface, data, Colors::BLACK, pos - Point(1,1) * getScalingFactor());
+
+		if (dropShadow || outline)
+			renderText(surface, data, Colors::BLACK, pos + Point(1,1) * getScalingFactor());
+	}
 
 	if (!data.empty())
 	{

+ 1 - 0
client/renderSDL/CTrueTypeFont.h

@@ -26,6 +26,7 @@ class CTrueTypeFont final : public IFont
 
 	const std::unique_ptr<TTF_Font, void (*)(TTF_Font*)> font;
 	const bool blended;
+	const bool outline;
 	const bool dropShadow;
 
 	std::pair<std::unique_ptr<ui8[]>, ui64> loadData(const JsonNode & config);

+ 15 - 14
config/fonts.json

@@ -5,12 +5,12 @@
 	"bitmap" :
 	[
 		"BIGFONT",  // Mostly used for window titles
-		"CALLI10R", // Unused in VCMI
-		"CREDITS",  // Used for credits menu
-		"HISCORE",  // Unused in VCMI
+		"CALLI10R", // Only in World View menu
+		"CREDITS",  // Only in Credits menu
+		"HISCORE",  // Only in High Scores menu
 		"MEDFONT",  // Some titles
 		"SMALFONT", // Most of the messages
-		"TIMES08R", // Used to display amounts on creature card 
+		"TIMES08R", // Unused in VCMI
 		"TINY",     // Some text
 		"VERD10B"   // Unused in VCMI
 	],
@@ -25,17 +25,18 @@
 	// b) list of scaling factors for each scaling mode, e.g. [ 10, 16, 22, 26]. In this case game will select point size according to xBRZ scaling factor
 	//    so unscaled mode will use 10px, xbrz2 will use 16px, and xbrz3 will use 22
 	// "style" - italic and\or bold, indicates font style
-	// "blend" - if set to true, font will be antialiased
+	// "outline" - if set, black shadow will be generated around entire text (instead of only bottom-right side)
+	// "noShadow" - if set, this font will not drop any shadow
 	"trueType":
 	{
-		//"BIGFONT"  : { "file" : "LiberationSerif-Bold.ttf", "size" : 22, "blend" : true},
-		//"CALLI10R" : { "file" : "Georgia.ttf",       "size" : 10},
-		//"CREDITS"  : { "file" : "LiberationSerif-Bold.ttf", "size" : 28},
-		//"HISCORE"  : { "file" : "Georgia.ttf",       "size" : 13},
-		//"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}
+		"BIGFONT"  : { "file" : "NotoSerif-Bold.ttf",   "size" : [ 19, 39, 58, 78] },
+		"CALLI10R" : { "file" : "NotoSerif-Bold.ttf",   "size" : [ 12, 24, 36, 48] }, // TODO: find better matching font? This is likely non-free 'Callisto MT' font
+		"CREDITS"  : { "file" : "NotoSerif-Black.ttf",  "size" : [ 22, 44, 66, 88], "outline" : true },
+		"HISCORE"  : { "file" : "NotoSerif-Black.ttf",  "size" : [ 18, 36, 54, 72], "outline" : true },
+		"MEDFONT"  : { "file" : "NotoSerif-Bold.ttf",   "size" : [ 15, 31, 46, 62] },
+		"SMALFONT" : { "file" : "NotoSerif-Medium.ttf", "size" : [ 12, 24, 36, 48] },
+		"TIMES08R" : { "file" : "NotoSerif-Medium.ttf", "size" : [  8, 16, 24, 32] },
+		"TINY"     : { "file" : "NotoSans-Medium.ttf",  "size" : [  9, 19, 28, 38], "noShadow" : true }, // The only H3 font without shadow
+		"VERD10B"  : { "file" : "NotoSans-Medium.ttf",  "size" : [ 13, 26, 39, 52] }
 	}
 }