Font loading before rendering #7289
Closed
wusikijeronii
started this conversation in
Build/Link/Run/Fonts issues ONLY!
Replies: 1 comment 1 reply
-
Yes and no. You can build the font atlas and associated data before You can however use Here's an example: ImGuiIO& io = ImGui::GetIO();
io.Fonts->Build();
ImFont* font = io.Fonts->Fonts[0];
ImVec2 size = font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.f, "Hello, world!"); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I cache some data during the resources preparation stage to reduce the number of calls per frame. Today I ran into an error trying to get the text size. To determine the size, I use the
ImGui::CalcTextSize
function. But as I found out, it uses font data (which is logical), but this font itself is not loaded at the initialization stage (through theAddFontFromFileTTF
function), and it is NULL. Initialization occurs in the first frame. Is there a way to load the font before the first call toImGui::New Frame
? I will add that for non-GUI tasks, I use my implementation of text atlases. And I prepare the data in advance. So I don't see a problem with that.Beta Was this translation helpful? Give feedback.
All reactions