From 11bdfd3a98f285da2d806d249e7df7499747e315 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 12 Jan 2026 19:18:54 +0200 Subject: [PATCH] using new saving system but i can't understand the fallback mechanism --- src/common/config.cpp | 101 +--------------------- src/common/config.h | 11 --- src/core/libraries/font/font_internal.cpp | 7 +- 3 files changed, 5 insertions(+), 114 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 34e5524cf..eac463d0a 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -4,9 +4,8 @@ #include #include #include -#include -#include #include +#include // for wstring support #include #include "common/assert.h" @@ -145,9 +144,6 @@ static ConfigEntry isSideTrophy("right"); static ConfigEntry isConnectedToNetwork(false); static bool enableDiscordRPC = false; static std::filesystem::path sys_modules_path = {}; -static std::filesystem::path sys_font_path = {}; -static std::string sys_font_fallback_name = {}; -static std::unordered_map system_font_overrides; // Input static ConfigEntry cursorState(HideCursorState::Idle); @@ -238,44 +234,6 @@ void setSysModulesPath(const std::filesystem::path& path) { sys_modules_path = path; } -std::filesystem::path getSysFontPath() { - return sys_font_path; -} - -void setSysFontPath(const std::filesystem::path& path) { - sys_font_path = path; -} - -std::optional getSystemFontOverride(std::string_view key) { - if (key.empty()) { - return std::nullopt; - } - auto it = system_font_overrides.find(std::string(key)); - if (it == system_font_overrides.end()) { - return std::nullopt; - } - return it->second; -} - -std::string getSystemFontFallbackName() { - return sys_font_fallback_name; -} - -void setSystemFontFallbackName(const std::string& name) { - sys_font_fallback_name = name; -} - -void setSystemFontOverride(std::string_view key, const std::filesystem::path& path) { - if (key.empty()) { - return; - } - system_font_overrides[std::string(key)] = path; -} - -void clearSystemFontOverrides() { - system_font_overrides.clear(); -} - int getVolumeSlider() { return volumeSlider.get(); } @@ -904,10 +862,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { return; } - if (!is_game_specific) { - system_font_overrides.clear(); - } - if (data.contains("General")) { const toml::value& general = data.at("General"); @@ -931,43 +885,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { isConnectedToNetwork.setFromToml(general, "isConnectedToNetwork", is_game_specific); defaultControllerID.setFromToml(general, "defaultControllerID", is_game_specific); sys_modules_path = toml::find_fs_path_or(general, "sysModulesPath", sys_modules_path); - // Accept alias without trailing 's' - sys_modules_path = toml::find_fs_path_or(general, "sysModulePath", sys_modules_path); - // Prefer 'sysFontPath'; accept 'SysFontPath' for compatibility - sys_font_path = toml::find_fs_path_or(general, "sysFontPath", sys_font_path); - sys_font_path = toml::find_fs_path_or(general, "SysFontPath", sys_font_path); - } - - if (data.contains("SystemFonts")) { - const toml::value& fonts = data.at("SystemFonts"); - if (fonts.is_table()) { - // Read fallback (lowercase preferred), accept 'Fallback'/'FallbackFontName' for compat - if (fonts.contains("fallback")) { - const auto& v = fonts.at("fallback"); - if (v.is_string()) { - sys_font_fallback_name = toml::get(v); - } - } else if (fonts.contains("Fallback")) { - const auto& v = fonts.at("Fallback"); - if (v.is_string()) { - sys_font_fallback_name = toml::get(v); - } - } else if (fonts.contains("FallbackFontName")) { - const auto& v = fonts.at("FallbackFontName"); - if (v.is_string()) { - sys_font_fallback_name = toml::get(v); - } - } - for (const auto& [name, value] : fonts.as_table()) { - if (name == "fallback" || name == "Fallback" || name == "FallbackFontName") { - continue; - } - if (value.is_string()) { - system_font_overrides[name] = - std::filesystem::path(toml::get(value)); - } - } - } } if (data.contains("Input")) { @@ -1241,22 +1158,6 @@ void save(const std::filesystem::path& path, bool is_game_specific) { // Non game-specific entries data["General"]["enableDiscordRPC"] = enableDiscordRPC; data["General"]["sysModulesPath"] = string{fmt::UTF(sys_modules_path.u8string()).data}; - // Save using 'sysFontPath' to match style - data["General"]["sysFontPath"] = string{fmt::UTF(sys_font_path.u8string()).data}; - { - toml::table fonts_table; - if (!sys_font_fallback_name.empty()) { - fonts_table["fallback"] = sys_font_fallback_name; - } - for (const auto& [name, path_override] : system_font_overrides) { - fonts_table[name] = string{fmt::UTF(path_override.u8string()).data}; - } - if (!fonts_table.empty()) { - data["SystemFonts"] = fonts_table; - } else if (data.is_table()) { - data.as_table().erase("SystemFonts"); - } - } data["GUI"]["installDirs"] = install_dirs; data["GUI"]["installDirsEnabled"] = install_dirs_enabled; data["GUI"]["saveDataPath"] = string{fmt::UTF(save_data_path.u8string()).data}; diff --git a/src/common/config.h b/src/common/config.h index 9903e6e35..2a95e6cf0 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -4,8 +4,6 @@ #pragma once #include -#include -#include #include #include "types.h" @@ -155,15 +153,6 @@ 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(); -bool getLoadAutoPatches(); -void setLoadAutoPatches(bool enable); 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 ace9cdca0..84afc8b78 100644 --- a/src/core/libraries/font/font_internal.cpp +++ b/src/core/libraries/font/font_internal.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "font_internal.h" @@ -10,6 +10,7 @@ #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 { @@ -1539,7 +1540,7 @@ static std::optional FindChildDirContainingFile( } std::filesystem::path GetSysFontBaseDir() { - std::filesystem::path base = Config::getSysFontPath(); + std::filesystem::path base = EmulatorSettings::GetInstance()->GetSysFontsDir(); std::error_code ec; if (base.empty()) { LOG_ERROR(Lib_Font, "SystemFonts: SysFontPath not set"); @@ -1972,7 +1973,7 @@ std::string ReportSystemFaceRequest(FontState& st, Libraries::Font::OrbisFontHan } if (!st.system_requested) { st.system_requested = true; - const auto configured = Config::getSysFontPath(); + const auto configured = EmulatorSettings::GetInstance()->GetSysFontsDir(); return fmt::format("SystemFace: handle={} requested internal font but sysFontPath ('{}') " "could not be loaded", static_cast(handle), configured.string());