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.font; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.global; 19 import qt.core.metatype; 20 import qt.core.objectdefs; 21 import qt.core.shareddata; 22 import qt.core.string; 23 import qt.core.stringlist; 24 import qt.core.typeinfo; 25 import qt.core.variant; 26 import qt.gui.paintdevice; 27 import qt.helpers; 28 29 extern(C++, class) struct QFontPrivate; /* don't touch */ 30 /+ class QStringList; 31 class QVariant; +/ 32 33 @(QMetaType.Type.QFont) @Q_MOVABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QFont 34 { 35 mixin(Q_GADGET); 36 public: 37 enum StyleHint { 38 Helvetica, SansSerif = StyleHint.Helvetica, 39 Times, Serif = StyleHint.Times, 40 Courier, TypeWriter = StyleHint.Courier, 41 OldEnglish, Decorative = StyleHint.OldEnglish, 42 System, 43 AnyStyle, 44 Cursive, 45 Monospace, 46 Fantasy 47 } 48 /+ Q_ENUM(StyleHint) +/ 49 50 enum StyleStrategy { 51 PreferDefault = 0x0001, 52 PreferBitmap = 0x0002, 53 PreferDevice = 0x0004, 54 PreferOutline = 0x0008, 55 ForceOutline = 0x0010, 56 PreferMatch = 0x0020, 57 PreferQuality = 0x0040, 58 PreferAntialias = 0x0080, 59 NoAntialias = 0x0100, 60 /+ #if QT_DEPRECATED_SINCE(5, 15) +/ 61 OpenGLCompatible /+ Q_DECL_ENUMERATOR_DEPRECATED +/ = 0x0200, 62 ForceIntegerMetrics /+ Q_DECL_ENUMERATOR_DEPRECATED +/ = 0x0400, 63 /+ #endif +/ 64 NoSubpixelAntialias = 0x0800, 65 PreferNoShaping = 0x1000, 66 NoFontMerging = 0x8000 67 } 68 /+ Q_ENUM(StyleStrategy) +/ 69 70 enum HintingPreference { 71 PreferDefaultHinting = 0, 72 PreferNoHinting = 1, 73 PreferVerticalHinting = 2, 74 PreferFullHinting = 3 75 } 76 /+ Q_ENUM(HintingPreference) +/ 77 78 // Mapping OpenType weight value. 79 enum Weight { 80 Thin = 0, // 100 81 ExtraLight = 12, // 200 82 Light = 25, // 300 83 Normal = 50, // 400 84 Medium = 57, // 500 85 DemiBold = 63, // 600 86 Bold = 75, // 700 87 ExtraBold = 81, // 800 88 Black = 87 // 900 89 } 90 /+ Q_ENUM(Weight) +/ 91 92 enum Style { 93 StyleNormal, 94 StyleItalic, 95 StyleOblique 96 } 97 /+ Q_ENUM(Style) +/ 98 99 enum Stretch { 100 AnyStretch = 0, 101 UltraCondensed = 50, 102 ExtraCondensed = 62, 103 Condensed = 75, 104 SemiCondensed = 87, 105 Unstretched = 100, 106 SemiExpanded = 112, 107 Expanded = 125, 108 ExtraExpanded = 150, 109 UltraExpanded = 200 110 } 111 /+ Q_ENUM(Stretch) +/ 112 113 enum Capitalization { 114 MixedCase, 115 AllUppercase, 116 AllLowercase, 117 SmallCaps, 118 Capitalize 119 } 120 /+ Q_ENUM(Capitalization) +/ 121 122 enum SpacingType { 123 PercentageSpacing, 124 AbsoluteSpacing 125 } 126 /+ Q_ENUM(SpacingType) +/ 127 128 enum ResolveProperties { 129 NoPropertiesResolved = 0x0000, 130 FamilyResolved = 0x0001, 131 SizeResolved = 0x0002, 132 StyleHintResolved = 0x0004, 133 StyleStrategyResolved = 0x0008, 134 WeightResolved = 0x0010, 135 StyleResolved = 0x0020, 136 UnderlineResolved = 0x0040, 137 OverlineResolved = 0x0080, 138 StrikeOutResolved = 0x0100, 139 FixedPitchResolved = 0x0200, 140 StretchResolved = 0x0400, 141 KerningResolved = 0x0800, 142 CapitalizationResolved = 0x1000, 143 LetterSpacingResolved = 0x2000, 144 WordSpacingResolved = 0x4000, 145 HintingPreferenceResolved = 0x8000, 146 StyleNameResolved = 0x10000, 147 FamiliesResolved = 0x20000, 148 AllPropertiesResolved = 0x3ffff 149 } 150 /+ Q_ENUM(ResolveProperties) +/ 151 152 @disable this(); 153 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 154 ref typeof(this) rawConstructor(); 155 static typeof(this) create() 156 { 157 typeof(this) r = typeof(this).init; 158 r.rawConstructor(); 159 return r; 160 } 161 162 this(ref const(QString) family, int pointSize = -1, int weight = -1, bool italic = false); 163 /+ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/ 164 this(ref const(QFont) font, QPaintDevice pd); 165 /+ #endif +/ 166 this(ref const(QFont) font, const(QPaintDevice) pd); 167 @disable this(this); 168 this(ref const(QFont) font); 169 ~this(); 170 171 /+ void swap(QFont &other) 172 { qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); } +/ 173 174 QString family() const; 175 void setFamily(ref const(QString) ); 176 177 QStringList families() const; 178 void setFamilies(ref const(QStringList) ); 179 180 QString styleName() const; 181 void setStyleName(ref const(QString) ); 182 183 int pointSize() const; 184 void setPointSize(int); 185 qreal pointSizeF() const; 186 void setPointSizeF(qreal); 187 188 int pixelSize() const; 189 void setPixelSize(int); 190 191 int weight() const; 192 void setWeight(int); 193 194 pragma(inline, true) bool bold() const 195 { return weight() > Weight.Medium; } 196 pragma(inline, true) void setBold(bool enable) 197 { setWeight(enable ? Weight.Bold : Weight.Normal); } 198 199 void setStyle(Style style); 200 Style style() const; 201 202 pragma(inline, true) bool italic() const 203 { 204 return (style() != Style.StyleNormal); 205 } 206 pragma(inline, true) void setItalic(bool b) { 207 setStyle(b ? Style.StyleItalic : Style.StyleNormal); 208 } 209 210 bool underline() const; 211 void setUnderline(bool); 212 213 bool overline() const; 214 void setOverline(bool); 215 216 bool strikeOut() const; 217 void setStrikeOut(bool); 218 219 bool fixedPitch() const; 220 void setFixedPitch(bool); 221 222 bool kerning() const; 223 void setKerning(bool); 224 225 StyleHint styleHint() const; 226 StyleStrategy styleStrategy() const; 227 void setStyleHint(StyleHint, StyleStrategy /+ = PreferDefault +/); 228 void setStyleStrategy(StyleStrategy s); 229 230 int stretch() const; 231 void setStretch(int); 232 233 qreal letterSpacing() const; 234 SpacingType letterSpacingType() const; 235 void setLetterSpacing(SpacingType type, qreal spacing); 236 237 qreal wordSpacing() const; 238 void setWordSpacing(qreal spacing); 239 240 void setCapitalization(Capitalization); 241 Capitalization capitalization() const; 242 243 void setHintingPreference(HintingPreference hintingPreference); 244 HintingPreference hintingPreference() const; 245 246 /+ #if QT_DEPRECATED_SINCE(5, 5) +/ 247 bool rawMode() const; 248 void setRawMode(bool); 249 /+ #endif +/ 250 251 // dupicated from QFontInfo 252 bool exactMatch() const; 253 254 /+ref QFont operator =(ref const(QFont) );+/ 255 /+bool operator ==(ref const(QFont) ) const;+/ 256 /+bool operator !=(ref const(QFont) ) const;+/ 257 /+bool operator <(ref const(QFont) ) const;+/ 258 /+auto opCast(T : QVariant)() const;+/ 259 bool isCopyOf(ref const(QFont) ) const; 260 /+ inline QFont &operator=(QFont &&other) noexcept 261 { qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); return *this; } +/ 262 263 /+ #if QT_DEPRECATED_SINCE(5, 3) +/ 264 // needed for X11 265 /+ QT_DEPRECATED +/ void setRawName(ref const(QString) ); 266 /+ QT_DEPRECATED +/ QString rawName() const; 267 /+ #endif +/ 268 269 QString key() const; 270 271 QString toString() const; 272 bool fromString(ref const(QString) ); 273 274 static QString substitute(ref const(QString) ); 275 static QStringList substitutes(ref const(QString) ); 276 static QStringList substitutions(); 277 static void insertSubstitution(ref const(QString), ref const(QString) ); 278 static void insertSubstitutions(ref const(QString), ref const(QStringList) ); 279 static void removeSubstitutions(ref const(QString) ); 280 /+ #if QT_DEPRECATED_SINCE(5, 0) 281 static QT_DEPRECATED void removeSubstitution(const QString &family) { removeSubstitutions(family); } 282 #endif +/ 283 static void initialize(); 284 static void cleanup(); 285 static void cacheStatistics(); 286 287 QString defaultFamily() const; 288 /+ #if QT_DEPRECATED_SINCE(5, 13) +/ 289 /+ QT_DEPRECATED +/ QString lastResortFamily() const; 290 /+ QT_DEPRECATED +/ QString lastResortFont() const; 291 /+ #endif +/ 292 293 QFont resolve(ref const(QFont) ) const; 294 pragma(inline, true) uint resolve() const { return resolve_mask; } 295 pragma(inline, true) void resolve(uint mask) { resolve_mask = mask; } 296 297 private: 298 /+ explicit +/this(QFontPrivate* ); 299 300 void detach(); 301 302 303 /+ friend class QFontPrivate; +/ 304 /+ friend class QFontDialogPrivate; +/ 305 /+ friend class QFontMetrics; +/ 306 /+ friend class QFontMetricsF; +/ 307 /+ friend class QFontInfo; +/ 308 /+ friend class QPainter; +/ 309 /+ friend class QPainterPrivate; +/ 310 /+ friend class QApplication; +/ 311 /+ friend class QWidget; +/ 312 /+ friend class QWidgetPrivate; +/ 313 /+ friend class QTextLayout; +/ 314 /+ friend class QTextEngine; +/ 315 /+ friend class QStackTextEngine; +/ 316 /+ friend class QTextLine; +/ 317 /+ friend struct QScriptLine; +/ 318 /+ friend class QOpenGLContext; +/ 319 /+ friend class QWin32PaintEngine; +/ 320 /+ friend class QAlphaPaintEngine; +/ 321 /+ friend class QPainterPath; +/ 322 /+ friend class QTextItemInt; +/ 323 /+ friend class QPicturePaintEngine; +/ 324 /+ friend class QPainterReplayer; +/ 325 /+ friend class QPaintBufferEngine; +/ 326 /+ friend class QCommandLinkButtonPrivate; +/ 327 /+ friend class QFontEngine; +/ 328 329 /+ #ifndef QT_NO_DATASTREAM +/ 330 version(QT_NO_DATASTREAM){}else 331 { 332 /+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QFont &); +/ 333 /+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QFont &); +/ 334 } 335 /+ #endif 336 337 #ifndef QT_NO_DEBUG_STREAM 338 friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QFont &); 339 #endif +/ 340 341 QExplicitlySharedDataPointer!(QFontPrivate) d; 342 uint resolve_mask; 343 } 344 345 /+ Q_DECLARE_SHARED(QFont) 346 347 Q_GUI_EXPORT uint qHash(const QFont &font, uint seed = 0) noexcept; 348 349 350 351 /***************************************************************************** 352 QFont stream functions 353 *****************************************************************************/ 354 355 #ifndef QT_NO_DATASTREAM 356 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QFont &); 357 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QFont &); 358 #endif 359 360 #ifndef QT_NO_DEBUG_STREAM 361 Q_GUI_EXPORT QDebug operator<<(QDebug, const QFont &); 362 #endif +/ 363