Closed
Description
Version/Branch of Dear ImGui:
master
Back-ends:
Any backend
Compiler, OS:
Windows + MSYS/MinGW
Full config/build information:
No response
Details:
I am building Dear ImGui with MSYS2 and MinGW. I noticed it fails to open TTF files when their Windows path has non ASCII characters. Analyzing the code the problem seems to be in ImFileOpen, in this line:
Line 2285 in c798311
The issue is that, when compiling with MinGW, the macro __GNUC__
is defined. So, despite being in Windows, and therefore needing to use _wfopen(), the plain fopen() gets used instead. In my system I just removed that from the #endif and it now opens files correctly.
Sorry that I don't submit a PR instead, but right now I'm not sure how the MinGW compiler should be properly detected.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
#include <imgui/imgui.h>
#include <string>
int main()
{
// init ImGui
ImGui::CreateContext();
ImGui::GetIO().IniFilename = NULL;
// add all the standard characters
ImVector< ImWchar > GlyphRanges;
ImFontGlyphRangesBuilder GlyphBuilder;
GlyphBuilder.AddRanges( ImGui::GetIO().Fonts->GetGlyphRangesDefault() );
GlyphBuilder.BuildRanges( &GlyphRanges );
// load a TTF font from a non ascii path
std::string FontPath = "C:\\Español\\GuiFont.ttf";
ImFont* Font = ImGui::GetIO().Fonts->AddFontFromFileTTF( FontPath.c_str(), 16, NULL, GlyphRanges.Data );
// this will now crash because Font is NULL
ImGui::GetIO().Fonts->Build();
}
Metadata
Assignees
Labels
No labels
Activity