Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImFont::IsLoaded() returns false on loaded fonts #3643

Closed
baderouaich opened this issue Dec 7, 2020 · 1 comment
Closed

ImFont::IsLoaded() returns false on loaded fonts #3643

baderouaich opened this issue Dec 7, 2020 · 1 comment

Comments

@baderouaich
Copy link

baderouaich commented Dec 7, 2020

Version/Branch of Dear ImGui:

Version: 1.79
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Compiler: MSVC v142 Visual Studio 2019 16
Operating System: Windows 10

My Issue/Question:
calling ImFont->IsLoaded() returns false after loading a font successfully.
works ok when not checking for loaded fonts.

Screenshots/Video
issue

Example

void LoadImGuiFonts()
{
	std::unordered_map<Enigma::String, ImFont*> m_fonts;
	static const auto& io = ImGui::GetIO();
	m_fonts["Audiowide-Regular-45"] = io.Fonts->AddFontFromFileTTF(Constants::Resources::Fonts::AUDIOWIDE_FONT_PATH, 45.0f);
	m_fonts["Audiowide-Regular-20"] = io.Fonts->AddFontFromFileTTF(Constants::Resources::Fonts::AUDIOWIDE_FONT_PATH, 20.0f);
	
	m_fonts["Montserrat-Medium-45"] = io.Fonts->AddFontFromFileTTF(Constants::Resources::Fonts::MONTSERRAT_FONT_PATH, 45.0f);
	m_fonts["Montserrat-Medium-20"] = io.Fonts->AddFontFromFileTTF(Constants::Resources::Fonts::MONTSERRAT_FONT_PATH, 20.0f);
	m_fonts["Montserrat-Medium-12"] = io.Fonts->AddFontFromFileTTF(Constants::Resources::Fonts::MONTSERRAT_FONT_PATH, 12.0f);

	// Check if fonts are loaded
	for (const auto& [font_name, font] : m_fonts)
	{
		if (!font->IsLoaded()) // <---- returns false on loaded fonts, works ok when disabled.
		{
			const std::string err_msg = "Failed to load font Resources/Fonts/" + font_name; 
 			std::cerr << err_msg << endl;
			break;

		}
	}
}
@baderouaich
Copy link
Author

duplicate of #2311
io.Fonts->Build() has to be called to rebuild the atlas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants