

QFont serifFont( "Times", 10, QFont ::Bold) When a QPainter draws a character from a font the QFont will report whether or not it has the character if it does not, QPainter will draw an unfilled square. If a chosen font does not include all the characters that need to be displayed, QFont will try to find the characters in the nearest equivalent fonts. You can set the application's default font with QGuiApplication::setFont(). Note that a QGuiApplication instance must exist before a QFont can be used. To load a specific physical font, typically represented by a single file, use QRawFont instead. the pixel length of a string using QFontMetrics::width().Īttributes which are not specifically set will not affect the font selection algorithm, and default values will be preferred instead.

Use QFontMetricsF to get measurements, e.g. If the window system provides an exact match exactMatch() returns true. The attributes of the font that is actually used are retrievable from a QFontInfo object. Qt will use the font with the specified attributes, or if no matching font exists, Qt will use the closest matching installed font. When you create a QFont object you specify various attributes that you want the font to have.

QFont can be regarded as a query for one or more fonts on the system. SetStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy = PreferDefault) SetLetterSpacing(QFont::SpacingType type, qreal spacing) SetHintingPreference(QFont::HintingPreference hintingPreference) SetFamilies(const QStringList & families) SetCapitalization(QFont::Capitalization caps) QFont(const QFont & font, const QPaintDevice * pd) QFont(const QStringList & families, int pointSize = -1, int weight = -1, bool italic = false) QFont(const QString & family, int pointSize = -1, int weight = -1, bool italic = false)
