Changed loadFonts() function to return the created font so you can use it to switch between fonts while rendering.
This commit is contained in:
@@ -156,7 +156,7 @@ int Application::run(int argc, char** argv)
|
||||
}
|
||||
|
||||
|
||||
bool Application::loadFonts(std::span<const FontConfig> fonts)
|
||||
ImFont* Application::loadFonts(std::span<const FontConfig> fonts)
|
||||
{
|
||||
ImGuiIO& imguiIO = ImGui::GetIO();
|
||||
|
||||
@@ -170,14 +170,14 @@ bool Application::loadFonts(std::span<const FontConfig> fonts)
|
||||
error != mijin::StreamError::SUCCESS)
|
||||
{
|
||||
msgError("Error opening font file {}: {}.", font.path.generic_string(), mijin::errorName(error));
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mijin::TypelessBuffer& data = buffers.emplace_back();
|
||||
if (const mijin::StreamError readError = fontFile->readRest(data); readError != mijin::StreamError::SUCCESS)
|
||||
{
|
||||
msgError("Error reading font data from {}: {}.", font.path.generic_string(), mijin::errorName(readError));
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ bool Application::loadFonts(std::span<const FontConfig> fonts)
|
||||
|
||||
// but in that case Build() has to be run before the data gets deleted
|
||||
imguiIO.Fonts->Build();
|
||||
return true;
|
||||
return imguiIO.Fonts->Fonts.back();
|
||||
}
|
||||
|
||||
ImTextureID Application::getOrLoadTexture(fs::path path)
|
||||
@@ -839,7 +839,7 @@ bool Application::initImGui()
|
||||
// init font
|
||||
if (imguiIO.Fonts->Fonts.empty())
|
||||
{
|
||||
if (!loadFonts(getDefaultFonts()))
|
||||
if (loadFonts(getDefaultFonts()) == nullptr)
|
||||
{
|
||||
imguiIO.Fonts->AddFontDefault();
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
int run(int argc, char* argv[]);
|
||||
|
||||
[[nodiscard]]
|
||||
bool loadFonts(std::span<const FontConfig> fonts);
|
||||
ImFont* loadFonts(std::span<const FontConfig> fonts);
|
||||
|
||||
[[nodiscard]]
|
||||
bool loadFont(const FontConfig& font)
|
||||
|
||||
Reference in New Issue
Block a user