From 3bac3051fc03846f5461628ba6a1b1f19851657c Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 11 Sep 2018 03:31:01 +0200 Subject: Use open-source shared fonts if no dumped file is available (#1269) * Add open-source shared fonts * Address review comments --- src/core/CMakeLists.txt | 2 +- src/core/hle/service/ns/pl_u.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7ddc87539..26f727d96 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -388,7 +388,7 @@ add_library(core STATIC create_target_directory_groups(core) target_link_libraries(core PUBLIC common PRIVATE audio_core video_core) -target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt lz4_static mbedtls opus unicorn) +target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt lz4_static mbedtls opus unicorn open_source_archives) if (ARCHITECTURE_x86_64) target_sources(core PRIVATE diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index 878bbe439..77f635ae2 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp @@ -2,6 +2,13 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include +#include +#include +#include +#include + #include "common/common_paths.h" #include "common/file_util.h" #include "core/core.h" @@ -218,7 +225,24 @@ PL_U::PL_U() : ServiceFramework("pl:u") { file.ReadBytes(shared_font->data(), shared_font->size()); BuildSharedFontsRawRegions(*shared_font); } else { - LOG_WARNING(Service_NS, "Unable to load shared font: {}", filepath); + LOG_WARNING(Service_NS, + "Shared Font file missing. Loading open source replacement from memory"); + + const std::vector> open_source_shared_fonts_ttf = { + {std::begin(FontChineseSimplified), std::end(FontChineseSimplified)}, + {std::begin(FontChineseTraditional), std::end(FontChineseTraditional)}, + {std::begin(FontExtendedChineseSimplified), + std::end(FontExtendedChineseSimplified)}, + {std::begin(FontNintendoExtended), std::end(FontNintendoExtended)}, + {std::begin(FontStandard), std::end(FontStandard)}, + }; + + for (const std::vector& font_ttf : open_source_shared_fonts_ttf) { + const FontRegion region{static_cast(offset + 8), + static_cast(font_ttf.size())}; + EncryptSharedFont(font_ttf, *shared_font, offset); + SHARED_FONT_REGIONS.push_back(region); + } } } } -- cgit v1.2.3