From 1a6e53ec98fc14e93a865a09bfbce2f859af5f75 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Thu, 18 Jan 2018 13:14:55 +0300 Subject: [PATCH] overlay: Fixes - Add fallback fonts including attempting to find glyphs in dev_flash - Fix vulkan hang on startup if icons are not present --- rpcs3/Emu/RSX/VK/VKOverlays.h | 2 +- rpcs3/Emu/RSX/overlay_controls.h | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/VKOverlays.h b/rpcs3/Emu/RSX/VK/VKOverlays.h index dec6017f7f..2d02d3ccea 100644 --- a/rpcs3/Emu/RSX/VK/VKOverlays.h +++ b/rpcs3/Emu/RSX/VK/VKOverlays.h @@ -532,7 +532,7 @@ namespace vk const VkImageSubresourceRange range = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }; auto tex = std::make_unique(dev, memory_types.device_local, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, - VK_IMAGE_TYPE_2D, format, w, h, 1, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_TYPE_2D, format, std::max(w, 1), std::max(h, 1), 1, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, 0); diff --git a/rpcs3/Emu/RSX/overlay_controls.h b/rpcs3/Emu/RSX/overlay_controls.h index 67482c120a..0c533ae239 100644 --- a/rpcs3/Emu/RSX/overlay_controls.h +++ b/rpcs3/Emu/RSX/overlay_controls.h @@ -117,9 +117,10 @@ namespace rsx { //Init glyph std::vector bytes; + std::vector fallback_fonts; #ifdef _WIN32 std::string font_dir = "C:/Windows/Fonts/"; - std::string fallback_font = "C:/Windows/Fonts/Arial.ttf"; + fallback_fonts.push_back("C:/Windows/Fonts/Arial.ttf"); #else char *home = getenv("HOME"); if (home == nullptr) @@ -131,19 +132,31 @@ namespace rsx else font_dir += "/.fonts/"; - std::string fallback_font = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"; + fallback_fonts.push_back("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"); //ubuntu + fallback_fonts.push_back("/usr/share/fonts/TTF/DejaVuSans.ttf"); //arch #endif + //Also attempt to load from dev_flash as a last resort + fallback_fonts.push_back(fs::get_config_dir() + "dev_flash/data/font/SCE-PS3-VR-R-LATIN.TTF"); + std::string requested_file = font_dir + ttf_name + ".ttf"; std::string file_path = requested_file; if (!fs::is_file(requested_file)) { - if (fs::is_file(fallback_font)) + bool font_found = false; + for (auto &fallback_font : fallback_fonts) { - //TODO: Multiple fallbacks - file_path = fallback_font; + if (fs::is_file(fallback_font)) + { + file_path = fallback_font; + font_found = true; + + LOG_NOTICE(RSX, "Found font file '%s' as a replacement for '%s'", fallback_font.c_str(), ttf_name); + break; + } } - else + + if (!font_found) { LOG_ERROR(RSX, "Failed to initialize font '%s.ttf'", ttf_name); return;