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
qquickfontmetrics_p.h
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKFONTMETRICS_H
6#define QQUICKFONTMETRICS_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qtquickglobal_p.h>
20
21#include <QtQml/qqml.h>
22
23#include <QtGui/qfontmetrics.h>
24
25#include <QtCore/qobject.h>
26
27QT_BEGIN_NAMESPACE
28
29class QFont;
30
31class Q_QUICK_EXPORT QQuickFontMetrics : public QObject
32{
33 Q_OBJECT
34
35 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
36 Q_PROPERTY(qreal ascent READ ascent NOTIFY fontChanged)
37 Q_PROPERTY(qreal descent READ descent NOTIFY fontChanged)
38 Q_PROPERTY(qreal height READ height NOTIFY fontChanged)
39 Q_PROPERTY(qreal leading READ leading NOTIFY fontChanged)
40 Q_PROPERTY(qreal lineSpacing READ lineSpacing NOTIFY fontChanged)
41 Q_PROPERTY(qreal minimumLeftBearing READ minimumLeftBearing NOTIFY fontChanged)
42 Q_PROPERTY(qreal minimumRightBearing READ minimumRightBearing NOTIFY fontChanged)
43 Q_PROPERTY(qreal maximumCharacterWidth READ maximumCharacterWidth NOTIFY fontChanged)
44 Q_PROPERTY(qreal xHeight READ xHeight NOTIFY fontChanged)
45 Q_PROPERTY(qreal averageCharacterWidth READ averageCharacterWidth NOTIFY fontChanged)
46 Q_PROPERTY(qreal underlinePosition READ underlinePosition NOTIFY fontChanged)
47 Q_PROPERTY(qreal overlinePosition READ overlinePosition NOTIFY fontChanged)
48 Q_PROPERTY(qreal strikeOutPosition READ strikeOutPosition NOTIFY fontChanged)
49 Q_PROPERTY(qreal lineWidth READ lineWidth NOTIFY fontChanged)
50 Q_PROPERTY(qreal capitalHeight READ capitalHeight NOTIFY fontChanged REVISION (6,9))
51 QML_NAMED_ELEMENT(FontMetrics)
52 QML_ADDED_IN_VERSION(2, 4)
53public:
54 explicit QQuickFontMetrics(QObject *parent = nullptr);
55
56 QFont font() const;
57 void setFont(const QFont &font);
58
59 qreal ascent() const;
60 qreal descent() const;
61 qreal capitalHeight() const;
62 qreal height() const;
63 qreal leading() const;
64 qreal lineSpacing() const;
65 qreal minimumLeftBearing() const;
66 qreal minimumRightBearing() const;
67 qreal maximumCharacterWidth() const;
68
69 qreal xHeight() const;
70 qreal averageCharacterWidth() const;
71
72 qreal underlinePosition() const;
73 qreal overlinePosition() const;
74 qreal strikeOutPosition() const;
75 qreal lineWidth() const;
76
77 Q_INVOKABLE qreal advanceWidth(const QString &text) const;
78 Q_INVOKABLE QRectF boundingRect(const QString &text) const;
79 Q_INVOKABLE QRectF tightBoundingRect(const QString &text) const;
80 Q_INVOKABLE QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags = 0) const;
81
82Q_SIGNALS:
83 void fontChanged(const QFont &font);
84
85private:
86 QFont m_font;
87 QFontMetricsF m_metrics;
88};
89
90QT_END_NAMESPACE
91
92#endif // QQUICKFONTMETRICS_H