Skip to content

ImGui font rendering appears oversized on standard resolution displays #66

Description

@juanchuletas

Description

The current ImGui font setup loads a TTF font at a small fixed size and then applies FontGlobalScale to upscale it at runtime. This causes blurry text on all displays and produces inconsistent sizing across different screen types — the UI looks correct on a HiDPI OLED display but oversized on a standard 1080p laptop screen.

Root Cause

In GUI/imgui_layer.hpp, the font is loaded at 18.0f and then scaled by 1.8f globally:

io.Fonts->AddFontFromFileTTF("...Nunito-Regular.ttf", 18.0f);
io.FontGlobalScale = 1.8f;

FontGlobalScale stretches the already-rasterized font bitmap at render time. This is equivalent to zooming into a low-resolution texture — the result is blurry text. On a standard 1080p display with larger physical pixels, the upscaled text also appears disproportionately large.

Expected Behavior

Font should appear at a consistent, readable size across HiDPI and standard resolution displays, with crisp rendering on both.

Proposed Fix

Remove io.FontGlobalScale = 1.8f and load the font at the correct pixel size derived from the system DPI scale:

float xscale, yscale;
glfwGetWindowContentScale(m_window, &xscale, &yscale);
float fontSize = 16.0f * std::max(xscale, yscale);
io.Fonts->AddFontFromFileTTF("...Nunito-Regular.ttf", fontSize);
io.FontGlobalScale = 1.0f;

Files Affected

  • GUI/imgui_layer.hpponAttach(), lines 191–204

Environment

  • Works correctly on: HiDPI OLED display
  • Broken on: standard 1080p laptop display

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions