When you create a TQFont object you specify various attributes that you want the font to have. TQt will use the font with the specified attributes, or if no matching font exists, TQt will use the closest matching installed font. The attributes of the font that is actually used are retrievable from a TQFontInfo object. If the window system provides an exact match exactMatch() returns TRUE. Use TQFontMetrics to get measurements, e.g. the pixel length of a string using TQFontMetrics::width().
If a choosen X11 font does not include all the characters that need to be displayed, TQFont will try to find the characters in the nearest equivalent fonts. When a TQPainter draws a character from a font the TQFont will report whether or not it has the character; if it does not, TQPainter will draw an unfilled square.
The attributes set in the constructor can also be set later, e.g. setFamily(), setPointSize(), setPointSizeFloat(), setWeight() and setItalic(). The remaining attributes must be set after contstruction, e.g. setBold(), setUnderline(), setOverline(), setStrikeOut() and setFixedPitch(). TQFontInfo objects should be created \fIafter\fR the font's attributes have been set. A TQFontInfo object will not change, even if you change the font's attributes. The corresponding "get" functions, e.g. family(), pointSize(), etc., return the values that were set, even though the values used may differ. The actual values are available from a TQFontInfo object.
If the requested font family is unavailable you can influence the font matching algorithm by choosing a particular TQFont::StyleHint and TQFont::StyleStrategy with setStyleHint(). The default family (corresponding to the current style hint) is returned by defaultFamily().
The font-matching algorithm has a lastResortFamily() and lastResortFont() in cases where a suitable match cannot be found. You can provide substitutions for font family names using insertSubstitution() and insertSubstitutions(). Substitutions can be removed with removeSubstitution(). Use substitute() to retrieve a family's first substitute, or the family name itself if it has no substitutes. Use substitutes() to retrieve a list of a family's substitutes (which may be empty).
Every TQFont has a key() which you can use, for example, as the key in a cache or dictionary. If you want to store a user's font preferences you could use TQSettings, writing the font information with toString() and reading it back with fromString(). The operator<<() and operator>>() functions are also available, but they work on a data stream.
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.
.PP
Under the X Window System you can set a font using its system specific name with setRawName().
Loading fonts can be expensive, especially on X11. TQFont contains extensive optimizations to make the copying of TQFont objects fast, and to cache the results of the slow window system functions it depends upon.
Once a font is found, the remaining attributes are matched in order of priority: <ol type=1>
.IP 7
fixedPitch()
.IP 8
pointSize() (see below)
.IP 9
weight()
.IP 10
italic()
.PP
If you have a font which matches on family, even if none of the other attributes match, this font will be chosen in preference to a font which doesn't match on family but which does match on the other attributes. This is because font family is the dominant search criteria.
.PP
The point size is defined to match if it is within 20% of the requested point size. When several fonts match and are only distinguished by point size, the font with the closest point size to the one requested will be chosen.
The actual family, font size, weight and other font attributes used for drawing text will depend on what's available for the chosen family under the window system. A TQFontInfo object can be used to determine the actual values used for drawing the text.
See also TQFontMetrics, TQFontInfo, TQFontDatabase, QApplication::setFont(), TQWidget::font, TQPainter::setFont(), TQFont::StyleHint, TQFont::Weight, Widget Appearance and Style, Graphics Classes, and Implicitly and Explicitly Shared Classes.
\fCTQFont::Runic\fR - covers the known constituents of the Runic alphabets used by the early and medieval societies in the Germanic, Scandinavian, and Anglo-Saxon areas.
\fCTQFont::CombiningMarks\fR - consist of diacritical marks not specific to a particular alphabet, diacritical marks used in combination with mathematical and technical symbols, and glyph encodings applied to multiple letterforms.
\fCTQFont::Bengali\fR - is a relative to Devanagari employed to write the Bengali language used in West Bengal/India and Bangladesh as well as several minority languages.
\fCTQFont::Tamil\fR - is used to write the Tamil language of Tamil Nadu state/India, Sri Lanka, Singapore and parts of Malaysia as well as some minority languages.
\fCTQFont::Tibetan\fR - is the script used to write Tibetan in several countries like Tibet, the bordering Indian regions and Nepal. It is also used in the Buddist philosophy and liturgy of the Mongolian cultural area.
\fCTQFont::Katakana\fR - is a non-cursive syllabic script used to write Japanese words with visual emphasis and non-Japanese words in a phonetical manner.
\fCTQFont::TechnicalSymbols\fR - contains representations for control codes, the space symbol, APL symbols and other symbols mainly used in the context of electronic data processing.
\fCTQFont::MiscellaneousSymbols\fR - consists of a heterogeneous collection of symbols that do not fit any other Unicode character block, e.g. Dingbats.
\fCTQFont::Braille\fR - is an international writing system used by blind people. This script encodes the 256 eight-dot patterns with the 64 six-dot patterns as a subset.
Qt uses a weighting scale from 0 to 99 similar to, but not the same as, the scales used in Windows or CSS. A weight of 0 is ultralight, whilst 99 will be an extremely black.
The \fIfamily\fR name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". (The TQt 2.x syntax, i.e." Cronyx-Helvetica", is also supported.) If the \fIfamily\fR is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.
Returns TRUE if this font and \fIf\fR are copies of each other, i.e. one of them was created as a copy of the other and neither has been modified since. This is much stricter than equality.
The current implementation tries a wide variety of common fonts, returning the first one it finds. Is is possible that no family is found in which case a null string is returned.
Returns a "last resort" font name for the font matching algorithm. This is used if the last resort family is not available. It will always return a name, if necessary returning something like" fixed" or "system".
.PP
The current implementation tries a wide variety of common fonts, returning the first one it finds. The implementation may change at any time, but this function will always return a string containing something.
It is theoretically possible that there really isn't a lastResortFont() in which case TQt will abort with an error message. We have not been able to identify a case where this happens. Please report it as a bug if it does, preferably with a list of the fonts you have installed.
Two TQFonts are considered to be different if their font attributes are different. If rawMode() is enabled for both fonts, only the family fields are compared.
The \fIfamily\fR name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". (The TQt 2.x syntax, i.e." Cronyx-Helvetica", is also supported.) If the \fIfamily\fR is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available a family will be set using the font matching algorithm.
Using this function makes the font device dependent. Use setPointSize() or setPointSizeFloat() to set the size of the font in a device independent manner.
If raw mode is enabled, TQt will search for an X font with a complete font name matching the family name, ignoring all other values set for the TQFont. If the font name matches several fonts, TQt will use the first font returned by X. TQFontInfo \fIcannot\fR be used to fetch information about a TQFont using raw mode (it will return the values set in the TQFont for all parameters, including the family name).
Sets a font by its system specific name. The function is particularly useful under X, where system font settings (for example X resources) are usually available in XLFD (X Logical Font Description) form only. You can pass an XLFD as \fIname\fR to this function.
A font set with setRawName() is still a full-featured TQFont. It can be queried (for example with italic()) or modified (for example with setItalic()) and is therefore also suitable for rendering rich text.
If Qt's internal font database cannot resolve the raw name, the font becomes a raw font with \fIname\fR as its family.
.PP
Note that the present implementation does not handle wildcards in XLFDs well, and that font aliases (file \fCfonts.alias\fR in the font directory on X11) are not supported.
.PP
See also rawName(), setRawMode(), and setFamily().
The stretch factor changes the width of all characters in the font by \fIfactor\fR percent. For example, setting \fIfactor\fR to 150 results in all characters in the font being 1.5 times ( ie. 150% ) wider. The default stretch factor is 100. The minimum stretch factor is 1, and the maximum stretch factor is 4000.
.PP
The stretch factor is only applied to outline fonts. The stretch factor is ignored for bitmap fonts.
NOTE: TQFont cannot stretch XLFD fonts. When loading XLFD fonts on X11, the stretch factor is matched against a predefined set of values for the SETWIDTH_NAME field of the XLFD.