From 273988551d8c9d26924ec501144e3f8c44800068 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 15 Sep 2022 21:18:47 +0100 Subject: [PATCH] Fix: font_win32.cpp compile failure with WITH_FREETYPE --- src/os/windows/font_win32.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index c93e95e697..f57921c42d 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -161,7 +161,7 @@ registry_no_font_found: * @param logfont the font information to get the english name of. * @return the English name (if it could be found). */ -static const char *GetEnglishFontName(const ENUMLOGFONTEX *logfont) +static std::string GetEnglishFontName(const ENUMLOGFONTEX *logfont) { static char font_name[MAX_PATH]; const char *ret_font_name = nullptr; @@ -228,7 +228,7 @@ err2: ReleaseDC(nullptr, dc); DeleteObject(font); err1: - return ret_font_name == nullptr ? FS2OTTD((const wchar_t *)logfont->elfFullName) : ret_font_name; + return ret_font_name == nullptr ? FS2OTTD((const wchar_t *)logfont->elfFullName) : std::string(ret_font_name); } #endif /* WITH_FREETYPE */ @@ -309,8 +309,8 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT #ifdef WITH_FREETYPE /* Add english name after font name */ - const char *english_name = GetEnglishFontName(logfont); - strecpy(font_name + strlen(font_name) + 1, english_name, lastof(font_name)); + std::string english_name = GetEnglishFontName(logfont); + strecpy(font_name + strlen(font_name) + 1, english_name.c_str(), lastof(font_name)); /* Check whether we can actually load the font. */ bool ft_init = _library != nullptr;