Add fonts to ImGui

This commit is contained in:
Dan Paulat 2022-11-29 10:13:47 -06:00
parent 7be3321d34
commit 5d9bf67fcc
4 changed files with 61 additions and 2 deletions

View file

@ -22,6 +22,7 @@ public:
~ImGuiContextModelImpl() = default;
std::vector<ImGuiContextInfo> contexts_ {};
ImFontAtlas fontAtlas_ {};
};
ImGuiContextModel::ImGuiContextModel() :
@ -86,7 +87,7 @@ ImGuiContext* ImGuiContextModel::CreateContext(const std::string& name)
{
static size_t nextId_ {0};
ImGuiContext* context = ImGui::CreateContext();
ImGuiContext* context = ImGui::CreateContext(&p->fontAtlas_);
ImGui::SetCurrentContext(context);
// ImGui Configuration
@ -136,6 +137,11 @@ std::vector<ImGuiContextInfo> ImGuiContextModel::contexts() const
return p->contexts_;
}
ImFontAtlas* ImGuiContextModel::font_atlas()
{
return &p->fontAtlas_;
}
ImGuiContextModel& ImGuiContextModel::Instance()
{
static ImGuiContextModel instance_ {};

View file

@ -5,6 +5,7 @@
#include <QAbstractListModel>
struct ImFontAtlas;
struct ImGuiContext;
namespace scwx
@ -46,6 +47,7 @@ public:
void DestroyContext(const std::string& name);
std::vector<ImGuiContextInfo> contexts() const;
ImFontAtlas* font_atlas();
static ImGuiContextModel& Instance();