Open ghost opened 7 years ago
You have to ask for double-sized fonts. Instead of asking for a size of 10, ask for 20, etc.
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.
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.
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?
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 |
---|---|
@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.)
@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
Thanks! This has sent me to a 7-hour-long rabbit hole of updating the Rust bindings...
Hello. I tried use scaling in IMGui but seen that font too blurry. Also test window not scaling.