Fix crash when the font file doesn't exist
This commit is contained in:
parent
ea4e143405
commit
d8ae03d281
|
@ -2141,7 +2141,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
||||||
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
|
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
|
// IM_ASSERT_USER_ERROR(0, "Could not load font file!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||||
|
|
|
@ -125,7 +125,10 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||||
fontConfig.OversampleV = 2;
|
fontConfig.OversampleV = 2;
|
||||||
fontConfig.OversampleH = 8;
|
fontConfig.OversampleH = 8;
|
||||||
|
|
||||||
io.Fonts->AddFontFromFileTTF(Options.FontFileName.c_str(), 13.f, &fontConfig, ranges.Data);
|
if(!io.Fonts->AddFontFromFileTTF(Options.FontFileName.c_str(), 13.f, &fontConfig, ranges.Data)) {
|
||||||
|
// Font loading failed, load default font instead
|
||||||
|
io.Fonts->AddFontDefault();
|
||||||
|
}
|
||||||
io.Fonts->Build();
|
io.Fonts->Build();
|
||||||
|
|
||||||
ImGuiSDL::Initialize(renderer, 0, 0);
|
ImGuiSDL::Initialize(renderer, 0, 0);
|
||||||
|
|
Loading…
Reference in New Issue