From 3c2fff9d07925ac3c759ec3bb783e476a36805b5 Mon Sep 17 00:00:00 2001 From: Lim Chunwei Date: Tue, 26 Oct 2021 11:53:52 +0800 Subject: [PATCH] Use a single Unicode charset and specify language-specific font for better viewing (?) (#69) * Use a single Unicode charset and specify language-specific font for better (?) viewing * Fix missing include for strcpy_s function * Better (?) implementation of using strings (so that font names aren't limited to 30 chars) --- SpaceCadetPinball/gdrv.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/SpaceCadetPinball/gdrv.cpp b/SpaceCadetPinball/gdrv.cpp index 78ac18f..3c7385a 100644 --- a/SpaceCadetPinball/gdrv.cpp +++ b/SpaceCadetPinball/gdrv.cpp @@ -6,6 +6,7 @@ #include "options.h" #include "pinball.h" #include "winmain.h" +#include HPALETTE gdrv::palette_handle = nullptr; HINSTANCE gdrv::hinst; @@ -446,29 +447,24 @@ void gdrv::grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, sscanf_s(fontColor, "%d %d %d", &grtext_red, &grtext_green, &grtext_blue); } - // DEFAULT_CHARSET in unicode build. - int charset; + std::string font; switch (options::Options.Language) { - default: - case Languages::English: - charset = ANSI_CHARSET; - break; - case Languages::Russian: - charset = RUSSIAN_CHARSET; - break; case Languages::TraditionalChinese: - charset = CHINESEBIG5_CHARSET; + font = "Microsoft JhengHei"; break; case Languages::SimplifiedChinese: - charset = GB2312_CHARSET; + font = "Microsoft YaHei"; break; + default: + font = "Arial"; } + // DEFAULT_CHARSET in unicode build. // Default font does not scale well auto hNewFont = CreateFont(fontSize, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, - charset, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - DEFAULT_PITCH | FF_SWISS, "Arial"); + DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + DEFAULT_PITCH | FF_SWISS, font.c_str()); HFONT hOldFont = static_cast(SelectObject(dc, hNewFont)); int prevMode = SetBkMode(dc, TRANSPARENT); COLORREF color = SetTextColor(dc, grtext_red | grtext_green << 8 | grtext_blue << 16);