-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Fonts at runtime after initial initiation? #2311
Comments
Hello, You need to rebuild the atlas if you add new fonts. Atlas needs to be rebuilt before NewFrame(). |
I can't rebuild Atlas in runtime? |
Yes you can.. just call Fonts->Build() et Fonts->GetTexDataAsXXX() and reupload the texture.. |
Hello, I am trying to implement similar feature but does not seem to work. I call
Is there any missing function call? You mention "reupload the texture", but I have no idea on how to do this. EDIT: Adding call to |
Good to hear! |
While ok once in a while, For those who want more optimal use of CPU, AND feel ready to modify the imgui_impl_dx11.cpp (not a big deal) hereafter a suggestion: For good reason (at least to ease avoiding resources leak) the
Usage:
|
#3761 will provide a more generic solution to this. |
Yes! In DX11 far more elegant use of Suggestion: At least reject (even if silently in release) the |
I solving this problem in OpenGL thanks to this code (and without Build function):
Hope that this can help |
I am also running into trouble updating fonts at runtime. To me, this seems sufficient:
However, this is not working. I also consulted the PR above (https://github.com/ocornut/imgui/pull/3761/files#), and it appears that the GL3 implementation is doing just what I describe. Could you help me understand what I am missing? Thank you kindly! |
This works. I think this is too low level and requires users to know deep implementation details. I want to change the default font, but it doesn't mean that I know how the whole ImGui and DirectX work. I think we as users shouldn't concern ourselves with such low level implementation details. ImGui::GetIO().FontDefault = ImGui::GetIO().Fonts->AddFontFromFileTTF(fontPath, sizePixels); To set the default font. And let the framework invalidate objects, build fonts, recreate font textures, etc as they're required? |
Hi!
Hope format is correct and I'll go straight to the matter / deleted most of the format for things I don't have. I've been looking at related issues but I didn't see anyone trying this.
Version:
// dear imgui, v1.67 WIP
Branch: master
My Question:
Is it even possible to use io.Fonts->AddFontFromFileTTF(filePath.c_str(), fontSize); at runtime after the initial initiation of ImGui?
It does load the font but doesn't build the atlas somehow: when I try to use the loaded font, it throws an error at,
IM_ASSERT(font && font->IsLoaded());
in ImGui::SetCurrentFont(ImFont* font) when trying to use ImGui::PushFont(ImFont* font)
Thank you for your time.
The text was updated successfully, but these errors were encountered: