After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 68113 - PangoFontDescription is locale-dependent strings on Windows.
PangoFontDescription is locale-dependent strings on Windows.
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
0.x
Other Windows
: Normal critical
: 1.0.5
Assigned To: Owen Taylor
Owen Taylor
Depends on:
Blocks:
 
 
Reported: 2002-01-06 09:37 UTC by Toshio MARUYAMA
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Toshio MARUYAMA 2002-01-06 09:37:09 UTC
I built gtk+ and pango cvs head sources on Mingw environment.
I executed testgtk and invoked Font Selection Dialog
on Japanese Windows 2000 Professional.

Japanese popular Font "MS Gothic" and "MS Mincho" 
in Japanese KANJI were not listed.

logfont_to_xlfd() in gtk+/gdk/win32/gdkfont-win32.c has 
g_filename_to_utf8(), but pangowin32 does not have this function.

I created following patch and attached it,
I confirmed  "MS Gothic" and "MS Mincho" in Japanese KANJI
were listed.

I think strings allocated by g_filename_to_utf8() must be freed
in somewhere, but I can not understand where to free this.


--- pangowin32-fontmap.c	Sun Jan  6 16:53:54 2002
+++ pangowin32-fontmap.c.new	Sun Jan  6 16:53:09 2002
@@ -750,11 +750,12 @@
 
   size_info->logfonts = g_slist_prepend (size_info->logfonts, lfp2);
   
   /* Convert the LOGFONT into a PangoFontDescription */
   
-  family_name = lfp2->lfFaceName;
+  /* family_name = lfp2->lfFaceName; */
+  family_name = g_filename_to_utf8 (lfp->lfFaceName, -1, NULL, NULL, 
NULL);
   
   if (!lfp2->lfItalic)
     style = PANGO_STYLE_NORMAL;
   else
     style = PANGO_STYLE_ITALIC;
Comment 1 Owen Taylor 2002-01-06 19:44:55 UTC
Should this be using the lfCharset value from the LOGFONT
structure instead of the current codepage as g_locale_to_utf8()
does? 

The value can be freed after the last use in the function,
since pango_win32_get_font_family copies the family. But
there seem to be other uses of lfpFaceName, so I'm not
sure this is a complete solution.

As a more general issue:

 - The family names in font descriptions are supposed to be
   locale independent so you can write programs that can
   run in different locales. The SDK docs say:
   
     The fonts for many East Asian languages have two 
     typeface names: an English name and a localized name. 
     EnumFonts, EnumFontFamilies, and EnumFontFamiliesEx return
     the English typeface name if the system locale does 
     not match the language of the font.
    
   Which is not a helpful behavior. Can we switch the locale
   for the program temporarily, list the fonts, and switch
   back?
 
   We should have pango_font_family_get_display_name() that
   returns a localized name, if available, but that would
   be a future API addition.
Comment 2 Toshio MARUYAMA 2002-01-16 16:58:25 UTC
I think this probrem is simply character set probrem.
So, in order to resolve this problem, pango only should convert
Shift-JIS as locale-dependent strings to UTF-8.

> Should this be using the lfCharset value from the LOGFONT
> structure instead of the current codepage as g_locale_to_utf8()
> does?

Sorry, I can't understand what this means.
g_filename_to_utf8() simply calls g_locale_to_utf8() on windows.

> Can we switch the locale
> for the program temporarily, list the fonts, and switch
> back?

I tried to try whether this would be possible.
Win32 API SetThreadLocale() is supported on Windows NT/2000/XP.
But this function is NOT supported on  Windows 95/98/Me.
Comment 3 Takayuki KUSANO 2002-03-10 11:36:06 UTC
On X11 environment with Xft enabled, encoding of TrueType font name
cause trouble. GtkFontSelection class cannot work correctly. Most of
font names are displayed as empty. So, Japanese user can't use
font selection dialog on many application.

Encoding of name of Japanese TrueType fonts and family_name
holded by PangoFontDescrition are Shift_JIS
(Mac variants of Windows varints), locale encoding is EUC-JP,
 and GTK+ assumes encodig of string are UTF-8.

Comment 4 Owen Taylor 2002-03-25 21:49:26 UTC
For some more on the Xft problem, see:

http://www.freetype.org/pipermail/devel/2002-March/003101.html
Comment 5 Tor Lillqvist 2002-09-18 18:46:31 UTC
Re Owen's comment from 2002-01-06 : No, unfortunately we cannot 
switch the thread's locale back and forth. There is SetThreadLocale
(), but it isn't present on Win9x/Me.

But presumably one should be able to peek out the ASCII name from the 
font file using GetFontData(). Will have to borrow code from FreeType 
to do that.
Comment 6 Owen Taylor 2002-10-14 15:52:58 UTC
The code in PangoWin32 now seems to implement the same algorithm
as FreeType, so I think this can be considered fixesd.

I've filed bug 95731 to cover the issue of adding an API to
get the localized name for display.