Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickfontinfo.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qquickfontinfo_p.h"
6
7
QT_BEGIN_NAMESPACE
8
9
/*!
10
\qmltype FontInfo
11
\nativetype QQuickFontInfo
12
\inqmlmodule QtQuick
13
\since 6.9
14
\ingroup qtquick-text-utility
15
\brief Provides info about how a given font query is resolved.
16
17
FontInfo provides information about the actual font which is matched for a font query by Qt's
18
font selection system.
19
20
It corresponds to the class QFontInfo in C++.
21
22
\code
23
FontInfo {
24
id: fontInfo
25
font.family: "Arial"
26
}
27
28
Text {
29
text: fontInfo.family === "Arial"
30
? "System has 'Arial' font"
31
: "System does not have 'Arial' font"
32
}
33
\endcode
34
35
\sa FontMetrics, TextMetrics
36
*/
37
QQuickFontInfo::QQuickFontInfo(QObject *parent)
38
: QObject(parent)
39
, m_info(m_font)
40
{
41
}
42
43
/*
44
\internal
45
*/
46
QQuickFontInfo::~QQuickFontInfo()
47
=
default
;
48
49
/*!
50
\qmlproperty font QtQuick::FontInfo::font
51
52
This property holds the font which will be resolved by the FontInfo.
53
*/
54
QFont QQuickFontInfo::font()
const
55
{
56
return
m_font;
57
}
58
59
void
QQuickFontInfo::setFont(QFont font)
60
{
61
if
(m_font != font) {
62
m_font = font;
63
m_info = QFontInfo(m_font);
64
emit fontChanged();
65
}
66
}
67
68
/*!
69
\qmlproperty string QtQuick::FontInfo::family
70
71
This property holds the family of the matched font.
72
73
\sa {QFontInfo::family()}
74
*/
75
QString QQuickFontInfo::family()
const
76
{
77
return
m_info.family();
78
}
79
80
/*!
81
\qmlproperty real QtQuick::FontInfo::styleName
82
83
This property holds the style name (or "sub-family") of the mathed font.
84
85
\sa {QFontInfo::styleName()}
86
*/
87
QString QQuickFontInfo::styleName()
const
88
{
89
return
m_info.styleName();
90
}
91
92
/*!
93
\qmlproperty int QtQuick::FontInfo::pixelSize
94
95
This property holds the pixel size of the matched font.
96
97
\sa {QFontInfo::pixelSize()}
98
*/
99
int
QQuickFontInfo::pixelSize()
const
100
{
101
return
m_info.pixelSize();
102
}
103
104
/*!
105
\qmlproperty real QtQuick::FontInfo::pointSize
106
107
This property holds the point size of the matched font.
108
109
\sa {QFontInfo::pointSizeF()}
110
*/
111
qreal QQuickFontInfo::pointSize()
const
112
{
113
return
m_info.pointSizeF();
114
}
115
116
/*!
117
\qmlproperty bool QtQuick::FontInfo::italic
118
119
This property holds the italic value of the matched font.
120
121
\sa {QFontInfo::italic()}
122
*/
123
bool
QQuickFontInfo::italic()
const
124
{
125
return
m_info.italic();
126
}
127
128
/*!
129
\qmlproperty int QtQuick::FontInfo::weight
130
131
This property holds the weight of the matched font.
132
133
\sa bold, {QFontInfo::weight()}
134
*/
135
int
QQuickFontInfo::weight()
const
136
{
137
return
m_info.weight();
138
}
139
140
/*!
141
\qmlproperty bool QtQuick::FontInfo::bold
142
143
This property is true if weight() would return a value greater than Font.Normal; otherwise
144
returns false.
145
146
\sa weight, {QFontInfo::bold()}
147
*/
148
bool
QQuickFontInfo::bold()
const
149
{
150
return
m_info.bold();
151
}
152
153
/*!
154
\qmlproperty bool QtQuick::FontInfo::fixedPitch
155
156
This property holds the fixed pitch value of the matched font.
157
158
\sa {QFontInfo::fixedPitch()}
159
*/
160
bool
QQuickFontInfo::fixedPitch()
const
161
{
162
return
m_info.fixedPitch();
163
}
164
165
/*!
166
\qmlproperty enum QtQuick::FontInfo::style
167
168
This property holds the style of the matched font.
169
170
\value Font.StyleNormal Contains normal glyphs without italic slant.
171
\value Font.StyleItalic Contains glyphs designed to be used for representing italicized
172
text.
173
\value Font.StyleOblique Contains glyphs with an italic appearance, typically not
174
specially designed, but rather produced by applying a slant on the
175
font family's normal glyphs.
176
177
\sa {QFontInfo::style()}
178
*/
179
QQuickFontEnums::Style QQuickFontInfo::style()
const
180
{
181
return
QQuickFontEnums::Style(m_info.style());
182
}
183
184
/*!
185
\qmlproperty list QtQuick::FontInfo::variableAxes
186
187
This property holds the variable axes supported by the matched font. The list consists of
188
QFontVariableAxis objects, which have the properties \c{tag}, \c{name}, \c{minimumValue},
189
\c{maximumValue}, and \c{defaultValue}.
190
191
\sa {QFontInfo::variableAxes()}, QFontVariableAxis
192
*/
193
QList<QFontVariableAxis> QQuickFontInfo::variableAxes()
const
194
{
195
return
m_info.variableAxes();
196
}
197
198
QT_END_NAMESPACE
199
200
#
include
"moc_qquickfontinfo_p.cpp"
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtdeclarative
src
quick
util
qquickfontinfo.cpp
Generated on
for Qt by
1.14.0