From 0faf06224f647c67a5252ce1df68bbfe1e3b6204 Mon Sep 17 00:00:00 2001
From: Clownacy <Clownacy@users.noreply.github.com>
Date: Sun, 1 Sep 2019 20:30:26 +0100
Subject: [PATCH] Added a bugfix for font creation

Fixes Japanese builds using the wrong charset on non-Japanese Windows
installations, and fixed the font using antialiasing, causing it to
clash with the game's colour-keying.
---
 src/Draw.cpp | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/Draw.cpp b/src/Draw.cpp
index fa70ecbf..4add7b70 100644
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -829,10 +829,26 @@ void InitTextObject(const char *name)
 
 	// The game uses DEFAULT_CHARSET when it should have used SHIFTJIS_CHARSET.
 	// This breaks the Japanese text on English Windows installations.
-	font = CreateFontA(height, width, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH | FF_DONTCARE, name);
+
+	// Also, the game uses DEFAULT_QUALITY instead of NONANTIALIASED_QUALITY,
+	// causing font antialiasing to blend with the colour-key, giving text ab
+	// ugly black outline.
+#ifdef FIX_BUGS
+	#define QUALITY NONANTIALIASED_QUALITY
+	#ifdef JAPANESE
+		#define CHARSET SHIFTJIS_CHARSET
+	#else
+		#define CHARSET DEFAULT_CHARSET
+	#endif
+#else
+	#define QUALITY DEFAULT_QUALITY
+	#define CHARSET DEFAULT_CHARSET
+#endif
+
+	font = CreateFontA(height, width, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, QUALITY, FIXED_PITCH | FF_DONTCARE, name);
 
 	if (font == NULL)
-		font = CreateFontA(height, width, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH | FF_DONTCARE, NULL);
+		font = CreateFontA(height, width, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, QUALITY, FIXED_PITCH | FF_DONTCARE, NULL);
 }
 
 void PutText(int x, int y, const char *text, unsigned long color)