Closed wkjarosz closed 8 months ago
You are experiencing a known quirk with ImGui: see this extract from the ImGui FAQ:
The reason DPI is not auto-magically solved in stock examples is that we don't yet have a satisfying solution for the "multi-dpi" problem (using the docking branch: when multiple viewport windows are over multiple monitors using different DPI scales). The current way to handle this on the application side is: Create and maintain one font atlas per active DPI scale (e.g. by iterating platform_io.Monitors[] before NewFrame()). Hook platform_io.OnChangedViewport() to detect when a Begin() call makes a Dear ImGui window change monitor (and therefore DPI). In the hook: swap atlas, swap style with correctly sized one, and remap the current font from one atlas to the other (you may need to maintain a remapping table of your fonts at varying DPI scales).
HelloImGui tries hard to add many additional steps to handle DPI correctly on different platforms. However, this is a very difficult a time consuming task, since different platforms, or different app settings handle DPI differently.
Moving a window between monitors having different DPIs is not handled at the moment, since this would require 1/ changing the font atlas whenever the windows switches to a different monitor, and 2/ adapt the window size to account for the DPI change (on windows).
However, under macOS we might be lucky, since the window physical size (in millimeter) will likely not change when moving from one Retina screen to a non retina screen.
Last week, I was confronted to this issue, which lead me to introduce some settings:
See dpi_aware.h
If you create a hello_imgui.ini
file where you place
[DpiAwareParams]
dpiWindowSizeFactor=1
fontRenderingScale=0.5
(or if you set those values inside runnerParams.dpiAwareParams
), you will disconnect HelloImGui automatic DPI detection.
In this case, fonts will be loaded at twice the size and scaled by 0.5 upon rendering, which will likely improve the situation. The fonts will use more texture memory (but it will be the same as when running directly on the retina screen, since in that case HelloImGui will apply fontRenderingScale=0.5
automatically).
Please keep me informed of the result
Thanks. I can confirm that setting those programmatically does indeed make the app use crisp fonts on the retina screen (though the fonts therefore look notably crunchy/jagged on the non-retina screen -- a compromise I'm willing to deal with for now).
Thanks, I took a few minutes to build and look at the imgui branch of your hdrview project, it looks extremely nice!
Thanks!
On macOS with a MacBook Pro, I just noticed the following behavior:
launch a hello imgui app on:
I have confirmed this behavior in my own apps, and also the fontawesome example in hello imgui.
Is there a way to handle case 3 above properly?