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)
This commit is contained in:
Lim Chunwei 2021-10-26 11:53:52 +08:00 committed by GitHub
parent 09c62f5909
commit 3c2fff9d07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@
#include "options.h"
#include "pinball.h"
#include "winmain.h"
#include <string>
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<HFONT>(SelectObject(dc, hNewFont));
int prevMode = SetBkMode(dc, TRANSPARENT);
COLORREF color = SetTextColor(dc, grtext_red | grtext_green << 8 | grtext_blue << 16);