Cannot load a font during frame rendering
XMNXofficial opened this issue · comments
Hellođź‘‹!
I want to load a ttf font into hello_imgui,but it can't work;
void Draw()
{
ImFont* font1; ImFont* font1;
static bool bool1 = true;
if (bool1)
{
font1 = HelloImGui::LoadFontTTF_WithFontAwesomeIcons(
"/usr/share/fonts/truetype/ms-core-fonts/AndaleMo.TTF", 25.0f);
bool1 = false;
}
ImGui::PushFont(font1);
ImGui::Text("Hello");
ImGui::PopFont();
⬇⬇It likely load success,but it show "unknown".
And when i select it,my program will crash ( show: 18762 segmentation fault (core dumped) ./hello_world ).
Hi,
Thanks for sharing your demo code, it makes it easier to answer.
Fonts need to be loaded at the appropriate moment during initialization. I updated a demo example to showcase how to load fonts.
First, you will need to create a function (or lambda) for loading the font:
Then, you need to use RunnerParams and fill the correct callback:
And then use the font:
Thank you very much for your great help!