From: Luca Bacci Date: Tue, 23 Aug 2022 12:49:59 +0000 (+0200) Subject: GdkWin32: Scale text with DPI like in GTK3 with SYSTEM_DPI_AWARENESS X-Git-Tag: archive/raspbian/4.8.3+ds-2+rpi1~3^2~20^2~3^2~59^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c11ea42644525df2d1c9cc8bc72292ff99a13395;p=gtk4.git 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. --- 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");