1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qfontvariableaxis.h"
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
class QFontVariableAxisPrivate : public QSharedData
{
public:
QFont::Tag tag;
QString name;
qreal minimumValue = 0.0;
qreal maximumValue = 0.0;
qreal defaultValue = 0.0;
};
/*!
\class QFontVariableAxis
\reentrant
\inmodule QtGui
\ingroup shared
\since 6.9
\brief The QFontVariableAxis class represents a variable axis in a font.
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 \l{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 \l{QFont::setVariableAxis()} and passing in the \l{tag()}.
\note On Windows, variable axes are not supported if the optional GDI font backend is in use.
*/
QFontVariableAxis::QFontVariableAxis()
: d_ptr(new QFontVariableAxisPrivate)
{
}
/*!
Destroys this QFontVariableAxis object.
*/
QFontVariableAxis::~QFontVariableAxis() = default;
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QFontVariableAxisPrivate)
/*!
Creates a QFontVariableAxis object that is a copy of the given \a axis.
\sa operator=()
*/
QFontVariableAxis::QFontVariableAxis(const QFontVariableAxis &axis) = default;
/*!
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.
\sa QFont::setVariableAxis(), name()
*/
QFont::Tag QFontVariableAxis::tag() const
{
Q_D(const QFontVariableAxis);
return d->tag;
}
/*!
Sets the tag of QFontVariableAxis to \a tag.
\note Typically, there will be no need to call this function as it will not affect the font
itself, only this particular representation.
\sa tag()
*/
void QFontVariableAxis::setTag(QFont::Tag tag)
{
if (d_func()->tag == tag)
return;
detach();
Q_D(QFontVariableAxis);
d->tag = tag;
}
/*!
Returns the name of the axis, if provided by the font.
\sa tag()
*/
QString QFontVariableAxis::name() const
{
Q_D(const QFontVariableAxis);
return d->name;
}
/*!
Sets the name of this QFontVariableAxis to \a name.
\note Typically, there will be no need to call this function as it will not affect the font
itself, only this particular representation.
\sa name()
*/
void QFontVariableAxis::setName(const QString &name)
{
if (d_func()->name == name)
return;
detach();
Q_D(QFontVariableAxis);
d->name = name;
}
/*!
Returns the minimum value of the axis. Setting the axis to a value which is lower than this
is not supported.
\sa maximumValue(), defaultValue()
*/
qreal QFontVariableAxis::minimumValue() const
{
Q_D(const QFontVariableAxis);
return d->minimumValue;
}
/*!
Sets the minimum value of this QFontVariableAxis to \a minimumValue.
\note Typically, there will be no need to call this function as it will not affect the font
itself, only this particular representation.
\sa minimumValue()
*/
void QFontVariableAxis::setMinimumValue(qreal minimumValue)
{
if (d_func()->minimumValue == minimumValue)
return;
detach();
Q_D(QFontVariableAxis);
d->minimumValue = minimumValue;
}
/*!
Returns the maximum value of the axis. Setting the axis to a value which is higher than this
is not supported.
\sa minimumValue(), defaultValue()
*/
qreal QFontVariableAxis::maximumValue() const
{
Q_D(const QFontVariableAxis);
return d->maximumValue;
}
/*!
Sets the maximum value of this QFontVariableAxis to \a maximumValue.
\note Typically, there will be no need to call this function as it will not affect the font
itself, only this particular representation.
\sa maximumValue()
*/
void QFontVariableAxis::setMaximumValue(qreal maximumValue)
{
if (d_func()->maximumValue == maximumValue)
return;
detach();
Q_D(QFontVariableAxis);
d->maximumValue = maximumValue;
}
/*!
Returns the default value of the axis. This is the value the axis will have if none has been
provided in the QFont query.
\sa minimumValue(), maximumValue()
*/
qreal QFontVariableAxis::defaultValue() const
{
Q_D(const QFontVariableAxis);
return d->defaultValue;
}
/*!
Sets the default value of this QFontVariableAxis to \a defaultValue.
\note Typically, there will be no need to call this function as it will not affect the font
itself, only this particular representation.
\sa defaultValue()
*/
void QFontVariableAxis::setDefaultValue(qreal defaultValue)
{
if (d_func()->defaultValue == defaultValue)
return;
detach();
Q_D(QFontVariableAxis);
d->defaultValue = defaultValue;
}
/*!
Assigns the given \a axis to this QFontVariableAxis.
\sa QFontVariableAxis()
*/
QFontVariableAxis &QFontVariableAxis::operator=(const QFontVariableAxis &axis)
{
QFontVariableAxis copy(axis);
swap(copy);
return *this;
}
/*!
\internal
*/
void QFontVariableAxis::detach()
{
d_ptr.detach();
}
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QFontVariableAxis &axis)
{
QDebugStateSaver save(debug);
debug.nospace().noquote();
const QString name = axis.name();
if (!name.isEmpty())
debug << name << '(';
debug << axis.tag();
if (!name.isEmpty())
debug << ')';
debug << '[' << axis.minimumValue() << "..." << axis.maximumValue()
<< "; default=" << axis.defaultValue() << ']';
return debug;
}
#endif
QT_END_NAMESPACE
|