Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blurry fonts in high DPI #1065

Open
ghost opened this issue Mar 13, 2017 · 8 comments
Open

Blurry fonts in high DPI #1065

ghost opened this issue Mar 13, 2017 · 8 comments

Comments

@ghost
Copy link

ghost commented Mar 13, 2017

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

@meshula
Copy link

meshula commented Mar 14, 2017

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

@drewish
Copy link

drewish commented Mar 21, 2017

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
Copy link

Matheus28 commented Jul 20, 2017

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
Copy link

slajerek commented Dec 21, 2021

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
Copy link
Contributor

thedmd commented Dec 22, 2021

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
Copy link

@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
Copy link
Contributor

thedmd commented Jul 7, 2024

@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.

imgui/imgui.h

Line 3005 in 1ec1f7a

float RasterizerDensity; // 1.0f // DPI scale for rasterization, not altering other font metrics: make it easy to swap between e.g. a 100% and a 400% fonts for a zooming display. IMPORTANT: If you increase this it is expected that you increase font scale accordingly, otherwise quality may look lowered.

@whitequark
Copy link

whitequark commented Jul 8, 2024

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

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

No branches or pull requests

7 participants