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.
This commit is contained in:
Luca Bacci 2022-08-23 14:49:59 +02:00
parent d7c04145ee
commit c11ea42644

View File

@ -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");