summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextformat.h
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/gui/text/qtextformat.h
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/gui/text/qtextformat.h')
-rw-r--r--src/gui/text/qtextformat.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index 87de1e7fbd..9cdd34be2c 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -192,7 +192,9 @@ public:
FontStyleName = 0x1FE8,
FontLetterSpacingType = 0x1FE9,
FontStretch = 0x1FEA,
+#if QT_DEPRECATED_SINCE(6, 0)
FontFamily = 0x2000,
+#endif
FontPointSize = 0x2001,
FontSizeAdjustment = 0x2002,
FontSizeIncrement = FontSizeAdjustment, // old name, compat
@@ -454,10 +456,12 @@ public:
void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior = FontPropertiesAll);
QFont font() const;
- inline void setFontFamily(const QString &family)
- { setProperty(FontFamily, family); }
- inline QString fontFamily() const
- { return stringProperty(FontFamily); }
+#if QT_DEPRECATED_SINCE(6, 0)
+ QT_DEPRECATED_VERSION_X_6_0("Use setFontFamilies instead") inline void setFontFamily(const QString &family)
+ { setProperty(FontFamilies, QVariant(QStringList(family))); }
+ QT_DEPRECATED_VERSION_X_6_0("Use fontFamilies instead") inline QString fontFamily() const
+ { return property(FontFamilies).toStringList().first(); }
+#endif
inline void setFontFamilies(const QStringList &families)
{ setProperty(FontFamilies, QVariant(families)); }