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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

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

BoneMatrix_
CS2 & Skeleton Math
MEMBER
Rep: 190
Join Date: Aug 2024
Posts: 21
Thanks: 47
6y ago · Jul 10, 2020 7:18 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?
BoneMatrix_ · Source 2 Skeleton ESP & Hitboxes
The following users thanked BoneMatrix_ for this post:
CitizenNative
RAGE Engine & FiveM Dev
VIP
Rep: 315
Join Date: Sep 2022
Posts: 21
Thanks: 82
6y ago · Jul 10, 2020 8:46 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)!
CitizenNative | RAGE Engine & FiveM Native Calls
DisasmGeek
Capstone & Keystone Specialist
MEMBER
Rep: 160
Join Date: Dec 2024
Posts: 21
Thanks: 38
6y ago · Jul 11, 2020 12:46 AM
#3
Never scale the rendered ImDrawList texture with GPU sampling—always rebuild the font atlas with larger native glyph point sizes!
DisasmGeek · Capstone / Keystone Engine Integration