Index: /trunk/src/gui/kernel/qapplication_pm.cpp
===================================================================
--- /trunk/src/gui/kernel/qapplication_pm.cpp	(revision 370)
+++ /trunk/src/gui/kernel/qapplication_pm.cpp	(revision 371)
@@ -223,5 +223,5 @@
                     default: f.setStretch(QFont::Unstretched); break;
                 }
-                f.setFamily(fm.szFamilyname);
+                f.setFamily(QString::fromLocal8Bit(fm.szFamilyname));
                 f.setPointSize(height);
             }
Index: /trunk/src/gui/text/qfont_pm.cpp
===================================================================
--- /trunk/src/gui/text/qfont_pm.cpp	(revision 370)
+++ /trunk/src/gui/text/qfont_pm.cpp	(revision 371)
@@ -42,4 +42,5 @@
 ****************************************************************************/
 
+#include "qt_os2.h"
 #include "qfont.h"
 #include "qfont_p.h"
@@ -69,5 +70,30 @@
         break;
     case QFont::AnyStyle:
-        if (request.fixedPitch)
+    default:
+        static char szFontName[FACESIZE + 1] = {0,};
+
+        // already queried ?
+        if (szFontName[0] != ';') {
+            szFontName[0] = ';';
+            // query the associated font
+            if (PrfQueryProfileString(HINI_USERPROFILE,
+                                      "PM_SystemFonts", "PM_AssociateFont", 0,
+                                      szFontName, sizeof(szFontName))) {
+                szFontName[FACESIZE] = '\0';
+
+                // the format of the associated font is face_name;point_size
+                // so remove ';' and later
+                for (PSZ pch = szFontName; *pch; pch++)
+                    if (*pch == ';') {
+                        *pch = '\0';
+                        break;
+                    }
+            }
+        }
+
+        // is the associated font available ?
+        if (szFontName[0] != '\0' && szFontName[0] != ';')
+            family = szFontName;
+        else if (request.fixedPitch)
             family = "Courier";
         else
@@ -103,5 +129,5 @@
 QString QFont::defaultFamily() const
 {
-    return QLatin1String(qt_fontFamilyFromStyleHint(d->request));
+    return QString::fromLocal8Bit(qt_fontFamilyFromStyleHint(d->request));
 }
 
Index: /trunk/src/gui/text/qfontdatabase_pm.cpp
===================================================================
--- /trunk/src/gui/text/qfontdatabase_pm.cpp	(revision 370)
+++ /trunk/src/gui/text/qfontdatabase_pm.cpp	(revision 371)
@@ -42,12 +42,12 @@
 ****************************************************************************/
 
+#include "qfontengine_pm_p.h"
+
 #include "qabstractfileengine.h"
-
-#include "qfontengine_pm_p.h"
-
 #include "qsettings.h"
 #include "qfileinfo.h"
 #include "qdatetime.h"
 #include "qhash.h"
+#include "qtextcodec.h"
 
 #include <ft2build.h>
@@ -56,4 +56,6 @@
 #include FT_TRUETYPE_TABLES_H
 #include FT_LCD_FILTER_H
+#include FT_SFNT_NAMES_H
+#include FT_TRUETYPE_IDS_H
 
 QT_BEGIN_NAMESPACE
@@ -119,4 +121,169 @@
 static FontFileHash knownFontFiles;
 static bool knownFontFilesInitialized = false;
+
+static bool lookupFamilyName(FT_Face ftface, QString &familyName)
+{
+    FT_UInt     nNameCount;
+    FT_UInt     i;
+    FT_SfntName sfntName;
+    FT_UInt     found, best;
+
+    nNameCount = FT_Get_Sfnt_Name_Count(ftface);
+
+    if (nNameCount == 0)
+        return false;
+
+#ifndef QT_NO_TEXTCODEC
+    QTextCodec *codec = QTextCodec::codecForName("UTF-16BE");
+
+    // find a unicode name at first
+    if (codec) {
+        found = (FT_UInt)-1;
+        best  = (FT_UInt)-1;
+
+        // try to find the unicode name matching to the locale
+        for (i = 0; found == (FT_UInt)-1 && i < nNameCount; i++) {
+            FT_Get_Sfnt_Name(ftface, i, &sfntName);
+
+            if (sfntName.name_id     == TT_NAME_ID_FONT_FAMILY &&
+                sfntName.platform_id == TT_PLATFORM_MICROSOFT &&
+                sfntName.encoding_id == TT_MS_ID_UNICODE_CS) {
+                if (best == (FT_UInt)-1 || sfntName.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES)
+                    best = i;
+
+                QLocale sysLocale = QLocale::system();
+                switch (sfntName.language_id) {
+                    case TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA :
+                        if (sysLocale.language() == QLocale::Korean)
+                            found = i;
+                        break;
+
+                    case TT_MS_LANGID_JAPANESE_JAPAN :
+                        if (sysLocale.language() == QLocale::Japanese)
+                            found = i;
+                        break;
+
+                    case TT_MS_LANGID_CHINESE_PRC :
+                        if (sysLocale.country() == QLocale::China &&
+                            sysLocale.language() == QLocale::Chinese)
+                            found = i;
+                        break;
+
+                    case TT_MS_LANGID_CHINESE_TAIWAN :
+                        if (sysLocale.country() == QLocale::Taiwan &&
+                            sysLocale.language() == QLocale::Chinese)
+                            found = i;
+                        break;
+                }
+            }
+        }
+
+        if (found == (FT_UInt)-1)
+            found = best;
+
+        if (found != (FT_UInt)-1) {
+            FT_Get_Sfnt_Name(ftface, found, &sfntName);
+
+            familyName = codec->toUnicode((const char *)sfntName.string, sfntName.string_len);
+
+            return true;
+        }
+    }
+#endif
+
+    found = (FT_UInt)-1;
+    best  = (FT_UInt)-1;
+
+    // unicode name is not available, try the NLS encoded name
+    for (i = 0; found == (FT_UInt)-1 && i < nNameCount; i++) {
+        FT_Get_Sfnt_Name(ftface, i, &sfntName);
+
+        if (sfntName.name_id     == TT_NAME_ID_FONT_FAMILY &&
+            sfntName.platform_id == TT_PLATFORM_MICROSOFT) {
+            if (best == (FT_UInt)-1)
+                best = i;
+
+            QLocale sysLocale = QLocale::system();
+            switch (sfntName.encoding_id) {
+                case TT_MS_ID_WANSUNG :
+                    if (sysLocale.language() == QLocale::Korean)
+                        found = i;
+                    break;
+
+                case TT_MS_ID_SJIS :
+                    if (sysLocale.language() == QLocale::Japanese)
+                        found = i;
+                    break;
+
+                case TT_MS_ID_BIG_5 :
+                    if (sysLocale.country() == QLocale::Taiwan &&
+                        sysLocale.language() == QLocale::Chinese)
+                        found = i;
+                    break;
+
+                case TT_MS_ID_GB2312 :
+                    if (sysLocale.country() == QLocale::China &&
+                        sysLocale.language() == QLocale::Chinese)
+                        found = i;
+                    break;
+
+                case TT_MS_ID_SYMBOL_CS :
+                    found = i;
+                    break;
+            }
+        }
+    }
+
+    if (found == (FT_UInt)-1)
+        found = best;
+
+    if (found != (FT_UInt)-1)
+    {
+        char   *name;
+        FT_UInt name_len = 0;
+
+        FT_Get_Sfnt_Name(ftface, found, &sfntName);
+
+        name = (char *)alloca(sfntName.string_len);
+
+        for (FT_UInt j = 0; j < sfntName.string_len; j++)
+            if (sfntName.string[j])
+                name[name_len++] = sfntName.string[j];
+
+#ifndef QT_NO_TEXTCODEC
+        switch (sfntName.encoding_id) {
+            case TT_MS_ID_WANSUNG :
+                codec = QTextCodec::codecForName("cp949");
+                break;
+
+            case TT_MS_ID_SJIS :
+                codec = QTextCodec::codecForName("SJIS");
+                break;
+
+            case TT_MS_ID_BIG_5 :
+                codec = QTextCodec::codecForName("Big5");
+                break;
+
+            case TT_MS_ID_GB2312 :
+                codec = QTextCodec::codecForName("GB2312");
+                break;
+
+            case TT_MS_ID_SYMBOL_CS :
+            default :
+                codec = NULL;
+                break;
+        }
+
+        if (codec)
+            familyName = codec->toUnicode(name, name_len);
+        else
+#endif
+            familyName = QString::fromLocal8Bit(name, name_len);
+
+        return true;
+    }
+
+    return false;
+}
 
 static void populateDatabase(const QString& fam)
@@ -270,5 +437,7 @@
 
                 cached.index = idx;
-                cached.familyName = QString::fromLatin1(face->family_name);
+
+                if (!lookupFamilyName(face, cached.familyName))
+                    cached.familyName = QString::fromLocal8Bit(face->family_name);
 
                 // familyName may contain extra spaces (at least this is true for
