1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.gui.fontmetrics; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.global; 17 import qt.core.namespace; 18 import qt.core.qchar; 19 import qt.core.rect; 20 import qt.core.shareddata; 21 import qt.core.size; 22 import qt.core.string; 23 import qt.core.typeinfo; 24 import qt.gui.font; 25 import qt.gui.paintdevice; 26 import qt.helpers; 27 28 /+ #ifndef QT_INCLUDE_COMPAT 29 #endif +/ 30 31 32 33 /// Binding for C++ class [QFontMetrics](https://doc.qt.io/qt-6/qfontmetrics.html). 34 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QFontMetrics 35 { 36 public: 37 /+ explicit +/this(ref const(QFont) ); 38 mixin(changeWindowsMangling(q{mangleClassesTailConst}, q{ 39 this(ref const(QFont) font, const(QPaintDevice) pd); 40 })); 41 @disable this(this); 42 this(ref const(QFontMetrics) ); 43 ~this(); 44 45 /+ref QFontMetrics operator =(ref const(QFontMetrics) );+/ 46 /+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFontMetrics) +/ 47 48 /+ void swap(QFontMetrics &other) noexcept 49 { qSwap(d, other.d); } +/ 50 51 int ascent() const; 52 int capHeight() const; 53 int descent() const; 54 int height() const; 55 int leading() const; 56 int lineSpacing() const; 57 int minLeftBearing() const; 58 int minRightBearing() const; 59 int maxWidth() const; 60 61 int xHeight() const; 62 int averageCharWidth() const; 63 64 bool inFont(QChar) const; 65 bool inFontUcs4(uint ucs4) const; 66 67 int leftBearing(QChar) const; 68 int rightBearing(QChar) const; 69 70 int horizontalAdvance(ref const(QString) , int len = -1) const; 71 int horizontalAdvance(QChar) const; 72 73 QRect boundingRect(QChar) const; 74 75 QRect boundingRect(ref const(QString) text) const; 76 QRect boundingRect(ref const(QRect) r, int flags, ref const(QString) text, int tabstops = 0, int* tabarray = null) const; 77 pragma(inline, true) QRect boundingRect(int x, int y, int w, int h, int flags, ref const(QString) text, 78 int tabstops = 0, int* tabarray = null) const 79 { auto tmp = QRect(x, y, w, h); return boundingRect(tmp, flags, text, tabstops, tabarray); } 80 QSize size(int flags, ref const(QString) str, int tabstops = 0, int* tabarray = null) const; 81 82 QRect tightBoundingRect(ref const(QString) text) const; 83 84 QString elidedText(ref const(QString) text, /+ Qt:: +/qt.core.namespace.TextElideMode mode, int width, int flags = 0) const; 85 86 int underlinePos() const; 87 int overlinePos() const; 88 int strikeOutPos() const; 89 int lineWidth() const; 90 91 qreal fontDpi() const; 92 93 /+bool operator ==(ref const(QFontMetrics) other) const;+/ 94 /+pragma(inline, true) bool operator !=(ref const(QFontMetrics) other) const { return !operator==(other); }+/ 95 96 private: 97 /+ friend class QFontMetricsF; +/ 98 /+ friend class QStackTextEngine; +/ 99 100 QExplicitlySharedDataPointer!(QFontPrivate) d; 101 mixin(CREATE_CONVENIENCE_WRAPPERS); 102 } 103 104 /+ Q_DECLARE_SHARED(QFontMetrics) +/ 105 106 /// Binding for C++ class [QFontMetricsF](https://doc.qt.io/qt-6/qfontmetricsf.html). 107 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QFontMetricsF 108 { 109 public: 110 /+ explicit +/this(ref const(QFont) font); 111 mixin(changeWindowsMangling(q{mangleClassesTailConst}, q{ 112 this(ref const(QFont) font, const(QPaintDevice) pd); 113 })); 114 this(ref const(QFontMetrics) ); 115 @disable this(this); 116 this(ref const(QFontMetricsF) ); 117 ~this(); 118 119 /+ref QFontMetricsF operator =(ref const(QFontMetricsF) );+/ 120 /+ref QFontMetricsF operator =(ref const(QFontMetrics) );+/ 121 /+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QFontMetricsF) +/ 122 123 /+ void swap(QFontMetricsF &other) noexcept { qSwap(d, other.d); } +/ 124 125 qreal ascent() const; 126 qreal capHeight() const; 127 qreal descent() const; 128 qreal height() const; 129 qreal leading() const; 130 qreal lineSpacing() const; 131 qreal minLeftBearing() const; 132 qreal minRightBearing() const; 133 qreal maxWidth() const; 134 135 qreal xHeight() const; 136 qreal averageCharWidth() const; 137 138 bool inFont(QChar) const; 139 bool inFontUcs4(uint ucs4) const; 140 141 qreal leftBearing(QChar) const; 142 qreal rightBearing(QChar) const; 143 144 qreal horizontalAdvance(ref const(QString) string, int length = -1) const; 145 qreal horizontalAdvance(QChar) const; 146 147 QRectF boundingRect(ref const(QString) string) const; 148 QRectF boundingRect(QChar) const; 149 QRectF boundingRect(ref const(QRectF) r, int flags, ref const(QString) string, int tabstops = 0, int* tabarray = null) const; 150 QSizeF size(int flags, ref const(QString) str, int tabstops = 0, int* tabarray = null) const; 151 152 QRectF tightBoundingRect(ref const(QString) text) const; 153 154 QString elidedText(ref const(QString) text, /+ Qt:: +/qt.core.namespace.TextElideMode mode, qreal width, int flags = 0) const; 155 156 qreal underlinePos() const; 157 qreal overlinePos() const; 158 qreal strikeOutPos() const; 159 qreal lineWidth() const; 160 161 qreal fontDpi() const; 162 163 /+bool operator ==(ref const(QFontMetricsF) other) const;+/ 164 /+pragma(inline, true) bool operator !=(ref const(QFontMetricsF) other) const { return !operator==(other); }+/ 165 166 private: 167 QExplicitlySharedDataPointer!(QFontPrivate) d; 168 mixin(CREATE_CONVENIENCE_WRAPPERS); 169 } 170 171 /+ Q_DECLARE_SHARED(QFontMetricsF) +/ 172