summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-10-19 11:39:24 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-11-20 14:30:22 +0100
commitd8602ce58b6ef268be84b9aa0166b0c3fa6a96e8 (patch)
tree3665176e38aac64015213085f3d0e867ec11e612 /src/plugins
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 <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm2
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp2
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle.cpp4
3 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 4c7064a845..648f900aa5 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -94,7 +94,7 @@ void QCocoaMenu::setMinimumWidth(int width)
void QCocoaMenu::setFont(const QFont &font)
{
if (font.resolveMask()) {
- NSFont *customMenuFont = [NSFont fontWithName:font.family().toNSString()
+ NSFont *customMenuFont = [NSFont fontWithName:font.families().first().toNSString()
size:font.pointSize()];
m_nativeMenu.font = customMenuFont;
}
diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
index 258c4305ff..16d5eb3ab4 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
@@ -573,7 +573,7 @@ static QFont qt_fontFromString(const QString &name)
QString family = QString::fromUtf8(pango_font_description_get_family(desc));
if (!family.isEmpty())
- font.setFamily(family);
+ font.setFamilies(QStringList{family});
font.setWeight(QFont::Weight(pango_font_description_get_weight(desc)));
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
index af1c17fa9b..f7496b62ca 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
@@ -2301,7 +2301,7 @@ void QWindowsVistaStyle::polish(QWidget *widget)
#if QT_CONFIG(commandlinkbutton)
else if (qobject_cast<QCommandLinkButton*>(widget)) {
QFont buttonFont = widget->font();
- buttonFont.setFamily(QLatin1String("Segoe UI"));
+ buttonFont.setFamilies(QStringList{QLatin1String("Segoe UI")});
widget->setFont(buttonFont);
}
#endif // QT_CONFIG(commandlinkbutton)
@@ -2386,7 +2386,7 @@ void QWindowsVistaStyle::unpolish(QWidget *widget)
else if (qobject_cast<QCommandLinkButton*>(widget)) {
QFont font = QApplication::font("QCommandLinkButton");
QFont widgetFont = widget->font();
- widgetFont.setFamily(font.family()); //Only family set by polish
+ widgetFont.setFamilies(font.families()); //Only family set by polish
widget->setFont(widgetFont);
}
#endif // QT_CONFIG(commandlinkbutton)