Add system font path management functions and refactor font directory retrieval

This commit is contained in:
w1naenator 2026-01-16 16:59:39 +02:00
parent e3d401cf37
commit a6484150bf
2 changed files with 17 additions and 6 deletions

View File

@ -4,6 +4,9 @@
#pragma once
#include <filesystem>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
#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<std::filesystem::path> 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();

View File

@ -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<std::filesystem::path> 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<const void*>(handle), configured.string());