summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfont.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-11-03 11:16:30 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-11-03 13:06:14 +0100
commit7d875b4306dbd144afb332389e75dba331986cca (patch)
tree528d487b930adc62da18833e6c50adb810624ce0 /src/gui/text/qfont.cpp
parent9a50d62039179346b2d7f6de2756c912c1fd1dec (diff)
Add deprecated accessors for legacy font weight
In 3558704ed5c3d2c6dc6d024dfa454997469ca75f we changed the font weights to use the OpenType weights rather than our own non-standard scale. This can cause difficulty for people who have legacy font weights stored as ints and no way to convert them. Therefore, we add accessors for the legacy font weights to ease the transition. Change-Id: I2a591c62895dfa1a2310d9a2d0cdcf08de08f3a4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/text/qfont.cpp')
-rw-r--r--src/gui/text/qfont.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index c168423533..9ea6970409 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1148,6 +1148,46 @@ QFont::Weight QFont::weight() const
\value Black 900
*/
+#if QT_DEPRECATED_SINCE(6, 0)
+/*!
+ \obsolete Use setWeight() instead.
+
+ Sets the weight of the font to \a weight using the legacy font weight
+ scale of Qt 5 and previous versions.
+
+ Since Qt 6, the OpenType standard's font weight scale is used instead
+ of a non-standard scale. This requires conversion from values that
+ use the old scale. For convenience, this function may be used when
+ porting from code which uses the old weight scale.
+
+ \note If styleName() is set, this value may be ignored for font selection.
+
+ \sa setWeight(), weight(), legacyWeight(), QFontInfo
+*/
+void QFont::setLegacyWeight(int legacyWeight)
+{
+ setWeight(QFont::Weight(qt_legacyToOpenTypeWeight(legacyWeight)));
+}
+
+/*!
+ \obsolete Use weight() instead.
+
+ Returns the weight of the font converted to the non-standard font
+ weight scale used in Qt 5 and earlier versions.
+
+ Since Qt 6, the OpenType standard's font weight scale is used instead
+ of a non-standard scale. This requires conversion from values that
+ use the old scale. For convenience, this function may be used when
+ porting from code which uses the old weight scale.
+
+ \sa setWeight(), weight(), QFontInfo
+*/
+int QFont::legacyWeight() const
+{
+ return qt_openTypeToLegacyWeight(weight());
+}
+#endif // QT_DEPRECATED_SINCE(6, 0)
+
/*!
Sets the weight of the font to \a weight, using the scale defined by
\l QFont::Weight enumeration.
@@ -2599,6 +2639,28 @@ QFont::Style QFontInfo::style() const
return (QFont::Style)engine->fontDef.style;
}
+
+#if QT_DEPRECATED_SINCE(6, 0)
+/*!
+ \obsolete Use weight() instead.
+
+ Returns the weight of the font converted to the non-standard font
+ weight scale used in Qt 5 and earlier versions.
+
+ Since Qt 6, the OpenType standard's font weight scale is used instead
+ of a non-standard scale. This requires conversion from values that
+ use the old scale. For convenience, this function may be used when
+ porting from code which uses the old weight scale.
+
+ \sa setWeight(), weight(), QFontInfo
+*/
+int QFontInfo::legacyWeight() const
+{
+ return qt_openTypeToLegacyWeight(weight());
+}
+#endif // QT_DEPRECATED_SINCE(6, 0)
+
+
/*!
Returns the weight of the matched window system font.