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
2009-01-06 17:39:30
+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
2009-01-15 10:29:03
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
2009-03-15 20:17:32
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
2009-03-16 10:35:18
I stand 100% corrected. And baffled by the function name. Thank you, unwind.
Shmoopty
2009-04-07 17:22:30