summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontdatabase_x11.cpp
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-01-05 18:39:00 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-01-06 12:50:48 (GMT)
commit18447df1d021cfed69472b867cb7593401be27a6 (patch)
tree69406c23ec173d51f5ce3d5259d3638e0cdf0fad /src/gui/text/qfontdatabase_x11.cpp
parent09b06552f98f8ee8be4d156049a6a37a4abed6bd (diff)
downloadQt-18447df1d021cfed69472b867cb7593401be27a6.zip
Qt-18447df1d021cfed69472b867cb7593401be27a6.tar.gz
Qt-18447df1d021cfed69472b867cb7593401be27a6.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/gui/text/qfontdatabase_x11.cpp')
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 635d2cf..c67558b 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;
@@ -2037,6 +2044,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
int count = 0;
QStringList families;
+ QFontDatabasePrivate *db = privateDb();
FcPattern *pattern = 0;
do {
@@ -2048,8 +2056,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;
}