From 707207a83d0c4e81457a5625cd6f64088c5be680 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Tue, 17 Feb 2026 10:31:30 +0100 Subject: [PATCH] Changed loadFonts() function to return the created font so you can use it to switch between fonts while rendering. --- private/raid/application.cpp | 10 +++++----- public/raid/application.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/private/raid/application.cpp b/private/raid/application.cpp index 16dd302..b2d52f0 100644 --- a/private/raid/application.cpp +++ b/private/raid/application.cpp @@ -156,7 +156,7 @@ int Application::run(int argc, char** argv) } -bool Application::loadFonts(std::span fonts) +ImFont* Application::loadFonts(std::span fonts) { ImGuiIO& imguiIO = ImGui::GetIO(); @@ -170,14 +170,14 @@ bool Application::loadFonts(std::span 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 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(); } diff --git a/public/raid/application.hpp b/public/raid/application.hpp index 774d6c8..5d00ad6 100644 --- a/public/raid/application.hpp +++ b/public/raid/application.hpp @@ -128,7 +128,7 @@ public: int run(int argc, char* argv[]); [[nodiscard]] - bool loadFonts(std::span fonts); + ImFont* loadFonts(std::span fonts); [[nodiscard]] bool loadFont(const FontConfig& font)