summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-01-05 18:39:00 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:24:45 (GMT)
commit152a14cd73e478685833dd0c8ae29583d898ce82 (patch)
tree582f39cc9b10b01931fb7d96092d0ec75d56755d /src
parentf91ffcf84808ee24d62d5831ffde42c29d2c56e3 (diff)
downloadQt-152a14cd73e478685833dd0c8ae29583d898ce82.zip
Qt-152a14cd73e478685833dd0c8ae29583d898ce82.tar.gz
Qt-152a14cd73e478685833dd0c8ae29583d898ce82.tar.bz2
Make application font family names locale sensitive in X11
So that they will match the family names returned by QFontDatabase::families. Because the family names returned by FcFreeTypeQueryFace are not sorted with locale as the names returned by FcFontList, we have to find out the family name matching the system language in the former case. Task-number: QTBUG-14269 Reviewed-by: Eskil
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qfontdatabase.cpp3
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp23
2 files changed, 24 insertions, 2 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index cc25dee..e686103 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -640,6 +640,9 @@ public:
}
int count;
+#if defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)
+ QString systemLang;
+#endif
QtFontFamily **families;
struct ApplicationFont {
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 1604876..2fa16bb 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -1018,6 +1018,13 @@ static void loadFontConfig()
QFontDatabasePrivate *db = privateDb();
FcFontSet *fonts;
+ FcPattern *pattern = FcPatternCreate();
+ FcDefaultSubstitute(pattern);
+ FcChar8 *lang = 0;
+ if (FcPatternGetString(pattern, FC_LANG, 0, &lang) == FcResultMatch)
+ db->systemLang = QString::fromUtf8((const char *) lang);
+ FcPatternDestroy(pattern);
+
QString familyName;
FcChar8 *value = 0;
int weight_value;
@@ -2019,6 +2026,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
int count = 0;
QStringList families;
+ QFontDatabasePrivate *db = privateDb();
FcPattern *pattern = 0;
do {
@@ -2030,8 +2038,19 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
FcPatternDel(pattern, FC_FILE);
FcPatternAddString(pattern, FC_FILE, (const FcChar8 *)fnt->fileName.toUtf8().constData());
- FcChar8 *fam = 0;
- if (FcPatternGetString(pattern, FC_FAMILY, 0, &fam) == FcResultMatch) {
+ FcChar8 *fam = 0, *familylang = 0;
+ int i, n = 0;
+ for (i = 0; ; i++) {
+ if (FcPatternGetString(pattern, FC_FAMILYLANG, i, &familylang) != FcResultMatch)
+ break;
+ QString familyLang = QString::fromUtf8((const char *) familylang);
+ if (familyLang.compare(db->systemLang, Qt::CaseInsensitive) == 0) {
+ n = i;
+ break;
+ }
+ }
+
+ if (FcPatternGetString(pattern, FC_FAMILY, n, &fam) == FcResultMatch) {
QString family = QString::fromUtf8(reinterpret_cast<const char *>(fam));
families << family;
}