DPI and screen resolution on OS X

Chris Sherlock chris.sherlock79 at gmail.com
Tue Feb 2 23:52:48 UTC 2016

Hi all, 

I’ve mentioned this briefly to Tor on IRC, but thought I’d email the mailing list and a general enquiry. 

I noticed that we don’t actually get the “true” DPI for OS X, nor the actual resolution - at least on high resolution screens (Retina in particular). 

That’s because Apple have a concept of logical points, where each point scales depending on the resolution of the screen. To get the actual resolution, you need to get the NSScreen’s backing coordinate system into an NSRect, then get the actual resolution - at which point you can calculate the PPI (I’ll use PPI from now on, it’s more accurate than DPI). 

I figured out how to get this out of OS X and I submitted to patches to Gerrit for review:

1. https://gerrit.libreoffice.org/#/c/21948/ - vcl: (quartz) get the actual DPI on OS X
2. https://gerrit.libreoffice.org/#/c/21973/ - vcl: (quartz) get the actual pixel height and width of OS X

It’s actually pretty simple - you just use:

NSRect aFrame = [pScreen convertRectToBacking:[pScreen frame]];

This gives the actual resolution in pixels, not logical points (backing coordinates are always in pixels). 

However, whilst everything renders correctly - the size of things obviously double (or change to whatever scale the screen resolution makes it). 

I guess I was wondering what the impact is, or what challenges have we had with not getting the *actual* DPI and screen resolution on OS X builds? Has anyone noticed anything odd when they are using a Mac, or developing for it?

The other question is: why would we not want to the actual DPI and screen resolution? 


More information about the LibreOffice mailing list