overlay: Fixes

- Add fallback fonts including attempting to find glyphs in dev_flash
- Fix vulkan hang on startup if icons are not present
This commit is contained in:
kd-11 2018-01-18 13:14:55 +03:00
parent 9ec2337192
commit 1a6e53ec98
2 changed files with 20 additions and 7 deletions

View File

@ -532,7 +532,7 @@ namespace vk
const VkImageSubresourceRange range = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 };
auto tex = std::make_unique<vk::image>(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);

View File

@ -117,9 +117,10 @@ namespace rsx
{
//Init glyph
std::vector<u8> bytes;
std::vector<std::string> 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;