[gtk: 1/2] GdkWin32: Scale text with DPI like in GTK3 with SYSTEM_DPI_AWARENESS




commit c11ea42644525df2d1c9cc8bc72292ff99a13395
Author: Luca Bacci <luca bacci982 gmail com>
Date:   Tue Aug 23 14:49:59 2022 +0200

    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.

 gdk/win32/gdkproperty-win32.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
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");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]