Add deprecated accessors for legacy font weight
In 3558704ed5 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>
bb10
parent
9a50d62039
commit
7d875b4306
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -275,6 +275,11 @@ public:
|
|||
inline uint resolveMask() const { return resolve_mask; }
|
||||
inline void setResolveMask(uint mask) { resolve_mask = mask; }
|
||||
|
||||
#if QT_DEPRECATED_SINCE(6, 0)
|
||||
QT_DEPRECATED_VERSION_X_6_0("Use setWeight() instead") void setLegacyWeight(int legacyWeight);
|
||||
QT_DEPRECATED_VERSION_X_6_0("Use weight() instead") int legacyWeight() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
explicit QFont(QFontPrivate *);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,10 @@ public:
|
|||
bool fixedPitch() const;
|
||||
QFont::StyleHint styleHint() const;
|
||||
|
||||
#if QT_DEPRECATED_SINCE(6, 0)
|
||||
QT_DEPRECATED_VERSION_X_6_0("Use weight() instead") int legacyWeight() const;
|
||||
#endif
|
||||
|
||||
bool exactMatch() const;
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Reference in New Issue