Windows: Improve Freetype font database registry check for fonts
authorMiikka Heikkinen <miikka.heikkinen@digia.com>
Fri, 30 Mar 2012 11:51:42 +0000 (14:51 +0300)
committerQt by Nokia <qt-info@nokia.com>
Tue, 3 Apr 2012 08:45:02 +0000 (10:45 +0200)
Some non-scalable fonts like "Courier" list some numbers after the font
name in Windows registry, e.g. "Courier 10,12,15". These are not part
of the font name and therefore confused the algorithm looking for font
files. Improved the algorithm to ignore this kind of number list.
Single numbers are still expected to be part of the font name.

Task-number: QTBUG-24970
Change-Id: I3fe45b798f44bee962e5b3aa748fc4717f723353
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp

index 500a1ee..e84f0c7 100644 (file)
@@ -195,9 +195,11 @@ static bool addFontToDatabase(QString familyName, const QString &scriptName,
         const QStringList allKeys = fontRegistry.allKeys();
         allFonts.reserve(allKeys.size());
         const QString trueType = QStringLiteral("(TrueType)");
+        const QRegExp sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+"));
         foreach (const QString &key, allKeys) {
             QString realKey = key;
             realKey.remove(trueType);
+            realKey.remove(sizeListMatch);
             QStringList fonts;
             const QStringList fontNames = realKey.trimmed().split(QLatin1Char('&'));
             foreach (const QString &fontName, fontNames)