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

View File

@@ -3,7 +3,7 @@
// for use with https://github.com/google/material-design-icons/blob/master/font/MaterialIcons-Regular.ttf
#pragma once
#define FONT_ICON_FILE_NAME_MD "assets/font/MaterialIcons-Regular.ttf"
#define FONT_ICON_FILE_NAME_MD "MaterialIcons-Regular.ttf"
#define ICON_MIN_MD 0xe000
#define ICON_MAX_MD 0x10fffd