Refactor font loading: remove redundant icon and Japanese font configurations, and introduce FontState structure for better font management
This commit is contained in:
@@ -98,21 +98,6 @@ absl::Status AddJapaneseFont() {
|
||||
absl::Status LoadPackageFonts() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
// Icon configuration
|
||||
static const ImWchar icons_ranges[] = {ICON_MIN_MD, 0xf900, 0};
|
||||
ImFontConfig icons_config;
|
||||
icons_config.MergeMode = true;
|
||||
icons_config.GlyphOffset.y = 5.0f;
|
||||
icons_config.GlyphMinAdvanceX = 13.0f;
|
||||
icons_config.PixelSnapH = true;
|
||||
|
||||
// Japanese font configuration
|
||||
ImFontConfig japanese_font_config;
|
||||
japanese_font_config.MergeMode = true;
|
||||
icons_config.GlyphOffset.y = 5.0f;
|
||||
icons_config.GlyphMinAdvanceX = 13.0f;
|
||||
icons_config.PixelSnapH = true;
|
||||
|
||||
// List of fonts to be loaded
|
||||
std::vector<const char*> font_paths = {
|
||||
KARLA_REGULAR, ROBOTO_MEDIUM, COUSINE_REGULAR, IBM_PLEX_JP, DROID_SANS};
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
#ifndef YAZE_APP_CORE_PLATFORM_FONTLOADER_H
|
||||
#define YAZE_APP_CORE_PLATFORM_FONTLOADER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace core {
|
||||
|
||||
struct FontConfig {
|
||||
const char* font_path;
|
||||
float font_size;
|
||||
ImFontConfig im_font_config;
|
||||
ImFontConfig jp_conf_config;
|
||||
};
|
||||
|
||||
struct FontState {
|
||||
std::vector<FontConfig> fonts;
|
||||
};
|
||||
|
||||
static FontState global_font_state;
|
||||
|
||||
absl::Status LoadPackageFonts();
|
||||
|
||||
absl::Status ReloadPackageFont(const FontConfig& config);
|
||||
|
||||
Reference in New Issue
Block a user