From 1c620dafbc965336c5678b24cb691a4aefb97ebb Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Thu, 12 Feb 2026 15:09:55 -0600 Subject: [PATCH] Mount system fonts Now that font LLE works, these are necessary for some titles. --- src/common/path_util.cpp | 1 + src/common/path_util.h | 2 ++ src/core/libraries/kernel/kernel.h | 1 + src/emulator.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/src/common/path_util.cpp b/src/common/path_util.cpp index b0cbb10cf..5d37990ff 100644 --- a/src/common/path_util.cpp +++ b/src/common/path_util.cpp @@ -128,6 +128,7 @@ static auto UserPaths = [] { create_path(PathType::CustomTrophy, user_dir / CUSTOM_TROPHY); create_path(PathType::CustomConfigs, user_dir / CUSTOM_CONFIGS); create_path(PathType::CacheDir, user_dir / CACHE_DIR); + create_path(PathType::FontsDir, user_dir / FONTS_DIR); std::ofstream notice_file(user_dir / CUSTOM_TROPHY / "Notice.txt"); if (notice_file.is_open()) { diff --git a/src/common/path_util.h b/src/common/path_util.h index fd2c18baa..434f77b0d 100644 --- a/src/common/path_util.h +++ b/src/common/path_util.h @@ -25,6 +25,7 @@ enum class PathType { CustomTrophy, // Where custom files for trophies are stored. CustomConfigs, // Where custom files for different games are stored. CacheDir, // Where pipeline and shader cache is stored. + FontsDir, // Where dumped system fonts are stored. }; constexpr auto PORTABLE_DIR = "user"; @@ -44,6 +45,7 @@ constexpr auto METADATA_DIR = "game_data"; constexpr auto CUSTOM_TROPHY = "custom_trophy"; constexpr auto CUSTOM_CONFIGS = "custom_configs"; constexpr auto CACHE_DIR = "cache"; +constexpr auto FONTS_DIR = "fonts"; // Filenames constexpr auto LOG_FILE = "shad_log.txt"; diff --git a/src/core/libraries/kernel/kernel.h b/src/core/libraries/kernel/kernel.h index 91fac4c71..ce6446129 100644 --- a/src/core/libraries/kernel/kernel.h +++ b/src/core/libraries/kernel/kernel.h @@ -17,6 +17,7 @@ void ErrSceToPosix(s32 result); s32 ErrnoToSceKernelError(s32 e); void SetPosixErrno(s32 e); s32* PS4_SYSV_ABI __Error(); +const char* PS4_SYSV_ABI sceKernelGetFsSandboxRandomWord(); extern Core::EntryParams entry_params; diff --git a/src/emulator.cpp b/src/emulator.cpp index 0dde0b7fa..4a1473abe 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -36,6 +36,7 @@ #include "core/libraries/font/font.h" #include "core/libraries/font/fontft.h" #include "core/libraries/jpeg/jpegenc.h" +#include "core/libraries/kernel/kernel.h" #include "core/libraries/libc_internal/libc_internal.h" #include "core/libraries/libpng/pngenc.h" #include "core/libraries/libs.h" @@ -368,6 +369,34 @@ void Emulator::Run(std::filesystem::path file, std::vector args, } VideoCore::SetOutputDir(mount_captures_dir, id); + // Mount system fonts + const auto& fonts_dir = Common::FS::GetUserPath(Common::FS::PathType::FontsDir); + if (!std::filesystem::exists(fonts_dir)) { + std::filesystem::create_directory(fonts_dir); + } + + // Fonts are mounted into the sandboxed system directory, construct the appropriate path. + const char* sandbox_root = Libraries::Kernel::sceKernelGetFsSandboxRandomWord(); + std::string guest_font_dir = "/"; + guest_font_dir.append(sandbox_root).append("/common/font"); + const auto& host_font_dir = fonts_dir / "font"; + if (!std::filesystem::exists(host_font_dir)) { + std::filesystem::create_directory(host_font_dir); + } + mnt->Mount(host_font_dir, guest_font_dir); + + // There is a second font directory, mount that too. + guest_font_dir.append("2"); + const auto& host_font2_dir = fonts_dir / "font2"; + if (!std::filesystem::exists(host_font2_dir)) { + std::filesystem::create_directory(host_font2_dir); + } + mnt->Mount(host_font2_dir, guest_font_dir); + + if (std::filesystem::is_empty(host_font_dir) || std::filesystem::is_empty(host_font2_dir)) { + LOG_WARNING(Loader, "No dumped system fonts, expect missing text or instability"); + } + // Initialize kernel and library facilities. Libraries::InitHLELibs(&linker->GetHLESymbols());