summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Bacci <luca.bacci982@gmail.com>2022-08-23 14:49:59 +0200
committerLuca Bacci <luca.bacci982@gmail.com>2022-08-23 19:53:44 +0200
commitc11ea42644525df2d1c9cc8bc72292ff99a13395 (patch)
treef1501ec4e2cb6ad0dc1cce9a61f0d0cdee1b8d58
parentd7c04145ee4d2aa7c2f1ef9653de7d8708e9854a (diff)
downloadgtk+-c11ea42644525df2d1c9cc8bc72292ff99a13395.tar.gz
GdkWin32: Scale text with DPI like in GTK3 with SYSTEM_DPI_AWARENESS
Right now we only support system DPI awareness in GTK4. In that case it makes sense to scale text with the DPI of the primary monitor, like done in GTK3. We plan to land support for proper fractional scaling in Gdk/Win32, so in the future the "gtk-xft-dpi" setting will be gathered as intended, i.e. for text magnification, as an a11y feature.
-rw-r--r--gdk/win32/gdkproperty-win32.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c
index f919e53e9c..b8197495f2 100644
--- a/gdk/win32/gdkproperty-win32.c
+++ b/gdk/win32/gdkproperty-win32.c
@@ -31,6 +31,7 @@
#include "gdkdisplayprivate.h"
#include "gdkprivate-win32.h"
+#include "gdkdisplay-win32.h"
#include "gdkwin32.h"
static char *
@@ -162,6 +163,25 @@ _gdk_win32_get_setting (const char *name,
g_value_set_int (value, 1);
return TRUE;
}
+ else if (strcmp ("gtk-xft-dpi", name) == 0)
+ {
+ GdkWin32Display *display = GDK_WIN32_DISPLAY (_gdk_display);
+
+ if (display->dpi_aware_type == PROCESS_SYSTEM_DPI_AWARE &&
+ !display->has_fixed_scale)
+ {
+ int dpi = GetDeviceCaps (GetDC (NULL), LOGPIXELSX);
+ if (dpi >= 96)
+ {
+ int xft_dpi = 1024 * dpi / display->surface_scale;
+ g_value_set_int (value, xft_dpi);
+ GDK_NOTE(MISC, g_print ("gdk_screen_get_setting(\"%s\") : %d\n", name, xft_dpi));
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+ }
else if (strcmp ("gtk-xft-hintstyle", name) == 0)
{
g_value_set_static_string (value, "hintfull");