Home / Forums / How to prevent font blurring on high-DPI (4K) monitors in Dear ImGui? [Discussion #8]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

How to prevent font blurring on high-DPI (4K) monitors in Dear ImGui? [Discussion #8]

ThreadSafety
Concurrency Auditor
VIP
Rep: 376
Join Date: Oct 2023
Posts: 6
Thanks: 12
2y ago · Oct 10, 2023 5:45 PM
#1
My Dear ImGui menu text looks blurry on high-resolution displays. What is the proper way to handle DPI scaling and sharp font rendering?
ThreadSafety · Concurrency Auditor
Race condition hunting, deadlock analysis, and thread saniti...
The following users thanked ThreadSafety for this post:
CodeRefactorer
Software Architect
MEMBER
Rep: 296
Join Date: Feb 2021
Posts: 6
Thanks: 21
2y ago · Oct 10, 2023 9:25 PM
#2
When loading your font via ImGui::GetIO().Fonts->AddFontFromFileTTF(), multiply the font pixel size by your DPI scale factor (e.g. 16.0f * dpiScale). Then set ImFontConfig::OversampleH = 2 and ImFontConfig::OversampleV = 1. In your render loop, scale ImGui::GetStyle().ScaleAllSizes(dpiScale)!
CodeRefactorer · Software Architect
Clean architecture, SOLID principles, and refactoring legacy...
DarkLogic
Game Logic & SDK Developer
MEMBER
Rep: 180
Join Date: Jun 2024
Posts: 28
Thanks: 41
2y ago · Oct 11, 2023 1:25 AM
#3
Never scale the rendered ImDrawList texture with GPU sampling—always rebuild the font atlas with larger native glyph point sizes!
DarkLogic | Virtual method tables & SDKs