You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: MSVC (Visual Studio 2019 v. 16.11.9 with C++20)
Operating System: Windows 10 @ Latest Update
My Issue/Question:
I'm pushing a font before making a call to ImGui::Begin(myTitle), but the title text is still in default font. How can I make the title use the font I pushed without making it the default font?
Screenshots/Video
Standalone, minimal, complete and verifiable example:
ImGui::PushID("Observer");
// This bit is included because I'm lost
std::string title(SOME_UNICODE_FROM_ICON_FONT_CPP_HEADERS_FONT_AWESOME);
title.append(" ");
title.append("Observer");
// Don't ask why I append ###, because some parts of my code is not present here
// (the bit where it adds some dynamic value to the title string),
// but I included this because I'm lost
title.append("###");
title.append("Observer");
// Font is loaded for sure since AddFontFromFileTTF does not return NULL and
// bold font works for ImGui::Text
ImGui::PushFont(gui->GetFontBold()); // returns ImGui::GetIO().Fonts->Fonts[1]
ImGui::Begin(title.c_str()); // I am not in bold,
ImGui::Text("this text is for testing only"); // but I am bold, but why?
ImGui::End();
ImGui::PopFont();
ImGui::PopID();
Here is how I load my fonts:
// This function called once and only once when I launch my program.
// context is a static variable defined in my ImGuiIntegration.cpp file
ImGuiContext* ImGuiInit(GLFWwindow* window) {
if(context == nullptr) {
IMGUI_CHECKVERSION();
context = ImGui::CreateContext();
ImGuiIO& io{ ImGui::GetIO() };
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
// merge in icons from Font Awesome
static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
ImFontConfig icons_config;
icons_config.MergeMode = true;
icons_config.PixelSnapH = true;
// I checked the return values with my debugger, and none of these 4 return NULL
io.FontDefault = io.Fonts->AddFontFromFileTTF("Fonts/OpenSans-Regular.ttf", 18.0f);
io.Fonts->AddFontFromFileTTF("Fonts/fa-regular-400-pro.ttf", 16.0f, &icons_config, icons_ranges);
io.Fonts->AddFontFromFileTTF("Fonts/OpenSans-Bold.ttf", 18.0f);
io.Fonts->AddFontFromFileTTF("Fonts/fa-solid-900-pro.ttf", 16.0f, &icons_config, icons_ranges);
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 430");
/*
Some code regarding imgui colors, style etc.
*/
}
return context;
}
The text was updated successfully, but these errors were encountered:
Linking to #2700, #2539, #3537, #3521
In the case of font it's not really something we can easily change/fix, it would mean that potentially a single tab bar can use multiple font with varying height.
The default font at the time of NewFrame() will be used to submit docking-system tab bars.
Linking to #2700, #2539, #3537, #3521 In the case of font it's not really something we can easily change/fix, it would mean that potentially a single tab bar can use multiple font with varying height.
The default font at the time of NewFrame() will be used to submit docking-system tab bars.
I see, since I don't have access to the line where NewFrame() is called (its in my lib, and I'm using my lib in another project) there is no alternative for me other than setting the desired font as default font. Thanks for the quick reply @ocornut.
Version/Branch of Dear ImGui:
Version: 1.87
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: MSVC (Visual Studio 2019 v. 16.11.9 with C++20)
Operating System: Windows 10 @ Latest Update
My Issue/Question:
I'm pushing a font before making a call to ImGui::Begin(myTitle), but the title text is still in default font. How can I make the title use the font I pushed without making it the default font?
Screenshots/Video
Standalone, minimal, complete and verifiable example:
Here is how I load my fonts:
The text was updated successfully, but these errors were encountered: