Use a TTF font for fixed-width text in the debugger

Fixes #20635
This commit is contained in:
Henrik Rydgård
2025-07-16 20:20:33 +02:00
parent ccdf534188
commit 5f8ee93006
5 changed files with 26 additions and 9 deletions
+5 -3
View File
@@ -1822,11 +1822,13 @@ void EmuScreen::runImDebugger() {
imDebugger_ = std::make_unique<ImDebugger>();
// Read the TTF font
size_t size = 0;
uint8_t *fontData = g_VFS.ReadFile("Roboto-Condensed.ttf", &size);
size_t propSize = 0;
uint8_t *propFontData = g_VFS.ReadFile("Roboto-Condensed.ttf", &propSize);
size_t fixedSize = 0;
uint8_t *fixedFontData = g_VFS.ReadFile("Inconsolata-Medium.ttf", &fixedSize);
// This call works even if fontData is nullptr, in which case the font just won't get loaded.
// This takes ownership of the font array.
ImGui_ImplThin3d_Init(draw, fontData, size);
ImGui_ImplThin3d_Init(draw, propFontData, propSize, fixedFontData, fixedSize);
imguiInited_ = true;
}
+3
View File
@@ -381,6 +381,9 @@ void WaitIDToString(WaitType waitType, SceUID waitID, char *buffer, size_t bufSi
case WAITTYPE_MICINPUT:
truncate_cpy(buffer, bufSize, "-");
return;
case WAITTYPE_CTRL:
snprintf(buffer, bufSize, "ctrl: %d", waitID);
return;
default:
truncate_cpy(buffer, bufSize, "(unimpl)");
return;
Binary file not shown.
+15 -5
View File
@@ -290,15 +290,25 @@ void ImGui_ImplThin3d_DestroyDeviceObjects() {
}
}
bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw, const uint8_t *ttf_font, size_t size) {
bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw,
const uint8_t *ttf_font_proportional, size_t proportional_size,
const uint8_t *ttf_font_fixed, size_t fixed_size) {
ImGuiIO& io = ImGui::GetIO();
if (ttf_font) {
g_proportionalFont = io.Fonts->AddFontFromMemoryTTF((void *)ttf_font, (int)size, 21.0f / g_display.dpi_scale_x, nullptr, io.Fonts->GetGlyphRangesDefault());
g_proportionalFont = nullptr;
if (ttf_font_proportional) {
g_proportionalFont = io.Fonts->AddFontFromMemoryTTF((void *)ttf_font_proportional, (int)proportional_size, 21.0f / g_display.dpi_scale_x, nullptr, io.Fonts->GetGlyphRangesDefault());
}
if (ttf_font_fixed) {
g_fixedFont = io.Fonts->AddFontFromMemoryTTF((void *)ttf_font_fixed, (int)fixed_size, 20.0f / g_display.dpi_scale_x, nullptr, io.Fonts->GetGlyphRangesDefault());
} else {
// fallback
g_fixedFont = io.Fonts->AddFontDefault();
}
if (!g_proportionalFont) {
g_proportionalFont = g_fixedFont;
}
g_fixedFont = io.Fonts->AddFontDefault();
// g_fixedFont = io.Fonts->AddFontDefault();
ImGui::GetStyle().ScaleAllSizes(1.0f / g_display.dpi_scale_x);
ImGui::GetStyle().Colors[ImGuiCol_Border] = ImColor(IM_COL32(0x2A, 0x2F, 0x3B, 0xFF));
+3 -1
View File
@@ -34,7 +34,9 @@
#include "Common/Math/lin/matrix4x4.h"
// Called by user code. Takes ownership of the font buffer and later deletes it.
IMGUI_IMPL_API bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw, const uint8_t *ttf_font, size_t size);
IMGUI_IMPL_API bool ImGui_ImplThin3d_Init(Draw::DrawContext *draw,
const uint8_t *ttf_font_proportional, size_t proportional_size,
const uint8_t *ttf_font_fixed, size_t fixed_size);
IMGUI_IMPL_API void ImGui_ImplThin3d_Shutdown();
IMGUI_IMPL_API void ImGui_ImplThin3d_NewFrame(Draw::DrawContext *draw, Lin::Matrix4x4 drawMatrix);
IMGUI_IMPL_API void ImGui_ImplThin3d_RenderDrawData(ImDrawData* draw_data, Draw::DrawContext *draw);