mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2023-12-30 21:52:56 +00:00
Refactored System font option.
This commit is contained in:
parent
7a6ae6ac50
commit
6ce3f654b1
@ -436,7 +436,7 @@ void gdrv::ScrollBitmapHorizontal(gdrv_bitmap8* bmp, int xStart)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CALLBACK gdrv_find_font_func(
|
int CALLBACK gdrv::find_font_func(
|
||||||
ENUMLOGFONTEXA *lpelfe,
|
ENUMLOGFONTEXA *lpelfe,
|
||||||
NEWTEXTMETRICEXA *lpntme,
|
NEWTEXTMETRICEXA *lpntme,
|
||||||
DWORD FontType,
|
DWORD FontType,
|
||||||
@ -459,7 +459,7 @@ bool gdrv::find_font(const char* fontName)
|
|||||||
strcpy_s(lf.lfFaceName, fontName);
|
strcpy_s(lf.lfFaceName, fontName);
|
||||||
|
|
||||||
HDC hDC = GetDC(NULL);
|
HDC hDC = GetDC(NULL);
|
||||||
EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)&gdrv_find_font_func, reinterpret_cast<LPARAM>(¶ms), 0);
|
EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)&find_font_func, reinterpret_cast<LPARAM>(¶ms), 0);
|
||||||
ReleaseDC(NULL, hDC);
|
ReleaseDC(NULL, hDC);
|
||||||
return params.found;
|
return params.found;
|
||||||
}
|
}
|
||||||
@ -472,11 +472,9 @@ void gdrv::choose_font()
|
|||||||
static const int fontSizes_System[3] = { 17, 21, 29 };
|
static const int fontSizes_System[3] = { 17, 21, 29 };
|
||||||
static const int fontSizes_WinMenu[3] = { 17, 21, 27 };
|
static const int fontSizes_WinMenu[3] = { 17, 21, 27 };
|
||||||
|
|
||||||
const char* system_font_filename = nullptr;
|
// Default path: scalable TTF font with AA.
|
||||||
// Only System font requires non-default charset,
|
fontCharset = DEFAULT_CHARSET;
|
||||||
// and custom charsets may break other fonts (like WinMenu).
|
auto specialFont = true;
|
||||||
int systemFontCharset = DEFAULT_CHARSET;
|
|
||||||
|
|
||||||
switch (options::Options.Language)
|
switch (options::Options.Language)
|
||||||
{
|
{
|
||||||
case Languages::TraditionalChinese:
|
case Languages::TraditionalChinese:
|
||||||
@ -489,70 +487,80 @@ void gdrv::choose_font()
|
|||||||
break;
|
break;
|
||||||
case Languages::Japanese:
|
case Languages::Japanese:
|
||||||
fontFamily = "MS UI Gothic";
|
fontFamily = "MS UI Gothic";
|
||||||
fontSizes = fontSizes_Arial; // we need feedback for this
|
fontSizes = fontSizes_EastAsian;
|
||||||
break;
|
break;
|
||||||
case Languages::Korean:
|
case Languages::Korean:
|
||||||
fontFamily = "Gulim";
|
fontFamily = "Gulim";
|
||||||
fontSizes = fontSizes_EastAsian;
|
fontSizes = fontSizes_EastAsian;
|
||||||
break;
|
break;
|
||||||
case Languages::Greek:
|
|
||||||
system_font_filename = "vgasysg.fon";
|
|
||||||
systemFontCharset = GREEK_CHARSET;
|
|
||||||
break;
|
|
||||||
case Languages::Russian:
|
|
||||||
system_font_filename = "vgasysr.fon";
|
|
||||||
systemFontCharset = RUSSIAN_CHARSET;
|
|
||||||
break;
|
|
||||||
case Languages::Turkish:
|
|
||||||
system_font_filename = "vgasyst.fon";
|
|
||||||
systemFontCharset = TURKISH_CHARSET;
|
|
||||||
break;
|
|
||||||
case Languages::Danish:
|
|
||||||
case Languages::Dutch:
|
|
||||||
case Languages::Norwegian:
|
|
||||||
case Languages::Swedish:
|
|
||||||
system_font_filename = "vgasys.fon";
|
|
||||||
systemFontCharset = DEFAULT_CHARSET;
|
|
||||||
break;
|
|
||||||
case Languages::Czech:
|
|
||||||
case Languages::Hungarian:
|
|
||||||
case Languages::Polish:
|
|
||||||
system_font_filename = "vgasyse.fon";
|
|
||||||
systemFontCharset = EASTEUROPE_CHARSET;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
system_font_filename = "vgasys.fon";
|
fontFamily = "Arial";
|
||||||
break;
|
fontSizes = fontSizes_Arial;
|
||||||
|
specialFont = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontFamily.empty()) // no font chosen yet
|
// System font does not support some languages.
|
||||||
|
if (!options::Options.SystemFont || specialFont)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Alternative path: user defined font or System font.
|
||||||
|
auto userFont = options::Options.SystemFontName;
|
||||||
|
if (userFont[0] != '\0' && find_font(userFont))
|
||||||
{
|
{
|
||||||
if (!options::Options.SystemFont)
|
fontFamily = userFont;
|
||||||
|
fontSizes = fontSizes_WinMenu;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Original game does no font setup, so it ends up with default System font.
|
||||||
|
// System is a bitmap font with no AA and limited scaling support.
|
||||||
|
// Specific .fon selection is needed for improved language support.
|
||||||
|
fontFamily = "System";
|
||||||
|
fontSizes = fontSizes_System;
|
||||||
|
const char* system_font_filename = nullptr;
|
||||||
|
switch (options::Options.Language)
|
||||||
{
|
{
|
||||||
fontFamily = "Arial";
|
case Languages::Greek:
|
||||||
fontSizes = fontSizes_Arial;
|
system_font_filename = "vgasysg.fon";
|
||||||
}
|
fontCharset = GREEK_CHARSET;
|
||||||
else if (options::Options.SystemFontName[0] != '\0' && find_font(options::Options.SystemFontName))
|
break;
|
||||||
{
|
case Languages::Russian:
|
||||||
fontFamily = options::Options.SystemFontName;
|
system_font_filename = "vgasysr.fon";
|
||||||
fontSizes = fontSizes_WinMenu;
|
fontCharset = RUSSIAN_CHARSET;
|
||||||
|
break;
|
||||||
|
case Languages::Turkish:
|
||||||
|
system_font_filename = "vgasyst.fon";
|
||||||
|
fontCharset = TURKISH_CHARSET;
|
||||||
|
break;
|
||||||
|
case Languages::Danish:
|
||||||
|
case Languages::Dutch:
|
||||||
|
case Languages::Norwegian:
|
||||||
|
case Languages::Swedish:
|
||||||
|
system_font_filename = "vgasys.fon";
|
||||||
|
fontCharset = DEFAULT_CHARSET;
|
||||||
|
break;
|
||||||
|
case Languages::Czech:
|
||||||
|
case Languages::Hungarian:
|
||||||
|
case Languages::Polish:
|
||||||
|
case Languages::Finnish:
|
||||||
|
system_font_filename = "vgasyse.fon";
|
||||||
|
fontCharset = EASTEUROPE_CHARSET;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
system_font_filename = "vgasys.fon";
|
||||||
|
fontCharset = DEFAULT_CHARSET;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string windir(MAX_PATH, '\0');
|
||||||
|
DWORD result = GetEnvironmentVariableA("WINDIR", &windir[0], MAX_PATH);
|
||||||
|
if (result == 0 || result > MAX_PATH) // fails or doesn't fit
|
||||||
|
windir = "C:\\Windows";
|
||||||
else
|
else
|
||||||
{
|
windir.resize(result);
|
||||||
fontFamily = "System";
|
|
||||||
fontSizes = fontSizes_System;
|
|
||||||
fontCharset = systemFontCharset;
|
|
||||||
|
|
||||||
std::string windir(MAX_PATH, '\0');
|
fontFilename = windir + "\\Fonts\\" + system_font_filename;
|
||||||
DWORD result = GetEnvironmentVariableA("WINDIR", &windir[0], MAX_PATH);
|
AddFontResourceExA(fontFilename.c_str(), FR_PRIVATE, 0);
|
||||||
if (result == 0 || result > MAX_PATH) // fails or doesn't fit
|
|
||||||
windir = "C:\\Windows";
|
|
||||||
else
|
|
||||||
windir.resize(result);
|
|
||||||
|
|
||||||
fontFilename = windir + "\\Fonts\\" + system_font_filename;
|
|
||||||
AddFontResourceExA(fontFilename.c_str(), FR_PRIVATE, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +70,6 @@ public:
|
|||||||
static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff,
|
static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff,
|
||||||
gdrv_bitmap8* srcBmp, int srcXOff, int srcYOff);
|
gdrv_bitmap8* srcBmp, int srcXOff, int srcYOff);
|
||||||
static void ScrollBitmapHorizontal(gdrv_bitmap8* bmp, int xStart);
|
static void ScrollBitmapHorizontal(gdrv_bitmap8* bmp, int xStart);
|
||||||
static bool find_font(const char* fontName);
|
|
||||||
static void choose_font();
|
|
||||||
static void grtext_draw_ttext_in_box(LPCWSTR text, int xOff, int yOff, int width, int height, bool centered);
|
static void grtext_draw_ttext_in_box(LPCWSTR text, int xOff, int yOff, int width, int height, bool centered);
|
||||||
private:
|
private:
|
||||||
/*COLORONCOLOR or HALFTONE*/
|
/*COLORONCOLOR or HALFTONE*/
|
||||||
@ -89,4 +87,7 @@ private:
|
|||||||
static int StretchDIBitsScaled(HDC hdc, int xDest, int yDest, int DestWidth, int DestHeight, int xSrc, int ySrc,
|
static int StretchDIBitsScaled(HDC hdc, int xDest, int yDest, int DestWidth, int DestHeight, int xSrc, int ySrc,
|
||||||
int SrcWidth, int SrcHeight, gdrv_bitmap8* bmp, UINT iUsage,
|
int SrcWidth, int SrcHeight, gdrv_bitmap8* bmp, UINT iUsage,
|
||||||
DWORD rop);
|
DWORD rop);
|
||||||
|
static bool find_font(const char* fontName);
|
||||||
|
static int CALLBACK find_font_func(ENUMLOGFONTEXA* lpelfe, NEWTEXTMETRICEXA* lpntme, DWORD FontType, LPARAM lParam);
|
||||||
|
static void choose_font();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user