summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtexthtmlparser.cpp
diff options
context:
space:
mode:
authorAndy Shaw <[email protected]>2020-10-19 11:39:24 +0200
committerAndy Shaw <[email protected]>2020-11-20 14:30:22 +0100
commitd8602ce58b6ef268be84b9aa0166b0c3fa6a96e8 (patch)
tree3665176e38aac64015213085f3d0e867ec11e612 /src/gui/text/qtexthtmlparser.cpp
parent13c460d0ff1a4eecfb7b1bc43a863783ed59a2bd (diff)
QFont: Prefer setFamilies() over setFamily()
By depending on setFamilies() then we can be sure that font names with spaces, commas, quotes and so on are correctly handled without being misinterpreted. For now it will split on the comma when a string containing one is passed to setFamily. But from Qt 6.2 this will be removed to preserve the family string as a convenience function. [ChangeLog][QtGui][QFont] Indicated that setFamilies/families is preferred over setFamily/family to ensure that font family names are preserved when spaces, commas and so on are used in the name. Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
Diffstat (limited to 'src/gui/text/qtexthtmlparser.cpp')
-rw-r--r--src/gui/text/qtexthtmlparser.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 996980b7640..ed1c6d97f63 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1585,9 +1585,8 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes)
for (const QString &family : values)
families << family.trimmed();
node->charFormat.setFontFamilies(families);
- node->charFormat.setFontFamily(families.at(0));
} else {
- node->charFormat.setFontFamily(value);
+ node->charFormat.setFontFamilies(QStringList(value));
}
} else if (key == QLatin1String("color")) {
QColor c; c.setNamedColor(value);
@@ -2064,7 +2063,7 @@ QList<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode &n
decl.d->propertyId = QCss::FontFamily;
QList<QCss::Value> values;
val.type = QCss::Value::String;
- val.variant = QFontDatabase::systemFont(QFontDatabase::FixedFont).family();
+ val.variant = QFontDatabase::systemFont(QFontDatabase::FixedFont).families().first();
values << val;
decl.d->values = values;
decl.d->inheritable = true;