Reliable PPI?

Hi,

I want to paint score notation based on inches, and be able to get on the screen what i’ll get on the printer.

So Is there a way to get the real PPI / DPI with JUCE?

juce::Desktop::getInstance().getDisplays().getMainDisplay().dpi

The code above always return 72. It’s not correct for my screen (NSDeviceResolution limitation i guess).

But with the snippet below i can compute a good value (112.11 in my case).

I don’t know if that code is correct and/or usable directly in JUCE. But in case.

Interesting.. Seems like Apple's NSDeviceResolution may be acting as a backwards-compatibility bodge.

But TBH even this other trick will get the wrong value sometimes, because there will inevitably be monitors where the OS simply has no idea what their size is. (e.g. what does this return if you connect a projector!?)

According to:

1. CGDisplayScreenSize reference:

If Extended Display Identification Data (EDID) for the display device is not available, the size is estimated based on the device width and height in pixels from CGDisplayBounds, with an assumed resolution of 2.835 pixels/mm or 72 dpi, a reasonable guess for displays predating EDID support.

2. < https://stackoverflow.com/questions/20474596/nsscreen-get-the-projector-tv-out-airplay-screen/20486284#20486284 >

It seems to work for projectors also.

But that's true that without extensive tests (EDID seems not reliable) it's not a good idea to use that trick.