DPI Setting

Is there a way to get the current dpi setting of the video hardware with SDL? I am writing some freetype code in which one of the functions needs the dpi value and I have been hardcoding the value thus far.

Let me join to this question

I don’t see any function that would return that value. My guess is you could call SDL_GetWindowWMInfo() to get the native WM handle and from there you could get the screen size using platform specific function (which I don’t know any), and calculate the dpi from the window size. It does not appear to support Android, btw.

This is just a guess, please don’t take it for grant :slight_smile:

mr_tawan wrote:

you could get the screen size using platform specific function (which I don’t know any)
Yes, there are, for example, WinApi.GetDeviceCaps(dc, WinApi.LOGPIXELSY) function used by platform layer, but I centered my hopes to SDL as a single platform layer for my application (

But SDL_RenderGetLogicalSize can help? I will explore…

I don’t think it would help :-/ SDL_GetLogicalSize return (0, 0) when it’s not set beforehand.

I think we could implement this as a supplement library, and propose it to be included into SDL2.1 (or any other release).

Ooh, it’s out of my skills, i’m not a C programmer

Another point is SDL_TTF hardcoded to 72 DPI. On my Windows machine I have 96 DPI and a generated texture is smaller than it actually should be.