From a6484150bfcfde3bc2e468d308368debabf8953e Mon Sep 17 00:00:00 2001 From: w1naenator Date: Fri, 16 Jan 2026 16:59:39 +0200 Subject: [PATCH] Add system font path management functions and refactor font directory retrieval --- src/common/config.h | 10 ++++++++++ src/core/libraries/font/font_internal.cpp | 13 +++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/common/config.h b/src/common/config.h index 2a95e6cf0..bf7cce162 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -4,6 +4,9 @@ #pragma once #include +#include +#include +#include #include #include "types.h" @@ -153,6 +156,13 @@ void setConnectedToNetwork(bool enable, bool is_game_specific = false); void setUserName(const std::string& name, bool is_game_specific = false); std::filesystem::path getSysModulesPath(); void setSysModulesPath(const std::filesystem::path& path); +std::filesystem::path getSysFontPath(); +void setSysFontPath(const std::filesystem::path& path); +std::optional getSystemFontOverride(std::string_view key); +std::string getSystemFontFallbackName(); +void setSystemFontFallbackName(const std::string& name); +void setSystemFontOverride(std::string_view key, const std::filesystem::path& path); +void clearSystemFontOverrides(); enum UsbBackendType : int { Real, SkylandersPortal, InfinityBase, DimensionsToypad }; int getUsbDeviceBackend(); diff --git a/src/core/libraries/font/font_internal.cpp b/src/core/libraries/font/font_internal.cpp index 11a3c85fc..962181e50 100644 --- a/src/core/libraries/font/font_internal.cpp +++ b/src/core/libraries/font/font_internal.cpp @@ -10,7 +10,6 @@ #include FT_OUTLINE_H #include FT_TRUETYPE_TABLES_H -#include "core/emulator_settings.h" #include "core/libraries/font/fontft_internal.h" namespace Libraries::Font::Internal { @@ -1560,7 +1559,7 @@ static std::optional FindChildDirContainingFile( } std::filesystem::path GetSysFontBaseDir() { - std::filesystem::path base = EmulatorSettings::GetInstance()->GetSysFontsDir(); + std::filesystem::path base = Config::getSysFontPath(); std::error_code ec; if (base.empty()) { LOG_ERROR(Lib_Font, "SystemFonts: SysFontPath not set"); @@ -1572,9 +1571,11 @@ std::filesystem::path GetSysFontBaseDir() { } { - const auto preferred = base / "font"; - if (DirectoryContainsAnyFontFiles(preferred)) { - return preferred; + const auto font_dir = base / "font"; + const auto font2_dir = base / "font2"; + if (DirectoryContainsAnyFontFiles(font_dir) || + DirectoryContainsAnyFontFiles(font2_dir)) { + return base; } } @@ -1993,7 +1994,7 @@ std::string ReportSystemFaceRequest(FontState& st, Libraries::Font::OrbisFontHan } if (!st.system_requested) { st.system_requested = true; - const auto configured = EmulatorSettings::GetInstance()->GetSysFontsDir(); + const auto configured = Config::getSysFontPath(); return fmt::format("SystemFace: handle={} requested internal font but sysFontPath ('{}') " "could not be loaded", static_cast(handle), configured.string());