GithubHelp home page GithubHelp logo

Comments (2)

pthom avatar pthom commented on May 21, 2024 2

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:

// Demonstrate how to load additional fonts (fonts - part 1/3)
ImFont * gCustomFont = nullptr;
void MyLoadFonts()
{
HelloImGui::ImGuiDefaultSettings::LoadDefaultFont_WithFontAwesomeIcons(); // The font that is loaded first is the default font
gCustomFont = HelloImGui::LoadFontTTF("fonts/Akronim-Regular.ttf", 40.f); // will be loaded from the assets folder
}

Then, you need to use RunnerParams and fill the correct callback:

HelloImGui::RunnerParams params;
params.appWindowParams.windowGeometry.size = {1280, 720};
params.appWindowParams.windowTitle = "Dear ImGui example with 'Hello ImGui'";
params.imGuiWindowParams.defaultImGuiWindowType = HelloImGui::DefaultImGuiWindowType::NoDefaultWindow;
// Fonts need to be loaded at the appropriate moment during initialization (fonts - part 2/3)
params.callbacks.LoadAdditionalFonts = MyLoadFonts; // LoadAdditionalFonts is a callback that we set with our own font loading function

And then use the font:

// Demo custom font usage (fonts - part 3/3)
ImGui::PushFont(gCustomFont);
ImGui::Text("Custom font");
ImGui::PopFont();

from hello_imgui.

XMNXofficial avatar XMNXofficial commented on May 21, 2024

Thank you very much for your great help!

from hello_imgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.