GNOME Bugzilla – Bug 404506
Windows system fonts that have multi-byte font names cannot be loaded
Last modified: 2007-04-13 01:21:52 UTC
Under Windows 2000/XP/Vista, when using ms-windows engine, it tries to use system fonts, but fails to load fonts with multi-byte names in it with the following warnings (in this case it's Japanese). The older GTK+ (<= 2.6) crashed if this occurs, but 2.8 or later just fall backs to Sans (no crash). ** Pango-WARNING: couldn't load font "メイリオ Bold 9", falling back to "Sans Bold 9", expect ugly output. I have looked into the code of gtk-wimp, and I think I have found a bug in function msw_style.c::sys_font_to_pango_font(). It gets hDC from destop window handle with GetDC(), calculate pt_size, and release hDC with ReleaseDC(). Then, the already released hDC is passed to function get_family_name(). In get_family_name() function, the hDC (pango_win32_hdc) is passed to SelectObject(). It fails with ERROR_INVALID_PARAMETER (87) because hDC is already released. If the hDC is not released, the corresponding ASCII font name (in this case "Meiryo") is looked up as expected. Somehow the current code doesn't fail if the font only contains an ASCII name. I think that's why this bug was overlooked for a long time. The following simple patch fixes the bug. (Maybe this bug is related to #112401) --- msw_style.c.orig Tue Jan 23 00:52:04 2007 +++ msw_style.c Mon Feb 5 14:36:37 2007 @@ -466,12 +466,13 @@ { pt_size = -MulDiv (lf.lfHeight, 72, GetDeviceCaps (hDC, LOGPIXELSY)); - ReleaseDC (hwnd, hDC); } else pt_size = 10; font = get_family_name (&lf, hDC); + if (hDC) + ReleaseDC (hwnd, hDC); if(!(font && *font)) return NULL;
2007-02-05 Dom Lachowicz <domlachowicz@gmail.com> * modules/engines/ms-windows/msw_style.c: Fix bug 404506, caused by prematurely releasing a DC. By Hiroyuki Yamamoto * modules/engines/ms-windows/msw_style.c: Fix bug 403470 - leaking pixbufs when drawing rotated tabs. By Daniel Atallah
*** Bug 428284 has been marked as a duplicate of this bug. ***