diff options
| author | TryTwo <taolas@gmail.com> | 2025-10-02 23:22:14 -0700 |
|---|---|---|
| committer | TryTwo <taolas@gmail.com> | 2025-10-16 15:36:50 -0700 |
| commit | c135af22dde93327bc4e0c4c5b8c649cc847207e (patch) | |
| tree | 742f0383ff597665f5e9630ef5a0459dcff81ef0 /Source/Core/VideoCommon/OnScreenUI.cpp | |
| parent | e8d9c124e5290c9c02c16d83583ce82b4e57c0f2 (diff) | |
Imgui: Add a new default font (VeraMono - 49kb) that scales better than the old default.
Allow loading a custom font by naming it OSD_Font.ttf and placing the file in the User/Load folder, to load that font instead. Useful for future testing.
Diffstat (limited to 'Source/Core/VideoCommon/OnScreenUI.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/OnScreenUI.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/OnScreenUI.cpp b/Source/Core/VideoCommon/OnScreenUI.cpp index bca12bccdd..7b59450ca0 100644 --- a/Source/Core/VideoCommon/OnScreenUI.cpp +++ b/Source/Core/VideoCommon/OnScreenUI.cpp @@ -3,7 +3,9 @@ #include "VideoCommon/OnScreenUI.h" +#include "Common/CommonPaths.h" #include "Common/EnumMap.h" +#include "Common/FileUtil.h" #include "Common/Profiler.h" #include "Common/Timer.h" @@ -74,11 +76,28 @@ bool OnScreenUI::Initialize(u32 width, u32 height, float scale) } // Font defaults + ImGuiIO& io = ImGui::GetIO(); m_imgui_textures.clear(); - // Setup new font management behavior. - ImGui::GetIO().BackendFlags |= - ImGuiBackendFlags_RendererHasTextures | ImGuiBackendFlags_RendererHasVtxOffset; + // User supplied font + std::string file = File::GetUserPath(D_LOAD_IDX) + "OSD_Font.ttf"; + + bool font_exists = File::Exists(file); + if (!font_exists) + { + // Default supplied font + file = File::GetSysDirectory() + DIR_SEP + RESOURCES_DIR + DIR_SEP + "OSD_Font.ttf"; + font_exists = File::Exists(file); + } + + if (font_exists) + { + io.Fonts->Clear(); + io.Fonts->AddFontFromFileTTF(file.c_str()); + } + + // Setup new font management behavior + io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures | ImGuiBackendFlags_RendererHasVtxOffset; if (!RecompileImGuiPipeline()) return false; @@ -443,7 +462,6 @@ void OnScreenUI::UpdateImguiTexture(ImTextureData* tex) tex->SetTexID(static_cast<ImTextureID>(*font_tex.get())); // Keeps the texture alive. m_imgui_textures.push_back(std::move(font_tex)); - tex->SetStatus(ImTextureStatus_OK); } else if (tex->Status == ImTextureStatus_WantUpdates) |
