Warning, file /include/QtGui/qfontmetrics.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QFONTMETRICS_H
0005 #define QFONTMETRICS_H
0006
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtGui/qfont.h>
0009
0010 #ifndef QT_INCLUDE_COMPAT
0011 #include <QtCore/qrect.h>
0012 #endif
0013 #include <QtCore/qshareddata.h>
0014
0015 QT_BEGIN_NAMESPACE
0016
0017 class QRect;
0018 class QTextOption;
0019
0020 class Q_GUI_EXPORT QFontMetrics
0021 {
0022 public:
0023 explicit QFontMetrics(const QFont &);
0024 QFontMetrics(const QFont &font, const QPaintDevice *pd);
0025 QFontMetrics(const QFontMetrics &);
0026 ~QFontMetrics();
0027
0028 QFontMetrics &operator=(const QFontMetrics &);
0029 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFontMetrics)
0030
0031 void swap(QFontMetrics &other) noexcept
0032 { d.swap(other.d); }
0033
0034 int ascent() const;
0035 int capHeight() const;
0036 int descent() const;
0037 int height() const;
0038 int leading() const;
0039 int lineSpacing() const;
0040 int minLeftBearing() const;
0041 int minRightBearing() const;
0042 int maxWidth() const;
0043
0044 int xHeight() const;
0045 int averageCharWidth() const;
0046
0047 bool inFont(QChar) const;
0048 bool inFontUcs4(uint ucs4) const;
0049
0050 int leftBearing(QChar) const;
0051 int rightBearing(QChar) const;
0052
0053 int horizontalAdvance(const QString &, int len = -1) const;
0054 int horizontalAdvance(const QString &, const QTextOption &textOption) const;
0055 int horizontalAdvance(QChar) const;
0056
0057 QRect boundingRect(QChar) const;
0058
0059 QRect boundingRect(const QString &text) const;
0060 QRect boundingRect(const QString &text, const QTextOption &textOption) const;
0061 QRect boundingRect(const QRect &r, int flags, const QString &text, int tabstops = 0, int *tabarray = nullptr) const;
0062 inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text,
0063 int tabstops = 0, int *tabarray = nullptr) const
0064 { return boundingRect(QRect(x, y, w, h), flags, text, tabstops, tabarray); }
0065 QSize size(int flags, const QString& str, int tabstops = 0, int *tabarray = nullptr) const;
0066
0067 QRect tightBoundingRect(const QString &text) const;
0068 QRect tightBoundingRect(const QString &text, const QTextOption &textOption) const;
0069
0070 QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags = 0) const;
0071
0072 int underlinePos() const;
0073 int overlinePos() const;
0074 int strikeOutPos() const;
0075 int lineWidth() const;
0076
0077 qreal fontDpi() const;
0078
0079 bool operator==(const QFontMetrics &other) const;
0080 inline bool operator !=(const QFontMetrics &other) const { return !operator==(other); }
0081
0082 private:
0083 friend class QFontMetricsF;
0084 friend class QStackTextEngine;
0085
0086 QExplicitlySharedDataPointer<QFontPrivate> d;
0087 };
0088
0089 Q_DECLARE_SHARED(QFontMetrics)
0090
0091 class Q_GUI_EXPORT QFontMetricsF
0092 {
0093 public:
0094 explicit QFontMetricsF(const QFont &font);
0095 QFontMetricsF(const QFont &font, const QPaintDevice *pd);
0096 QFontMetricsF(const QFontMetrics &);
0097 QFontMetricsF(const QFontMetricsF &);
0098 ~QFontMetricsF();
0099
0100 QFontMetricsF &operator=(const QFontMetricsF &);
0101 QFontMetricsF &operator=(const QFontMetrics &);
0102 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFontMetricsF)
0103
0104 void swap(QFontMetricsF &other) noexcept { d.swap(other.d); }
0105
0106 qreal ascent() const;
0107 qreal capHeight() const;
0108 qreal descent() const;
0109 qreal height() const;
0110 qreal leading() const;
0111 qreal lineSpacing() const;
0112 qreal minLeftBearing() const;
0113 qreal minRightBearing() const;
0114 qreal maxWidth() const;
0115
0116 qreal xHeight() const;
0117 qreal averageCharWidth() const;
0118
0119 bool inFont(QChar) const;
0120 bool inFontUcs4(uint ucs4) const;
0121
0122 qreal leftBearing(QChar) const;
0123 qreal rightBearing(QChar) const;
0124
0125 qreal horizontalAdvance(const QString &string, int length = -1) const;
0126 qreal horizontalAdvance(QChar) const;
0127 qreal horizontalAdvance(const QString &string, const QTextOption &textOption) const;
0128
0129 QRectF boundingRect(const QString &string) const;
0130 QRectF boundingRect(const QString &text, const QTextOption &textOption) const;
0131 QRectF boundingRect(QChar) const;
0132 QRectF boundingRect(const QRectF &r, int flags, const QString& string, int tabstops = 0, int *tabarray = nullptr) const;
0133 QSizeF size(int flags, const QString& str, int tabstops = 0, int *tabarray = nullptr) const;
0134
0135 QRectF tightBoundingRect(const QString &text) const;
0136 QRectF tightBoundingRect(const QString &text, const QTextOption &textOption) const;
0137
0138 QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags = 0) const;
0139
0140 qreal underlinePos() const;
0141 qreal overlinePos() const;
0142 qreal strikeOutPos() const;
0143 qreal lineWidth() const;
0144
0145 qreal fontDpi() const;
0146
0147 bool operator==(const QFontMetricsF &other) const;
0148 inline bool operator !=(const QFontMetricsF &other) const { return !operator==(other); }
0149
0150 private:
0151 QExplicitlySharedDataPointer<QFontPrivate> d;
0152 };
0153
0154 Q_DECLARE_SHARED(QFontMetricsF)
0155
0156 QT_END_NAMESPACE
0157
0158 #endif