ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.4k stars 10.12k forks source link

Blurry fonts in high DPI #1065

Open ghost opened 7 years ago

ghost commented 7 years ago

Hello. I tried use scaling in IMGui but seen that font too blurry. Also test window not scaling.

meshula commented 7 years ago

You have to ask for double-sized fonts. Instead of asking for a size of 10, ask for 20, etc.

drewish commented 7 years ago

Yeah I'd hoped that IO.FontGlobalScale would be applied when the font's texture is built, but it's applied afterwards and scales the texture. You can't rely on the default font since you'll need to pass in a size.

Matheus28 commented 7 years ago

A workaround for this is to add a font other than the default and setting OversampleH and OversampleH to something high, I use 3 for both. It looks pretty smooth in here.

slajerek commented 2 years ago

This is still not resolved. I literally tried everything, default stb backend supports oversample which is in some cases even looking good, but not nice hinting in small font sizes. FreeType with oversampling, has nice hinting but oversampling does not work, as FreeType does not support oversampling and gives blurry fonts. How to make fonts look good on macOS with High DPI with FreeType? How to add oversampling to FreeType renderer?

thedmd commented 2 years ago

You don't need to change your font size, which will screw your layout. What you need is to increase resolution of generated font atlas. And that is what ImFontConfig::Density is for.

You can cherry pick patch to ImGui & FreeType atlas builder that add ImFontConfig::Density support from my feature/hidpi-support branch.

Note: Oversampling afaik is here to fight artifacts on small fonts rendered with stb_truetype. It it not suited to change atlas density.

MacBook iPad
MacBook@2 iPad@2
whitequark commented 2 months ago

@thedmd Do you have any plans to upstream the font density patch? (If not I might pick it up myself if it works well for me.)

thedmd commented 2 months ago

@whitequark Ability to control density was merged into ImGui about 8 months ago. I forgot about this thread, so I will take the opportunity now to mention it. :)

You can control density with RasterizationDensity.

https://github.com/ocornut/imgui/blob/1ec1f7a3de2ce96bee58b2825917707cc1b7c17c/imgui.h#L3005

whitequark commented 2 months ago

Thanks! This has sent me to a 7-hour-long rabbit hole of updating the Rust bindings...