From 9f7bc42b7d6466b8422c7cc3900a7eb3bfa60bf9 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 5 Apr 2013 16:20:15 +0300 Subject: Fix QFontconfigDatabase unable to fallback to a localized family When populating the font database, FcPatternGetString(FC_FAMILY) gets a localized font family name; but, in fallbacksForFamily, it gets a non-localized font family name, so it unable to find the proper font to fallback. Simply register all family name variants as aliases to localized name and make sure they are checked when getting fallback families. Task-number: QTBUG-28806 Task-number: QTBUG-30415 Change-Id: I71c03ae9b51a28736c2576f3442f1bbdb3497c09 Reviewed-by: Friedemann Kleint Reviewed-by: jian liang Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontdatabase.cpp | 20 +++++++------------- src/gui/text/qfontdatabase_qpa.cpp | 3 +-- 2 files changed, 8 insertions(+), 15 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index e3270b430f..86a5bed15d 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -344,6 +344,7 @@ struct QtFontFamily bool askedForFallback; unsigned char writingSystems[QFontDatabase::WritingSystemsCount]; + bool matchesFamilyName(const QString &familyName) const; QtFontFoundry *foundry(const QString &f, bool = false); }; @@ -383,6 +384,11 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) return foundries[count++]; } +bool QtFontFamily::matchesFamilyName(const QString &familyName) const +{ + return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive); +} + class QFontDatabasePrivate { @@ -852,19 +858,7 @@ static bool matchFamilyName(const QString &familyName, QtFontFamily *f) { if (familyName.isEmpty()) return true; - - if (f->name.compare(familyName, Qt::CaseInsensitive) == 0) - return true; - - QStringList::const_iterator it = f->aliases.constBegin(); - while (it != f->aliases.constEnd()) { - if ((*it).compare(familyName, Qt::CaseInsensitive) == 0) - return true; - - ++it; - } - - return false; + return f->matchesFamilyName(familyName); } /*! diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index be42e892fa..32580ada7a 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -110,8 +110,7 @@ static QStringList fallbackFamilies(const QString &family, QFont::Style style, Q for (i = retList.begin(); i != retList.end(); ++i) { bool contains = false; for (int j = 0; j < db->count; j++) { - QtFontFamily *qtFamily = db->families[j]; - if (!(i->compare(qtFamily->name,Qt::CaseInsensitive))) { + if (db->families[j]->matchesFamilyName(*i)) { contains = true; break; } -- cgit v1.2.3