QFontVariableAxis Class

The QFontVariableAxis class represents a variable axis in a font. More...

Header: #include <QFontVariableAxis>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Since: Qt 6.9

Note: All functions in this class are reentrant.

Public Functions

QFontVariableAxis(const QFontVariableAxis &axis)
~QFontVariableAxis()
qreal defaultValue() const
qreal maximumValue() const
qreal minimumValue() const
QString name() const
void setDefaultValue(qreal defaultValue)
void setMaximumValue(qreal maximumValue)
void setMinimumValue(qreal minimumValue)
void setName(const QString &name)
void setTag(QFont::Tag tag)
QFont::Tag tag() const
QFontVariableAxis &operator=(const QFontVariableAxis &axis)

Detailed Description

Variable fonts provide a way to store multiple variations (with different weights, widths or styles) in the same font file. The variations are given as floating point values for a pre-defined set of parameters, called "variable axes".

Specific parameterizations (sets of values for the axes in a font) can be selected using the properties in QFont, same as with traditional subfamilies that are defined as stand-alone font files. But with variable fonts, arbitrary values can be provided for each axis to gain a fine-grained customization of the font's appearance.

QFontVariableAxis contains information of one axis. Use QFontInfo::variableAxes() to retrieve a list of the variable axes defined for a given font. Specific values can be provided for an axis by using QFont::setVariableAxis() and passing in the tag().

Note: On Windows, variable axes are not supported if the optional GDI font backend is in use.

Member Function Documentation

QFontVariableAxis::QFontVariableAxis(const QFontVariableAxis &axis)

Creates a QFontVariableAxis object that is a copy of the given axis.

See also operator=().

[noexcept] QFontVariableAxis::~QFontVariableAxis()

Destroys this QFontVariableAxis object.

qreal QFontVariableAxis::defaultValue() const

Returns the default value of the axis. This is the value the axis will have if none has been provided in the QFont query.

Note: Getter function for property defaultValue.

See also setDefaultValue(), minimumValue(), and maximumValue().

qreal QFontVariableAxis::maximumValue() const

Returns the maximum value of the axis. Setting the axis to a value which is higher than this is not supported.

Note: Getter function for property maximumValue.

See also setMaximumValue(), minimumValue(), and defaultValue().

qreal QFontVariableAxis::minimumValue() const

Returns the minimum value of the axis. Setting the axis to a value which is lower than this is not supported.

Note: Getter function for property minimumValue.

See also setMinimumValue(), maximumValue(), and defaultValue().

QString QFontVariableAxis::name() const

Returns the name of the axis, if provided by the font.

Note: Getter function for property name.

See also setName() and tag().

void QFontVariableAxis::setDefaultValue(qreal defaultValue)

Sets the default value of this QFontVariableAxis to defaultValue.

Note: Typically, there will be no need to call this function as it will not affect the font itself, only this particular representation.

See also defaultValue().

void QFontVariableAxis::setMaximumValue(qreal maximumValue)

Sets the maximum value of this QFontVariableAxis to maximumValue.

Note: Typically, there will be no need to call this function as it will not affect the font itself, only this particular representation.

See also maximumValue().

void QFontVariableAxis::setMinimumValue(qreal minimumValue)

Sets the minimum value of this QFontVariableAxis to minimumValue.

Note: Typically, there will be no need to call this function as it will not affect the font itself, only this particular representation.

See also minimumValue().

void QFontVariableAxis::setName(const QString &name)

Sets the name of this QFontVariableAxis to name.

Note: Typically, there will be no need to call this function as it will not affect the font itself, only this particular representation.

See also name().

void QFontVariableAxis::setTag(QFont::Tag tag)

Sets the tag of QFontVariableAxis to tag.

Note: Typically, there will be no need to call this function as it will not affect the font itself, only this particular representation.

See also tag().

QFont::Tag QFontVariableAxis::tag() const

Returns the tag of the axis. This is a four-character sequence which identifies the axis. Certain tags have standardized meanings, such as "wght" (weight) and "wdth" (width), but any sequence of four latin-1 characters is a valid tag. By convention, non-standard/custom axes are denoted by tags in all uppercase.

See also setTag(), QFont::setVariableAxis(), and name().

QFontVariableAxis &QFontVariableAxis::operator=(const QFontVariableAxis &axis)

Assigns the given axis to this QFontVariableAxis.

See also QFontVariableAxis().