Merge branch 'master' into jgrpp

# Conflicts:
#	src/debug.cpp
#	src/lang/russian.txt
#	src/misc_gui.cpp
#	src/os/windows/crashlog_win.cpp
#	src/os/windows/font_win32.cpp
#	src/os/windows/win32.cpp
#	src/rail_cmd.cpp
#	src/window_gui.h
This commit is contained in:
Jonathan G Rennison
2021-04-11 03:05:08 +01:00
52 changed files with 439 additions and 267 deletions

View File

@@ -83,7 +83,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
}
/* Convert font name to file system encoding. */
wchar_t *font_namep = wcsdup(OTTD2FS(font_name));
wchar_t *font_namep = wcsdup(OTTD2FS(font_name).c_str());
for (index = 0;; index++) {
wchar_t *s;
@@ -377,6 +377,7 @@ Win32FontCache::Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels)
{
this->dc = CreateCompatibleDC(nullptr);
this->SetFontSize(fs, pixels);
this->fontname = FS2OTTD(this->logfont.lfFaceName);
}
Win32FontCache::~Win32FontCache()
@@ -440,7 +441,7 @@ void Win32FontCache::SetFontSize(FontSize fs, int pixels)
font_height_cache[this->fs] = this->GetHeight();
DEBUG(freetype, 2, "Loaded font '%s' with size %d", FS2OTTD((LPTSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)), pixels);
DEBUG(freetype, 2, "Loaded font '%s' with size %d", FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)).c_str(), pixels);
}
/**
@@ -499,7 +500,7 @@ void Win32FontCache::ClearFontCache()
* For anti-aliased rendering, GDI uses the strange value range of 0 to 64,
* inclusively. To map this to 0 to 255, we shift left by two and then
* subtract one. */
uint pitch = Align(aa ? gm.gmBlackBoxX : std::max(gm.gmBlackBoxX / 8u, 1u), 4);
uint pitch = Align(aa ? gm.gmBlackBoxX : std::max((gm.gmBlackBoxX + 7u) / 8u, 1u), 4);
/* Draw shadow for medium size. */
if (this->fs == FS_NORMAL && !aa) {
@@ -543,10 +544,10 @@ void Win32FontCache::ClearFontCache()
/* Convert characters outside of the BMP into surrogate pairs. */
WCHAR chars[2];
if (key >= 0x010000U) {
chars[0] = (WCHAR)(((key - 0x010000U) >> 10) + 0xD800);
chars[1] = (WCHAR)(((key - 0x010000U) & 0x3FF) + 0xDC00);
chars[0] = (wchar_t)(((key - 0x010000U) >> 10) + 0xD800);
chars[1] = (wchar_t)(((key - 0x010000U) & 0x3FF) + 0xDC00);
} else {
chars[0] = (WCHAR)(key & 0xFFFF);
chars[0] = (wchar_t)(key & 0xFFFF);
}
WORD glyphs[2] = { 0, 0 };
@@ -607,12 +608,12 @@ void LoadWin32Font(FontSize fs)
/* See if this is an absolute path. */
if (FileExists(settings->font)) {
convert_to_fs(settings->font, fontPath, lengthof(fontPath), false);
convert_to_fs(settings->font, fontPath, lengthof(fontPath));
} else {
/* Scan the search-paths to see if it can be found. */
std::string full_font = FioFindFullPath(BASE_DIR, settings->font);
if (!full_font.empty()) {
convert_to_fs(full_font.c_str(), fontPath, lengthof(fontPath), false);
convert_to_fs(full_font.c_str(), fontPath, lengthof(fontPath));
}
}
@@ -650,7 +651,7 @@ void LoadWin32Font(FontSize fs)
if (logfont.lfFaceName[0] == 0) {
logfont.lfWeight = strcasestr(settings->font, " bold") != nullptr ? FW_BOLD : FW_NORMAL; // Poor man's way to allow selecting bold fonts.
convert_to_fs(settings->font, logfont.lfFaceName, lengthof(logfont.lfFaceName), false);
convert_to_fs(settings->font, logfont.lfFaceName, lengthof(logfont.lfFaceName));
}
HFONT font = CreateFontIndirect(&logfont);