Add ReloadPackageFonts

This commit is contained in:
Justin Scofield
2025-01-05 20:54:56 -05:00
parent f625fc94b3
commit 5e0fb9e36e
3 changed files with 15 additions and 1 deletions

View File

@@ -134,6 +134,18 @@ absl::Status LoadPackageFonts() {
return absl::OkStatus();
}
absl::Status ReloadPackageFont(const FontConfig& config) {
ImGuiIO& io = ImGui::GetIO();
std::string actual_font_path = SetFontPath(config.font_path);
if (!io.Fonts->AddFontFromFileTTF(actual_font_path.data(), config.font_size)) {
return absl::InternalError(
absl::StrFormat("Failed to load font from %s", actual_font_path));
}
RETURN_IF_ERROR(AddIconFont());
RETURN_IF_ERROR(AddJapaneseFont());
return absl::OkStatus();
}
#ifdef _WIN32
#include <Windows.h>

View File

@@ -13,6 +13,8 @@ struct FontConfig {
absl::Status LoadPackageFonts();
absl::Status ReloadPackageFont(const FontConfig& config);
void LoadSystemFonts();
} // namespace core