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.rawfont; 13 extern(C++): 14 15 import qt.config; 16 import qt.helpers; 17 version(QT_NO_RAWFONT){}else 18 { 19 import qt.core.bytearray; 20 import qt.core.flags; 21 import qt.core.global; 22 import qt.core.list; 23 import qt.core.point; 24 import qt.core.qchar; 25 import qt.core.rect; 26 import qt.core.shareddata; 27 import qt.core.string; 28 import qt.core.typeinfo; 29 import qt.gui.font; 30 import qt.gui.fontdatabase; 31 import qt.gui.image; 32 import qt.gui.painterpath; 33 import qt.gui.transform; 34 } 35 36 version(QT_NO_RAWFONT){}else 37 { 38 39 40 41 extern(C++, class) struct QRawFontPrivate; 42 /// Binding for C++ class [QRawFont](https://doc.qt.io/qt-6/qrawfont.html). 43 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QRawFont 44 { 45 public: 46 enum AntialiasingType { 47 PixelAntialiasing, 48 SubPixelAntialiasing 49 } 50 51 enum LayoutFlag { 52 SeparateAdvances = 0, 53 KernedAdvances = 1, 54 UseDesignMetrics = 2 55 } 56 /+ Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag) +/ 57 alias LayoutFlags = QFlags!(LayoutFlag); 58 @disable this(); 59 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 60 ref typeof(this) rawConstructor(); 61 static typeof(this) create() 62 { 63 typeof(this) r = typeof(this).init; 64 r.rawConstructor(); 65 return r; 66 } 67 68 this(ref const(QString) fileName, 69 qreal pixelSize, 70 QFont.HintingPreference hintingPreference = QFont.HintingPreference.PreferDefaultHinting); 71 this(ref const(QByteArray) fontData, 72 qreal pixelSize, 73 QFont.HintingPreference hintingPreference = QFont.HintingPreference.PreferDefaultHinting); 74 @disable this(this); 75 this(ref const(QRawFont) other); 76 /+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QRawFont) +/ 77 /+ref QRawFont operator =(ref const(QRawFont) other);+/ 78 ~this(); 79 80 /+ void swap(QRawFont &other) noexcept { qSwap(d, other.d); } +/ 81 82 bool isValid() const; 83 84 /+bool operator ==(ref const(QRawFont) other) const;+/ 85 /+pragma(inline, true) bool operator !=(ref const(QRawFont) other) const 86 { return !operator==(other); }+/ 87 88 QString familyName() const; 89 QString styleName() const; 90 91 QFont.Style style() const; 92 int weight() const; 93 94 /+ QList!(quint32) glyphIndexesForString(ref const(QString) text) const; 95 pragma(inline, true) QList!(QPointF) advancesForGlyphIndexes(ref const(QList!(quint32)) glyphIndexes) const 96 { 97 return advancesForGlyphIndexes(glyphIndexes, QRawFont.LayoutFlags.SeparateAdvances); 98 } 99 pragma(inline, true) QList!(QPointF) advancesForGlyphIndexes(ref const(QList!(quint32)) glyphIndexes, 100 LayoutFlags layoutFlags) const 101 { 102 auto advances = QList!(QPointF)(glyphIndexes.size()); 103 if (advancesForGlyphIndexes(glyphIndexes.constData(), advances.data(), glyphIndexes.size(), layoutFlags)) 104 return advances; 105 return QList!(QPointF)(); 106 } +/ 107 bool glyphIndexesForChars(const(QChar)* chars, int numChars, quint32* glyphIndexes, int* numGlyphs) const; 108 bool advancesForGlyphIndexes(const(quint32)* glyphIndexes, QPointF* advances, int numGlyphs) const; 109 bool advancesForGlyphIndexes(const(quint32)* glyphIndexes, QPointF* advances, int numGlyphs, LayoutFlags layoutFlags) const; 110 111 QImage alphaMapForGlyph(quint32 glyphIndex, 112 AntialiasingType antialiasingType = AntialiasingType.SubPixelAntialiasing, 113 ref const(QTransform) transform = globalInitVar!QTransform) const; 114 QPainterPath pathForGlyph(quint32 glyphIndex) const; 115 QRectF boundingRect(quint32 glyphIndex) const; 116 117 void setPixelSize(qreal pixelSize); 118 qreal pixelSize() const; 119 120 QFont.HintingPreference hintingPreference() const; 121 122 qreal ascent() const; 123 qreal capHeight() const; 124 qreal descent() const; 125 qreal leading() const; 126 qreal xHeight() const; 127 qreal averageCharWidth() const; 128 qreal maxCharWidth() const; 129 qreal lineThickness() const; 130 qreal underlinePosition() const; 131 132 qreal unitsPerEm() const; 133 134 void loadFromFile(ref const(QString) fileName, 135 qreal pixelSize, 136 QFont.HintingPreference hintingPreference); 137 138 void loadFromData(ref const(QByteArray) fontData, 139 qreal pixelSize, 140 QFont.HintingPreference hintingPreference); 141 142 bool supportsCharacter(uint ucs4) const; 143 bool supportsCharacter(QChar character) const; 144 QList!(QFontDatabase.WritingSystem) supportedWritingSystems() const; 145 146 QByteArray fontTable(const(char)* tagName) const; 147 148 static QRawFont fromFont(ref const(QFont) font, 149 QFontDatabase.WritingSystem writingSystem = QFontDatabase.WritingSystem.Any); 150 151 private: 152 /+ friend class QRawFontPrivate; +/ 153 /+ friend class QTextLayout; +/ 154 /+ friend class QTextEngine; +/ 155 156 QExplicitlySharedDataPointer!(QRawFontPrivate) d; 157 mixin(CREATE_CONVENIENCE_WRAPPERS); 158 } 159 /+pragma(inline, true) QFlags!(QRawFont.LayoutFlags.enum_type) operator |(QRawFont.LayoutFlags.enum_type f1, QRawFont.LayoutFlags.enum_type f2)/+noexcept+/{return QFlags!(QRawFont.LayoutFlags.enum_type)(f1)|f2;}+/ 160 /+pragma(inline, true) QFlags!(QRawFont.LayoutFlags.enum_type) operator |(QRawFont.LayoutFlags.enum_type f1, QFlags!(QRawFont.LayoutFlags.enum_type) f2)/+noexcept+/{return f2|f1;}+/ 161 /+pragma(inline, true) QFlags!(QRawFont.LayoutFlags.enum_type) operator &(QRawFont.LayoutFlags.enum_type f1, QRawFont.LayoutFlags.enum_type f2)/+noexcept+/{return QFlags!(QRawFont.LayoutFlags.enum_type)(f1)&f2;}+/ 162 /+pragma(inline, true) QFlags!(QRawFont.LayoutFlags.enum_type) operator &(QRawFont.LayoutFlags.enum_type f1, QFlags!(QRawFont.LayoutFlags.enum_type) f2)/+noexcept+/{return f2&f1;}+/ 163 /+pragma(inline, true) void operator +(QRawFont.LayoutFlags.enum_type f1, QRawFont.LayoutFlags.enum_type f2)/+noexcept+/;+/ 164 /+pragma(inline, true) void operator +(QRawFont.LayoutFlags.enum_type f1, QFlags!(QRawFont.LayoutFlags.enum_type) f2)/+noexcept+/;+/ 165 /+pragma(inline, true) void operator +(int f1, QFlags!(QRawFont.LayoutFlags.enum_type) f2)/+noexcept+/;+/ 166 /+pragma(inline, true) void operator -(QRawFont.LayoutFlags.enum_type f1, QRawFont.LayoutFlags.enum_type f2)/+noexcept+/;+/ 167 /+pragma(inline, true) void operator -(QRawFont.LayoutFlags.enum_type f1, QFlags!(QRawFont.LayoutFlags.enum_type) f2)/+noexcept+/;+/ 168 /+pragma(inline, true) void operator -(int f1, QFlags!(QRawFont.LayoutFlags.enum_type) f2)/+noexcept+/;+/ 169 /+pragma(inline, true) QIncompatibleFlag operator |(QRawFont.LayoutFlags.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/ 170 /+pragma(inline, true) void operator +(int f1, QRawFont.LayoutFlags.enum_type f2)/+noexcept+/;+/ 171 /+pragma(inline, true) void operator +(QRawFont.LayoutFlags.enum_type f1, int f2)/+noexcept+/;+/ 172 /+pragma(inline, true) void operator -(int f1, QRawFont.LayoutFlags.enum_type f2)/+noexcept+/;+/ 173 /+pragma(inline, true) void operator -(QRawFont.LayoutFlags.enum_type f1, int f2)/+noexcept+/;+/ 174 175 /+ Q_DECLARE_SHARED(QRawFont) 176 177 Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags) 178 Q_GUI_EXPORT size_t qHash(const QRawFont &font, size_t seed = 0) noexcept; +/ 179 180 181 } 182