Mount system fonts

Now that font LLE works, these are necessary for some titles.
This commit is contained in:
Stephen Miller 2026-02-12 15:09:55 -06:00
parent cdafdb7443
commit 1c620dafbc
4 changed files with 33 additions and 0 deletions

View File

@ -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()) {

View File

@ -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";

View File

@ -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;

View File

@ -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<std::string> 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());