| 466 | } |
| 467 | |
| 468 | bool ImGuiManager::LoadFontData() |
| 469 | { |
| 470 | const std::string custom_font_path(StringUtil::StripWhitespace(GSConfig.OsdFontPath)); |
| 471 | if (custom_font_path.empty()) |
| 472 | { |
| 473 | s_custom_font_data.clear(); |
| 474 | } |
| 475 | else |
| 476 | { |
| 477 | std::optional<std::vector<u8>> font_data = FileSystem::ReadBinaryFile(custom_font_path.c_str()); |
| 478 | if (font_data.has_value()) |
| 479 | { |
| 480 | s_custom_font_data = std::move(font_data.value()); |
| 481 | Console.WriteLn("Using custom OSD font '%s'.", custom_font_path.c_str()); |
| 482 | } |
| 483 | else |
| 484 | { |
| 485 | Console.ErrorFmt("Failed to load custom OSD font '{}'", custom_font_path); |
| 486 | s_custom_font_data.clear(); |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | if (s_fixed_font_data.empty()) |
| 491 | { |
| 492 | std::optional<std::vector<u8>> font_data = FileSystem::ReadBinaryFile( |
| 493 | EmuFolders::GetOverridableResourcePath("fonts" FS_OSPATH_SEPARATOR_STR "RobotoMono-Medium.ttf").c_str()); |
| 494 | if (!font_data.has_value()) |
| 495 | return false; |
| 496 | |
| 497 | s_fixed_font_data = std::move(font_data.value()); |
| 498 | } |
| 499 | |
| 500 | if (s_icon_fa_font_data.empty()) |
| 501 | { |
| 502 | std::optional<std::vector<u8>> font_data = |
| 503 | FileSystem::ReadBinaryFile(EmuFolders::GetOverridableResourcePath("fonts" FS_OSPATH_SEPARATOR_STR "fa-solid-900.ttf").c_str()); |
| 504 | if (!font_data.has_value()) |
| 505 | return false; |
| 506 | |
| 507 | s_icon_fa_font_data = std::move(font_data.value()); |
| 508 | } |
| 509 | |
| 510 | if (s_icon_pf_font_data.empty()) |
| 511 | { |
| 512 | std::optional<std::vector<u8>> font_data = |
| 513 | FileSystem::ReadBinaryFile(EmuFolders::GetOverridableResourcePath("fonts" FS_OSPATH_SEPARATOR_STR "promptfont.otf").c_str()); |
| 514 | if (!font_data.has_value()) |
| 515 | return false; |
| 516 | |
| 517 | s_icon_pf_font_data = std::move(font_data.value()); |
| 518 | } |
| 519 | |
| 520 | return true; |
| 521 | } |
| 522 | |
| 523 | void ImGuiManager::UnloadFontData() |
| 524 | { |