OpenTTD/OpenTTD

[Crash]: Game crashes when changing font type

Closed this issue · 4 comments

Version of OpenTTD

14.0-RC3 | Windows 8.1

Steps to reproduce

  1. Uncheck option "Use traditional sprite font"
  2. Game crashes

Upload crash files

crashlog.zip

Stacktrace:

 	[Inline Frame] openttd.exe!std::_WChar_traits<wchar_t>::length(const wchar_t *) Line 259	C++
 	[Inline Frame] openttd.exe!std::wstring::{ctor}(const wchar_t * const _Ptr) Line 2546	C++
 	openttd.exe!Win32FontCache::SetFontSize(int pixels=10) Line 195	C++
 	openttd.exe!Win32FontCache::Win32FontCache(FontSize fs, const tagLOGFONTW & logfont={...}, int pixels=10) Line 131	C++
 	openttd.exe!LoadWin32Font(FontSize fs, const tagLOGFONTW & logfont={...}, unsigned int size=10, const char * font_name=0x0000005b2309c520) Line 378	C++
 	openttd.exe!LoadWin32Font(FontSize fs=FS_MONO, const std::string & file_name, unsigned int size=10) Line 435	C++
 	openttd.exe!TryLoadDefaultTrueTypeFont(FontSize fs=FS_MONO) Line 185	C++
 	openttd.exe!InitFontCache(bool monospace) Line 209	C++
 	openttd.exe!GameOptionsWindow::OnClick(Point pt, int widget, int click_count=1) Line 770	C++
 	openttd.exe!DispatchLeftClickEvent(Window * w=0x0000005b48263e70, int x=287, int y=127, int click_count=1) Line 733	C++
 	openttd.exe!MouseLoop(MouseClick click=MC_LEFT, int mousewheel=0) Line 2844	C++
 	openttd.exe!HandleMouseEvents() Line 2947	C++
 	openttd.exe!WndProcGdi(HWND__ * hwnd=0x00000000003c0376, unsigned int msg=513, unsigned __int64 wParam=1, __int64 lParam=20710145) Line 445	C++

Line 195 is this->fontname = FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFaceName));

otm comes from GetOutlineTextMetrics(), so this suggests to me that a bitmap font is selected, but we assume it is an outline font... Or something is fishy with its name.

otmSize seems to be 0, would mean GetOutlineTextMetrics() failed but we expect it to never fail.

@Air118 are you able to reproduce it reliably on your system? As I'm unable to reproduce it on mine, but there is a test build with a possible fix in #12406 (comment).