Commit 9e686d1f authored by Chun-wei Fan's avatar Chun-wei Fan

gdkproperty-win32.c: Fix gtk-font-name handling

...on Windows 8+ and when the system setting for non-Unicode programs do
not match the language version of Windows by falling back to using Pango.

This ensures that the correct font is used during these scenarios, so that
we minimize the risk of seeing garbled characters for texts that the system
code page does not support due to system peculiarties.  There might be a
way to support gtk-font-name handling using the native Windows APIs
directly on Windows 8+, but that needs to be investigated.

https://bugzilla.gnome.org/show_bug.cgi?id=726298
parent d6f9247f
......@@ -398,6 +398,36 @@ _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;
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))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment