tags:

views:

721

answers:

2

Using GTK, how do I query the current screen's dpi settings?

+1  A: 

See http://gtk.php.net/manual/en/gdk.gdkscreen.php. You should be able to compute it using the get_height and get_height_mm or with get_width and get_width_mm.

Ben Alpert
+3  A: 

The current accepted answer is for PHPGTK, which feels a bit odd to me. The pure GDK library has this call: gdk_screen_get_resolution(), which sounds like a better match. Haven't worked with it myself, don't know if it's generally reliable.

unwind
That function returns resolution, or number of pixels.DPI measures the assumed "dots per inch", or density of pixels. Those are two entirely different concepts.
Shmoopty
No, it does not, at least not according to the documentation. It returns a single double, which is "a scale factor between points specified in a PangoFontDescription and Cairo units. The default value is 96, meaning that a 10 point font will be 13 units high. (10 * 96. / 72. = 13.3)".
unwind
I stand 100% corrected. And baffled by the function name. Thank you, unwind.
Shmoopty