diff --git a/build/win32/vs10/gtk3-build-defines.props b/build/win32/vs10/gtk3-build-defines.props
index 1c4a54115f..ee4bd802b6 100644
--- a/build/win32/vs10/gtk3-build-defines.props
+++ b/build/win32/vs10/gtk3-build-defines.props
@@ -10,10 +10,10 @@
GDK_COMPILATION;G_LOG_DOMAIN="Gdk"
INCLUDE_IM_am_et;INCLUDE_IM_cedilla;INCLUDE_IM_cyrillic_translit;INCLUDE_IM_ime;INCLUDE_IM_inuktitut;INCLUDE_IM_ipa;INCLUDE_IM_multipress;INCLUDE_IM_thai;INCLUDE_IM_ti_er;INCLUDE_IM_ti_et;INCLUDE_IM_viqr
GTK_COMPILATION;G_LOG_DOMAIN="Gtk";GTK_HOST="i686-pc-vs$(VSVer)";GTK_PRINT_BACKENDS="file";GTK_PRINT_BACKEND_ENABLE_UNSUPPORTED;$(GtkIncludedImmodulesDefines);GTK_LIBDIR="$(GtkDummyPrefix)/lib";GTK_DATADIR="$(GtkDummyPrefix)/share";GTK_DATA_PREFIX="$(GtkDummyPrefix)";GTK_SYSCONFDIR="$(GtkDummyPrefix)/etc";MULTIPRESS_CONFDIR="$(GtkDummyPrefix)/etc/gtk-$(ApiVersion)";MULTIPRESS_LOCALEDIR="$(GtkDummyPrefix)/share/locale";GTK_VERSION="$(GtkVersion)/etc";GTK_BINARY_VERSION="$(GtkBinaryVersion)/etc";GDK_DISABLE_DEPRECATED;ISOLATION_AWARE_ENABLED
- imm32.lib
+ pangowin32-1.0.lib;imm32.lib
winmm.lib;dwmapi.lib;setupapi.lib;$(GtkGdkCommonLibs)
ws2_32.lib
- atk-1.0.lib;pangowin32-1.0.lib;winspool.lib;comctl32.lib;$(GtkGdkCommonLibs)
+ atk-1.0.lib;winspool.lib;comctl32.lib;$(GtkGdkCommonLibs)
cd ..
set VCInstallDir=$(VCInstallDir)
nmake -f gtk-introspection-msvc.mak CFG=$(Configuration) PREFIX=$(GlibEtcInstallRoot)
diff --git a/build/win32/vs9/gtk3-build-defines.vsprops b/build/win32/vs9/gtk3-build-defines.vsprops
index ab77577ebf..e268225038 100644
--- a/build/win32/vs9/gtk3-build-defines.vsprops
+++ b/build/win32/vs9/gtk3-build-defines.vsprops
@@ -45,7 +45,7 @@
/>
#include
#include
+#include
#include "gdkscreen.h"
#include "gdkproperty.h"
@@ -239,6 +240,32 @@ _gdk_win32_window_delete_property (GdkWindow *window,
}
}
+static gchar*
+_get_system_font_name (HDC hdc)
+{
+ NONCLIENTMETRICSW ncm;
+ PangoFontDescription *font_desc;
+ gchar *result, *font_desc_string;
+ int logpixelsy;
+ gint font_size;
+
+ ncm.cbSize = sizeof(NONCLIENTMETRICSW);
+ if (!SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0))
+ return NULL;
+
+ logpixelsy = GetDeviceCaps (hdc, LOGPIXELSY);
+ font_desc = pango_win32_font_description_from_logfontw (&ncm.lfMessageFont);
+ font_desc_string = pango_font_description_to_string (font_desc);
+ pango_font_description_free (font_desc);
+
+ /* https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-taglogfonta */
+ font_size = -MulDiv (ncm.lfMessageFont.lfHeight, 72, logpixelsy);
+ result = g_strdup_printf ("%s %d", font_desc_string, font_size);
+ g_free (font_desc_string);
+
+ return result;
+}
+
/*
For reference, from gdk/x11/gdksettings.c:
@@ -371,58 +398,27 @@ _gdk_win32_screen_get_setting (GdkScreen *screen,
}
else if (strcmp ("gtk-font-name", name) == 0)
{
- NONCLIENTMETRICS ncm;
- CPINFOEX cpinfoex_default, cpinfoex_curr_thread;
- OSVERSIONINFO info;
- BOOL result_default, result_curr_thread;
+ gchar *font_name = _get_system_font_name (_gdk_display_hdc);
- info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
-
- /* TODO: Fallback to using Pango on Windows 8 and later,
- * as this method of handling gtk-font-name does not work
- * well there, where garbled text will be displayed for texts
- * that are not supported by the default menu font. Look for
- * whether there is a better solution for this on Windows 8 and
- * later
- */
- if (!GetVersionEx (&info) ||
- info.dwMajorVersion > 6 ||
- (info.dwMajorVersion == 6 && info.dwMinorVersion >= 2))
- return FALSE;
-
- /* check whether the system default ANSI codepage matches the
- * ANSI code page of the running thread. If so, continue, otherwise
- * fall back to using Pango to handle gtk-font-name
- */
- result_default = GetCPInfoEx (CP_ACP, 0, &cpinfoex_default);
- result_curr_thread = GetCPInfoEx (CP_THREAD_ACP, 0, &cpinfoex_curr_thread);
-
- if (!result_default ||
- !result_curr_thread ||
- cpinfoex_default.CodePage != cpinfoex_curr_thread.CodePage)
- return FALSE;
-
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
- if (SystemParametersInfo (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, FALSE))
+ if (font_name)
{
- /* Pango finally uses GetDeviceCaps to scale, we use simple
- * approximation here.
- */
- int nHeight = (0 > ncm.lfMenuFont.lfHeight ? - 3 * ncm.lfMenuFont.lfHeight / 4 : 10);
- if (OUT_STRING_PRECIS == ncm.lfMenuFont.lfOutPrecision)
- GDK_NOTE(MISC, g_print("gdk_screen_get_setting(%s) : ignoring bitmap font '%s'\n",
- name, ncm.lfMenuFont.lfFaceName));
- else if (ncm.lfMenuFont.lfFaceName && strlen(ncm.lfMenuFont.lfFaceName) > 0 &&
- /* Avoid issues like those described in bug #135098 */
- g_utf8_validate (ncm.lfMenuFont.lfFaceName, -1, NULL))
+ /* The pango font fallback list got fixed during 1.43, before that
+ * using anything but "Segoe UI" would lead to a poor glyph coverage */
+ if (pango_version_check (1, 43, 0) != NULL &&
+ g_ascii_strncasecmp (font_name, "Segoe UI", strlen ("Segoe UI")) != 0)
{
- char *s = g_strdup_printf ("%s %d", ncm.lfMenuFont.lfFaceName, nHeight);
- GDK_NOTE(MISC, g_print("gdk_screen_get_setting(%s) : %s\n", name, s));
- g_value_set_string (value, s);
-
- g_free(s);
- return TRUE;
+ g_free (font_name);
+ return FALSE;
}
+
+ GDK_NOTE(MISC, g_print("gdk_screen_get_setting(\"%s\") : %s\n", name, font_name));
+ g_value_take_string (value, font_name);
+ return TRUE;
+ }
+ else
+ {
+ g_warning ("gdk_screen_get_setting: Detecting the system font failed");
+ return FALSE;
}
}
else if (strcmp ("gtk-im-module", name) == 0)