summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp')
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp
index 5b8707cdec..e6dee54d84 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp
@@ -866,4 +866,123 @@ QFontEngine *QWindowsFontDatabaseBase::fontEngine(const QByteArray &fontData, qr
return fontEngine;
}
+QString QWindowsFontDatabaseBase::familyForStyleHint(QFont::StyleHint styleHint)
+{
+ switch (styleHint) {
+ case QFont::Times:
+ return QStringLiteral("Times New Roman");
+ case QFont::Courier:
+ return QStringLiteral("Courier New");
+ case QFont::Monospace:
+ return QStringLiteral("Courier New");
+ case QFont::Cursive:
+ return QStringLiteral("Comic Sans MS");
+ case QFont::Fantasy:
+ return QStringLiteral("Impact");
+ case QFont::Decorative:
+ return QStringLiteral("Old English");
+ case QFont::Helvetica:
+ return QStringLiteral("Arial");
+ case QFont::System:
+ default:
+ break;
+ }
+ return QStringLiteral("MS Shell Dlg 2");
+}
+
+// Creation functions
+
+static const char *other_tryFonts[] = {
+ "Arial",
+ "MS UI Gothic",
+ "Gulim",
+ "SimSun",
+ "PMingLiU",
+ "Arial Unicode MS",
+ 0
+};
+
+static const char *jp_tryFonts [] = {
+ "MS UI Gothic",
+ "Arial",
+ "Gulim",
+ "SimSun",
+ "PMingLiU",
+ "Arial Unicode MS",
+ 0
+};
+
+static const char *ch_CN_tryFonts [] = {
+ "SimSun",
+ "Arial",
+ "PMingLiU",
+ "Gulim",
+ "MS UI Gothic",
+ "Arial Unicode MS",
+ 0
+};
+
+static const char *ch_TW_tryFonts [] = {
+ "PMingLiU",
+ "Arial",
+ "SimSun",
+ "Gulim",
+ "MS UI Gothic",
+ "Arial Unicode MS",
+ 0
+};
+
+static const char *kr_tryFonts[] = {
+ "Gulim",
+ "Arial",
+ "PMingLiU",
+ "SimSun",
+ "MS UI Gothic",
+ "Arial Unicode MS",
+ 0
+};
+
+static const char **tryFonts = nullptr;
+
+QStringList QWindowsFontDatabaseBase::extraTryFontsForFamily(const QString &family)
+{
+ QStringList result;
+ QFontDatabase db;
+ if (!db.writingSystems(family).contains(QFontDatabase::Symbol)) {
+ if (!tryFonts) {
+ LANGID lid = GetUserDefaultLangID();
+ switch (lid&0xff) {
+ case LANG_CHINESE: // Chinese
+ if ( lid == 0x0804 || lid == 0x1004) // China mainland and Singapore
+ tryFonts = ch_CN_tryFonts;
+ else
+ tryFonts = ch_TW_tryFonts; // Taiwan, Hong Kong and Macau
+ break;
+ case LANG_JAPANESE:
+ tryFonts = jp_tryFonts;
+ break;
+ case LANG_KOREAN:
+ tryFonts = kr_tryFonts;
+ break;
+ default:
+ tryFonts = other_tryFonts;
+ break;
+ }
+ }
+ QFontDatabase db;
+ const QStringList families = db.families();
+ const char **tf = tryFonts;
+ while (tf && *tf) {
+ // QTBUG-31689, family might be an English alias for a localized font name.
+ const QString family = QString::fromLatin1(*tf);
+ if (families.contains(family) || db.hasFamily(family))
+ result << family;
+ ++tf;
+ }
+ }
+ result.append(QStringLiteral("Segoe UI Emoji"));
+ result.append(QStringLiteral("Segoe UI Symbol"));
+ return result;
+}
+
QT_END_NAMESPACE