summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qcssparser.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-05-18 12:59:14 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-05-18 13:07:53 (GMT)
commite8ac2b958d92319da7c725f0c30f8ba5fe06497b (patch)
treebb3c2748ee8db5639c14dcbbdc6f9c269f5414e0 /src/gui/text/qcssparser.cpp
parent3c40b1af35319f1fd1b10c97b954adff3abbe9b0 (diff)
downloadQt-e8ac2b958d92319da7c725f0c30f8ba5fe06497b.zip
Qt-e8ac2b958d92319da7c725f0c30f8ba5fe06497b.tar.gz
Qt-e8ac2b958d92319da7c725f0c30f8ba5fe06497b.tar.bz2
QCss: font-family handle fallback font specs
if one specify more than one parameter in font-family, e.g., font-family: Verdana, Arial Qt should fallback on the second font if the first cannot be found. QFont::setFamily handle the case when the family name contains a comas, so we do not need to handle that specially in the css parser code. Task-number: 252311 Reviewed-by: Thomas Zander
Diffstat (limited to 'src/gui/text/qcssparser.cpp')
-rw-r--r--src/gui/text/qcssparser.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 8214e54..38621c1 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1161,13 +1161,20 @@ static bool setFontWeightFromValue(const Value &value, QFont *font)
return true;
}
-static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font)
+/** \internal
+ * parse the font family from the values (starting from index \a start)
+ * and set it the \a font
+ * \returns true if a family was extracted.
+ */
+static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font, int start = 0)
{
QString family;
- for (int i = 0; i < values.count(); ++i) {
+ for (int i = start; i < values.count(); ++i) {
const Value &v = values.at(i);
- if (v.type == Value::TermOperatorComma)
- break;
+ if (v.type == Value::TermOperatorComma) {
+ family += QLatin1Char(',');
+ continue;
+ }
const QString str = v.variant.toString();
if (str.isEmpty())
break;
@@ -1221,9 +1228,7 @@ static void parseShorthandFontProperty(const QVector<Value> &values, QFont *font
}
if (i < values.count()) {
- QString fam = values.at(i).variant.toString();
- if (!fam.isEmpty())
- font->setFamily(fam);
+ setFontFamilyFromValues(values, font, i);
}
}