Skip to content

Commit

Permalink
East Asian font adjustments (#94)
Browse files Browse the repository at this point in the history
* Disable input method in game

* Improve imm32.lib linking

* East Asian font size adjustments

* Use pre-defined font sizes instead of offset

* Use Malgun Gothic instead of Gulim for Korean
  • Loading branch information
win98se authored Nov 19, 2021
1 parent 129b8aa commit 818a90b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions SpaceCadetPinball/gdrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,17 @@ void gdrv::grtext_draw_ttext_in_box(LPCWSTR text, int xOff, int yOff, int width,
22,
28
};
static const int fontSizes_EastAsian[3] =
{
22,
27,
32
};

xOff = static_cast<int>(xOff * fullscrn::ScaleX) + fullscrn::OffsetX;
yOff = static_cast<int>(yOff * fullscrn::ScaleY) + fullscrn::OffsetY;
width = static_cast<int>(width * fullscrn::ScaleX);
height = static_cast<int>(height * fullscrn::ScaleY);
auto fontSize = static_cast<int>(round(fontSizes[fullscrn::GetResolution()] * fullscrn::ScaleY));

HDC dc = GetDC(hwnd);
tagRECT rc{};
Expand All @@ -459,25 +464,29 @@ void gdrv::grtext_draw_ttext_in_box(LPCWSTR text, int xOff, int yOff, int width,
sscanf_s(fontColor, "%d %d %d", &grtext_red, &grtext_green, &grtext_blue);
}

const char* font;
const char* font = "Arial";
const int* selectedFontSizes = fontSizes;
switch (options::Options.Language)
{
case Languages::TraditionalChinese:
font = "Microsoft JhengHei";
selectedFontSizes = fontSizes_EastAsian;
break;
case Languages::SimplifiedChinese:
font = "Microsoft YaHei";
selectedFontSizes = fontSizes_EastAsian;
break;
case Languages::Japanese:
font = "MS UI Gothic";
break;
case Languages::Korean:
font = "Gulim";
font = "Malgun Gothic";
selectedFontSizes = fontSizes_EastAsian;
break;
default:
font = "Arial";
}

auto fontSize = static_cast<int>(round(selectedFontSizes[fullscrn::GetResolution()] * fullscrn::ScaleY));

// 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,
Expand Down

0 comments on commit 818a90b

Please sign in to comment.