summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2012-05-10 16:50:33 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-16 04:24:58 +0200
commit4959e6af8e5b8d6dbf677fcd0802e4dc43083308 (patch)
tree8ca30874ac4c426350771dbd76bae73c66980ce8
parentba300f42bdbf1e033616ee8a8054d84613b55aca (diff)
Support specifying fallbacks in font request on QPA
Because the QPA font database would query fallback families inside findFont(), support for requesting multiple font families in order of preference (like QFont("Times New Roman, Arial")) did not work, because the Arial fallback was never attempted. To fix this, we pass in the queried fallbacks and make sure they are tried before any platform specific fallbacks. Task-number: QTBUG-20986 Change-Id: Idb2b717856f013ce2874f00a8debaff60176d2fc Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
-rw-r--r--src/gui/text/qfont_p.h2
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp18
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp5
3 files changed, 18 insertions, 7 deletions
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index 13e5fcbedd..55e1b701c0 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -56,6 +56,7 @@
#include "QtGui/qfont.h"
#include "QtCore/qmap.h"
#include "QtCore/qobject.h"
+#include "QtCore/qstringlist.h"
#include <private/qunicodetables_p.h>
#include <QtGui/qfontdatabase.h>
#include "private/qfixed_p.h"
@@ -79,6 +80,7 @@ struct QFontDef
QString family;
QString styleName;
+ QStringList fallBackFamilies;
qreal pointSize;
qreal pixelSize;
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index d7e5441931..622eda0ec6 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -317,7 +317,12 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
if (!engine) {
if (!request.family.isEmpty()) {
- QStringList fallbacks = fallbackFamilies(request.family,QFont::Style(request.style),QFont::StyleHint(request.styleHint),QUnicodeTables::Script(script));
+ QStringList fallbacks = request.fallBackFamilies
+ + fallbackFamilies(request.family,
+ QFont::Style(request.style),
+ QFont::StyleHint(request.styleHint),
+ QUnicodeTables::Script(script));
+
for (int i = 0; !engine && i < fallbacks.size(); i++) {
QFontDef def = request;
def.family = fallbacks.at(i);
@@ -386,7 +391,13 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
QStringList family_list;
if (!req.family.isEmpty()) {
- family_list = familyList(req);
+ QStringList familiesForRequest = familyList(req);
+
+ // Add primary selection
+ family_list << familiesForRequest.takeFirst();
+
+ // Fallbacks requested in font request
+ req.fallBackFamilies = familiesForRequest;
// add the default family
QString defaultFamily = QGuiApplication::font().family();
@@ -409,6 +420,9 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
fe = 0;
}
+
+ // No need to check requested fallback families again
+ req.fallBackFamilies.clear();
}
if (fe->symbol || (d->request.styleStrategy & QFont::NoFontMerging)) {
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index 7e0a60c859..4d50601664 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -1592,11 +1592,6 @@ void tst_QCssParser::extractFontFamily()
extractor.extractFont(&fnt, &adjustment);
QFontInfo info(fnt);
- // Note, we have to QSKIP rather than QEXPECT_FAIL because font lookup is broken
- // such that it may work or not work depending on the order in which fonts were
- // loaded from disk: ### fixme: Check platforms
- QSKIP("QTBUG-20986 may fail on qpa");
-
QTEST(info.family(), "expectedFamily");
}