The TQFontInfo class provides the same access functions as TQFont, e.g. family(), pointSize(), italic(), weight(), fixedPitch(), styleHint() etc. But whilst the TQFont access functions return the values that were set, a TQFontInfo object returns the values that apply to the font that will actually be used to draw the text.
For example, when the program asks for a 25pt Courier font on a machine that has a non-scalable 24pt Courier font, TQFont will (normally) use the 24pt Courier for rendering. In this case, TQFont::pointSize() returns 25 and TQFontInfo::pointSize() returns 24.
Calling the TQFontInfo constructor with a TQFont creates a font info object for a screen-compatible font, i.e. the font cannot be a printer font<sup>*</sup>. If the font is changed later, the font info object is \fInot\fR updated.
TQWidget::fontInfo() returns the font info for a widget's font. This is equivalent to calling TQFontInfo(widget->font()). If the widget's font is changed later, the font info object is \fInot\fR updated.
TQPainter::fontInfo() returns the font info for a painter's current font. If the painter's font is changed later, the font info object is \fInot\fR updated.
<sup>*</sup> If you use a printer font the values returned may be inaccurate. Printer fonts are not always accessible so the nearest screen font is used if a printer font is supplied.
The font info object holds the information for the font that is passed in the constructor at the time it is created, and is not updated if the font's attributes are changed later.
Use TQPainter::fontInfo() to get the font info when painting. This will give correct results also when painting on paint device that is not screen-compatible.