This feature can be disabled using QFont::NoFontMerging style strategy. Note: If the selected font, though supporting the writing system in general, is missing glyphs for one or more specific characters, then Qt will try to find a fallback font for this or these particular characters. If no font exists on the system that can support the text, then special "missing character" boxes will be shown in its place.How this is done varies from platform to platform. The font matching algorithm will try to find the best match for all the properties set in the QFont. If not, a replacement font that supports the writing system is selected.The specified font families (set by setFamilies()) are searched for.The font matching algorithm works as follows: QFont contains extensive optimizations to make the copying of QFont objects fast, and to cache the results of the slow window system functions it depends upon. Loading fonts can be expensive, especially on X11. It is possible to set the height of characters shown on the screen to a specified number of pixels with setPixelSize() however using setPointSize() has a similar effect and provides device independence. The operator>() functions are also available, but they work on a data stream. If you want to store a user's font preferences you could use QSettings, writing the font information with toString() and reading it back with fromString(). After substituting a font, you must trigger the updating of the font by destroying and re-creating all QFont objects.Įvery QFont has a key() which you can use, for example, as the key in a cache or dictionary. Use substitutes() to retrieve a list of a family's substitutes (which may be empty). Use substitute() to retrieve a family's first substitute, or the family name itself if it has no substitutes. Substitutions can be removed with removeSubstitutions(). You can provide substitutions for font family names using insertSubstitution() and insertSubstitutions(). The default family (corresponding to the current style hint) is returned by defaultFamily(). If the requested font family is unavailable you can influence the font matching algorithm by choosing a particular QFont::StyleHint and QFont::StyleStrategy with setStyleHint(). The actual values are available from a QFontInfo object. family(), pointSize(), etc., return the values that were set, even though the values used may differ. A QFontInfo object will not change, even if you change the font's attributes. QFontInfo objects should be created after the font's attributes have been set. setBold(), setUnderline(), setOverline(), setStrikeOut() and setFixedPitch(). The remaining attributes must be set after construction, e.g. setFamily(), setPointSize(), setPointSizeF(), setWeight() and setItalic(). The attributes set in the constructor can also be set later, e.g. 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) SetFeature(const char * feature, quint32 value) 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)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |