Cleanup font magic generation code

This commit is contained in:
Billy Laws 2022-09-22 21:32:54 +01:00
parent 5c4cc3d51f
commit 0d4893c448

View File

@ -40,10 +40,6 @@ namespace skyline::service::pl {
auto fontsDirectory{std::make_shared<vfs::OsFileSystem>(state.os->publicAppFilesPath + "fonts/")}; auto fontsDirectory{std::make_shared<vfs::OsFileSystem>(state.os->publicAppFilesPath + "fonts/")};
auto ptr{reinterpret_cast<u32 *>(sharedFontMemory->host.data())}; auto ptr{reinterpret_cast<u32 *>(sharedFontMemory->host.data())};
for (auto &font : fonts) { for (auto &font : fonts) {
*ptr++ = 0x18029a7f;
*ptr++ = util::SwapEndianness(font.length ^ 0x49621806);
font.offset = static_cast<u32>(reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(sharedFontMemory->host.data()));
std::shared_ptr<vfs::Backing> fontFile; std::shared_ptr<vfs::Backing> fontFile;
if (fontsDirectory->FileExists(font.path)) if (fontsDirectory->FileExists(font.path))
fontFile = fontsDirectory->OpenFile(font.path); fontFile = fontsDirectory->OpenFile(font.path);
@ -51,6 +47,10 @@ namespace skyline::service::pl {
fontFile = state.os->assetFileSystem->OpenFile("fonts/" + font.path); fontFile = state.os->assetFileSystem->OpenFile("fonts/" + font.path);
font.length = static_cast<u32>(fontFile->size); font.length = static_cast<u32>(fontFile->size);
*ptr++ = util::SwapEndianness(SharedFontResult);
*ptr++ = util::SwapEndianness(font.length ^ SharedFontKey);
font.offset = static_cast<u32>(reinterpret_cast<uintptr_t>(ptr) - reinterpret_cast<uintptr_t>(sharedFontMemory->host.data()));
fontFile->Read(span<u8>(reinterpret_cast<u8 *>(ptr), font.length)); fontFile->Read(span<u8>(reinterpret_cast<u8 *>(ptr), font.length));
ptr = reinterpret_cast<u32 *>(reinterpret_cast<u8 *>(ptr) + font.length); ptr = reinterpret_cast<u32 *>(reinterpret_cast<u8 *>(ptr) + font.length);
} }