Skip to content
New issue

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

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

Already on GitHub? # to your account

DPI issue on OSX #33

Open
yan-zaretskiy opened this issue Nov 24, 2020 · 4 comments
Open

DPI issue on OSX #33

yan-zaretskiy opened this issue Nov 24, 2020 · 4 comments

Comments

@yan-zaretskiy
Copy link

I am new to Dear Imgui and I came across the Mahi GUI library as a starter kit. I started going thru the examples and immediately noticed that the fonts are a tad blurry. I am on OSX with the Retina monitor. I downloaded the Syntacts app just in case and saw the same issue with it:

Screen Shot 2020-11-24 at 10 56 43

I saw there's a DPI example in Mahi GUI, but it looks like it does not actually change the scaling factor, the reported DPI scale is still 1.0 when I pass the -d option there.

In the end, my question is, can I somehow make the fonts look sharper?

@epezent
Copy link
Member

epezent commented Nov 24, 2020

@mindv0rtex , DPI scaling is a WIP and currently has no effect. The whole thing was pushed prematurely, regretfully. I was using Syntacts and the example mahi-gui app as testing grounds while working on it.

In its present form, mahi-gui should do no DPI scaling yet (despite the option existing). I thought I would have this worked out soon enough that no one would catch it, but life got in the way. I just added a warning comment to not use it yet (it's the best I can do for now).

Sorry for the mess. Hopefully this is something I can resolve sooner than later.

Regarding sharper fonts, the general idea is that you load the font at a large size (e.g. 12 pt * dpi_scale), and then apply a global font scaling (e.g. 1.0 / dpi_scale). I was trying to make this work in Application.cpp, but did not get it finished.

DPI scaling ImGui in general is a bit confusing. There are two approaches: 1) manually scale all of ImGui's styling sizes and any hard coded window sizes, or 2) scale the framebuffer and continue to work under the assumption of 96 DPI. The latter is preferred, and what I hope to get working eventually.

@yan-zaretskiy
Copy link
Author

I am sorry I stumbled upon an unfinished feature I was not meant to find 😄

Regarding sharper fonts, the general idea is that you load the font at a large size (e.g. 12 pt * dpi_scale), and then apply a global font scaling (e.g. 1.0 / dpi_scale). I was trying to make this work in Application.cpp, but did not get it finished.

Is this something I can do now with mahi-gui or would I need to use vanilla Dear Imgui?

@yan-zaretskiy
Copy link
Author

@epezent, in case this could be helpful for you, I managed to make your code work for Retina scaling with very minor tweaks:

  • Changed enable_dpi_aware() to return 2.0f. I realize this is a hard-coded value, I was just trying to see if I could get it to work...
  • Removed dpi scale multiplier in methods that set/get window sizes.

Font size scaling and the DPI scaling method 1 are left untouched. I get nice crisp looking fonts now.

@yan-zaretskiy
Copy link
Author

Looks like this param in GLFW is relevant:

GLFW_COCOA_RETINA_FRAMEBUFFER specifies whether to use full resolution framebuffers on Retina displays. Possible values are GLFW_TRUE and GLFW_FALSE. This is ignored on other platforms.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants