ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.41k stars 10.12k forks source link

Can't PushFont, even though I've called "AddFontFromFileTTF" and "Build" #3621

Open FlogramMatt opened 3 years ago

FlogramMatt commented 3 years ago

Version/Branch of Dear ImGui:

Dear ImGui 1.79 (17900)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201402
define: _WIN32
define: _WIN64
define: _MSC_VER=1928
define: __clang_version__=10.0.0 
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000000
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMemoryCompactTimer = 60.0f
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_implopengl3.cpp (or specify if using a custom engine/back-end)_ Compiler: Clang Operating System: Windows 10

My Issue/Question:

Can't PushFont, even though I've called "AddFontFromFileTTF" and "Build"

Interestingly if I run the same code but remove "PushFont", it seems to be loading the font correctly, Which is fine for me but still a bug, so I'll leave this open.

One other issue though, font seems a little blurry.

Screenshots/Video

Standalone, minimal, complete and verifiable example: (see https://github.com/ocornut/imgui/issues/2261)

ImFontAtlas customFonts;

    ImFont* pFont = customFonts.AddFontFromFileTTF("JetBrainsMonoNL-Regular.ttf", 12.0f);//font_filepath.c_str(), 12.0f);
    customFonts.Build();

    ImGui::CreateContext(&customFonts);
    ImGui::PushFont(pFont);

    ImGuiIO& io = ImGui::GetIO(); (void)io;
ocornut commented 3 years ago

Can't PushFont

You are not providing any information about this. As instructed in the issue guidelines, if something asserts or crash please provide detailed information about what's happening.

I believe PushFont() needs to be called during the imgui frame so after NewFrame()