Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickfontmetrics.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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
5
6#include <QFont>
7
9
39 QObject(parent),
40 m_metrics(m_font)
41{
42}
43
50{
51 return m_font;
52}
53
55{
56 if (m_font != font) {
57 m_font = font;
58 m_metrics = QFontMetricsF(m_font);
59 emit fontChanged(m_font);
60 }
61}
62
71{
72 return m_metrics.ascent();
73}
74
83{
84 return m_metrics.descent();
85}
86
95{
96 return m_metrics.height();
97}
98
107{
108 return m_metrics.leading();
109}
110
119{
120 return m_metrics.lineSpacing();
121}
122
131{
132 return m_metrics.minLeftBearing();
133}
134
143{
144 return m_metrics.minRightBearing();
145}
146
155{
156 return m_metrics.maxWidth();
157}
158
167{
168 return m_metrics.xHeight();
169}
170
179{
180 return m_metrics.averageCharWidth();
181}
182
192{
193 return m_metrics.underlinePos();
194}
195
205{
206 return m_metrics.overlinePos();
207}
208
218{
219 return m_metrics.strikeOutPos();
220}
221
231{
232 return m_metrics.lineWidth();
233}
234
249{
250 return m_metrics.horizontalAdvance(text);
251}
252
266{
267 return m_metrics.boundingRect(text);
268}
269
283{
284 return m_metrics.tightBoundingRect(text);
285}
286
310
312
313#include "moc_qquickfontmetrics_p.cpp"
\reentrant \inmodule QtGui
qreal height() const
Returns the height of the font.
qreal leading() const
Returns the leading of the font.
qreal ascent() const
Returns the ascent of the font.
QRectF boundingRect(const QString &string) const
Returns the bounding rectangle of the characters in the string specified by text.
qreal strikeOutPos() const
Returns the distance from the base line to where the strikeout line should be drawn.
qreal horizontalAdvance(const QString &string, int length=-1) const
Returns the horizontal advance in pixels of the first length characters of text.
qreal lineSpacing() const
Returns the distance from one base line to the next.
qreal averageCharWidth() const
qreal descent() const
Returns the descent of the font.
qreal xHeight() const
Returns the 'x' height of the font.
qreal lineWidth() const
Returns the width of the underline and strikeout lines, adjusted for the point size of the font.
qreal underlinePos() const
Returns the distance from the base line to where an underscore should be drawn.
QRectF tightBoundingRect(const QString &text) const
qreal minRightBearing() const
Returns the minimum right bearing of the font.
qreal overlinePos() const
Returns the distance from the base line to where an overline should be drawn.
QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags=0) const
qreal minLeftBearing() const
Returns the minimum left bearing of the font.
qreal maxWidth() const
Returns the width of the widest character in the font.
\reentrant
Definition qfont.h:22
\inmodule QtCore
Definition qobject.h:103
void fontChanged(const QFont &font)
Q_INVOKABLE qreal advanceWidth(const QString &text) const
\qmlmethod qreal QtQuick::FontMetrics::advanceWidth(string text)
Q_INVOKABLE QRectF boundingRect(const QString &text) const
\qmlmethod rect QtQuick::FontMetrics::boundingRect(string text)
Q_INVOKABLE QRectF tightBoundingRect(const QString &text) const
\qmlmethod rect QtQuick::FontMetrics::tightBoundingRect(string text)
Q_INVOKABLE QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags=0) const
\qmlmethod string QtQuick::FontMetrics::elidedText(string text, enumeration mode, real width,...
QQuickFontMetrics(QObject *parent=nullptr)
\qmltype FontMetrics \instantiates QQuickFontMetrics \inqmlmodule QtQuick
void setFont(const QFont &font)
\inmodule QtCore\reentrant
Definition qrect.h:484
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString text
Combined button and popup list for selecting options.
TextElideMode
Definition qnamespace.h:188
GLenum mode
GLint GLsizei width
GLbitfield flags
#define emit
double qreal
Definition qtypes.h:187