diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 1b9a08b0d2..4adb188212 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -56,46 +56,33 @@ QT_BEGIN_NAMESPACE static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin) { - *hasLatin = true; - QList writingSystems = QFontDatabase().writingSystems(font.family()); // qDebug() << font.family() << writingSystems; // this just confuses the algorithm below. Vietnamese is Latin with lots of special chars - writingSystems.removeAll(QFontDatabase::Vietnamese); - - QFontDatabase::WritingSystem system = QFontDatabase::Any; - - if (!writingSystems.contains(QFontDatabase::Latin)) { - *hasLatin = false; - // we need to show something - if (writingSystems.count()) - system = writingSystems.last(); - } else { - writingSystems.removeAll(QFontDatabase::Latin); - } + writingSystems.removeOne(QFontDatabase::Vietnamese); + *hasLatin = writingSystems.removeOne(QFontDatabase::Latin); if (writingSystems.isEmpty()) - return system; + return QFontDatabase::Any; - if (writingSystems.count() == 1 && writingSystems.at(0) > QFontDatabase::Cyrillic) { - system = writingSystems.at(0); + QFontDatabase::WritingSystem system = writingSystems.last(); + + if (!*hasLatin) { + // we need to show something return system; } - if (writingSystems.count() <= 2 - && writingSystems.last() > QFontDatabase::Armenian - && writingSystems.last() < QFontDatabase::Vietnamese) { - system = writingSystems.last(); + if (writingSystems.count() == 1 && system > QFontDatabase::Cyrillic) return system; - } - if (writingSystems.count() <= 5 - && writingSystems.last() >= QFontDatabase::SimplifiedChinese - && writingSystems.last() <= QFontDatabase::Korean) - system = writingSystems.last(); + if (writingSystems.count() <= 2 && system > QFontDatabase::Armenian && system < QFontDatabase::Vietnamese) + return system; - return system; + if (writingSystems.count() <= 5 && system >= QFontDatabase::SimplifiedChinese && system <= QFontDatabase::Korean) + return system; + + return QFontDatabase::Any; } class QFontFamilyDelegate : public QAbstractItemDelegate