Display issue with custom font


#1

I’m currently working on a sample app using Magnum and Dear ImGui to use as a base for a project I’m contributing to.

Since I want to use a custom font, I use the following code to load it:

ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontFromFileTTF("font.ttf",
                             16.0f,
                             nullptr,
                             io.Fonts->GetGlyphRangesDefault());
io.Fonts->Build();

But when I run my app, I’m greeted with this:
image

Should I use an ImFontConfig object to fix it, or should I do something else ?

EDIT: I forget to add that I actually check if the returned pointer is equal to nullptr or not, and if Build()'s return value is true.


#2

I don’t know how your Magnum binding works, but you will need to upload the new texture to the GPU. It is possible that this is the effect of building the atlas with a new font but using the previous texture that the Magnum binding uploaded by default.

(You can loading the same font in one of the examples/ of the imgui repository and it’ll probably work…)


#3

Thanks for your answer!

I don’t know why I didn’t think of looking at the binding’s source for that part. :man_facepalming:

I’ll try copying how it’s done.