1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.gui.rawfont; 15 extern(C++): 16 17 import qt.config; 18 import qt.helpers; 19 version(QT_NO_RAWFONT){}else 20 { 21 import qt.core.bytearray; 22 import qt.core.flags; 23 import qt.core.global; 24 import qt.core.list; 25 import qt.core.point; 26 import qt.core.qchar; 27 import qt.core.rect; 28 import qt.core.shareddata; 29 import qt.core.string; 30 import qt.core.vector; 31 import qt.gui.font; 32 import qt.gui.fontdatabase; 33 import qt.gui.image; 34 import qt.gui.painterpath; 35 import qt.gui.transform; 36 } 37 38 version(QT_NO_RAWFONT){}else 39 { 40 41 42 43 extern(C++, class) struct QRawFontPrivate; 44 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QRawFont 45 { 46 public: 47 enum AntialiasingType { 48 PixelAntialiasing, 49 SubPixelAntialiasing 50 } 51 52 enum LayoutFlag { 53 SeparateAdvances = 0, 54 KernedAdvances = 1, 55 UseDesignMetrics = 2 56 } 57 /+ Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag) +/ 58 alias LayoutFlags = QFlags!(LayoutFlag); 59 @disable this(); 60 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 61 ref typeof(this) rawConstructor(); 62 static typeof(this) create() 63 { 64 typeof(this) r = typeof(this).init; 65 r.rawConstructor(); 66 return r; 67 } 68 69 this(ref const(QString) fileName, 70 qreal pixelSize, 71 QFont.HintingPreference hintingPreference = QFont.HintingPreference.PreferDefaultHinting); 72 this(ref const(QByteArray) fontData, 73 qreal pixelSize, 74 QFont.HintingPreference hintingPreference = QFont.HintingPreference.PreferDefaultHinting); 75 @disable this(this); 76 this(ref const(QRawFont) other); 77 /+ QRawFont &operator=(QRawFont &&other) noexcept { swap(other); return *this; } +/ 78 /+ref QRawFont operator =(ref const(QRawFont) other);+/ 79 ~this(); 80 81 /+ void swap(QRawFont &other) noexcept { qSwap(d, other.d); } +/ 82 83 bool isValid() const; 84 85 /+bool operator ==(ref const(QRawFont) other) const;+/ 86 /+pragma(inline, true) bool operator !=(ref const(QRawFont) other) const 87 { return !operator==(other); }+/ 88 89 QString familyName() const; 90 QString styleName() const; 91 92 QFont.Style style() const; 93 int weight() const; 94 95 QVector!(quint32) glyphIndexesForString(ref const(QString) text) const; 96 pragma(inline, true) QVector!(QPointF) advancesForGlyphIndexes(ref const(QVector!(quint32)) glyphIndexes) const 97 { 98 return advancesForGlyphIndexes(glyphIndexes, QRawFont.LayoutFlags.SeparateAdvances); 99 } 100 pragma(inline, true) QVector!(QPointF) advancesForGlyphIndexes(ref const(QVector!(quint32)) glyphIndexes, LayoutFlags layoutFlags) const 101 /+pragma(inline, true) QVector!(QPointF) advancesForGlyphIndexes(ref const(QVector!(quint32)) glyphIndexes, QRawFont.LayoutFlags layoutFlags) const+/ 102 { 103 QVector!QPointF advances = QVector!QPointF(glyphIndexes.size()); 104 if (advancesForGlyphIndexes(cast(const(quint32)*)(glyphIndexes.constData()), advances.data(), glyphIndexes.size(), layoutFlags)) 105 return advances; 106 return QVector!(QPointF).create(); 107 } 108 bool glyphIndexesForChars(const(QChar)* chars, int numChars, quint32* glyphIndexes, int* numGlyphs) const; 109 bool advancesForGlyphIndexes(const(quint32)* glyphIndexes, QPointF* advances, int numGlyphs) const; 110 bool advancesForGlyphIndexes(const(quint32)* glyphIndexes, QPointF* advances, int numGlyphs, LayoutFlags layoutFlags) const; 111 112 QImage alphaMapForGlyph(quint32 glyphIndex, 113 AntialiasingType antialiasingType = AntialiasingType.SubPixelAntialiasing, 114 ref const(QTransform) transform = globalInitVar!QTransform) const; 115 QPainterPath pathForGlyph(quint32 glyphIndex) const; 116 QRectF boundingRect(quint32 glyphIndex) const; 117 118 void setPixelSize(qreal pixelSize); 119 qreal pixelSize() const; 120 121 QFont.HintingPreference hintingPreference() const; 122 123 qreal ascent() const; 124 qreal capHeight() const; 125 qreal descent() const; 126 qreal leading() const; 127 qreal xHeight() const; 128 qreal averageCharWidth() const; 129 qreal maxCharWidth() const; 130 qreal lineThickness() const; 131 qreal underlinePosition() const; 132 133 qreal unitsPerEm() const; 134 135 void loadFromFile(ref const(QString) fileName, 136 qreal pixelSize, 137 QFont.HintingPreference hintingPreference); 138 139 void loadFromData(ref const(QByteArray) fontData, 140 qreal pixelSize, 141 QFont.HintingPreference hintingPreference); 142 143 bool supportsCharacter(uint ucs4) const; 144 bool supportsCharacter(QChar character) const; 145 QList!(QFontDatabase.WritingSystem) supportedWritingSystems() const; 146 147 QByteArray fontTable(const(char)* tagName) const; 148 149 static QRawFont fromFont(ref const(QFont) font, 150 QFontDatabase.WritingSystem writingSystem = QFontDatabase.WritingSystem.Any); 151 152 private: 153 /+ friend class QRawFontPrivate; +/ 154 /+ friend class QTextLayout; +/ 155 /+ friend class QTextEngine; +/ 156 157 QExplicitlySharedDataPointer!(QRawFontPrivate) d; 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) QIncompatibleFlag operator |(QRawFont.LayoutFlags.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/ 162 163 /+ Q_DECLARE_SHARED(QRawFont) 164 165 Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags) 166 Q_GUI_EXPORT uint qHash(const QRawFont &font, uint seed = 0) noexcept; +/ 167 168 169 } 170