Removed unnecessary ImGui patch.

This commit is contained in:
Muzychenko Andrey 2022-08-29 13:30:44 +03:00
parent 78c8acc31e
commit e8b0102bfb
2 changed files with 23 additions and 11 deletions

View File

@ -2141,7 +2141,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
if (!data)
{
// IM_ASSERT_USER_ERROR(0, "Could not load font file!");
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
return NULL;
}
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();

View File

@ -116,21 +116,33 @@ int winmain::WinMain(LPCSTR lpCmdLine)
// First step: just load the options
options::InitPrimary();
if(!Options.FontFileName.empty()) {
if(!Options.FontFileName.empty())
{
ImGuiSDL::Deinitialize();
io.Fonts->Clear();
ImVector<ImWchar> ranges;
translations::GetGlyphRange(&ranges);
ImFontConfig fontConfig;
fontConfig.OversampleV = 2;
fontConfig.OversampleH = 8;
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();
ImFontConfig fontConfig{};
// ToDo: further tweak font options, maybe try imgui_freetype
fontConfig.OversampleV = 2;
fontConfig.OversampleH = 4;
// ToDo: improve font file test, checking if file exists is not enough
auto fileName = Options.FontFileName.c_str();
auto fileHandle = fopenu(fileName, "rb");
if (fileHandle)
{
fclose(fileHandle);
// ToDo: Bind font size to UI scale
if (!io.Fonts->AddFontFromFileTTF(fileName, 13.f, &fontConfig, ranges.Data))
io.Fonts->AddFontDefault();
}
else
io.Fonts->AddFontDefault();
io.Fonts->Build();
ImGuiSDL::Initialize(renderer, 0, 0);
}