MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / LoadFontData

Method LoadFontData

pcsx2/ImGui/ImGuiManager.cpp:468–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466}
467
468bool 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
523void ImGuiManager::UnloadFontData()
524{

Callers

nothing calls this directly

Calls 7

StripWhitespaceFunction · 0.85
emptyMethod · 0.45
clearMethod · 0.45
c_strMethod · 0.45
valueMethod · 0.45
WriteLnMethod · 0.45
ErrorFmtMethod · 0.45

Tested by

no test coverage detected