From a0e6d3b0f090972033a03c290c0e615642eba7b5 Mon Sep 17 00:00:00 2001 From: Lim Chunwei Date: Tue, 26 Oct 2021 02:09:44 +0800 Subject: [PATCH] Better (?) implementation of using strings (so that font names aren't limited to 30 chars) --- SpaceCadetPinball/gdrv.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SpaceCadetPinball/gdrv.cpp b/SpaceCadetPinball/gdrv.cpp index f893ad4..3c7385a 100644 --- a/SpaceCadetPinball/gdrv.cpp +++ b/SpaceCadetPinball/gdrv.cpp @@ -6,7 +6,7 @@ #include "options.h" #include "pinball.h" #include "winmain.h" -#include "string.h" +#include HPALETTE gdrv::palette_handle = nullptr; HINSTANCE gdrv::hinst; @@ -447,24 +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); } - char font[30]; + std::string font; switch (options::Options.Language) { case Languages::TraditionalChinese: - strcpy_s(font, "Microsoft JhengHei"); + font = "Microsoft JhengHei"; break; case Languages::SimplifiedChinese: - strcpy_s(font, "Microsoft YaHei"); + font = "Microsoft YaHei"; break; default: - strcpy_s(font, "Arial"); + 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, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - DEFAULT_PITCH | FF_SWISS, font); + 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);