#include <qfontinfo.h>
Collaboration diagram for QFontInfo:

The QFontInfo class provides the same access functions as QFont, e.g. family(), pointSize(), italic(), weight(), fixedPitch(), styleHint() etc. But whilst the QFont access functions return the values that were set, a QFontInfo 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, QFont will (normally) use the 24pt Courier for rendering. In this case, QFont::pointSize() returns 25 and QFontInfo::pointSize() returns 24.
There are three ways to create a QFontInfo object. 1 Calling the QFontInfo constructor with a QFont creates a font info object for a screen-compatible font, i.e. the font cannot be a printer font. If the font is changed later, the font info object is not updated.
(Note: 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.)
QWidget::fontInfo() returns the font info for a widget's font. This is equivalent to calling QFontInfo(widget->font()). If the widget's font is changed later, the font info object is not updated.
QPainter::fontInfo() returns the font info for a painter's current font. If the painter's font is changed later, the font info object is not updated.
Definition at line 33 of file qfontinfo.h.
Public Member Functions | |
| QFontInfo (const QFont &) | |
| QFontInfo (const QFontInfo &) | |
| ~QFontInfo () | |
| QFontInfo & | operator= (const QFontInfo &) |
| QString | family () const |
| int | pixelSize () const |
| int | pointSize () const |
| qreal | pointSizeF () const |
| bool | italic () const |
| QFont::Style | style () const |
| int | weight () const |
| bool | bold () const |
| bool | underline () const |
| bool | overline () const |
| bool | strikeOut () const |
| bool | fixedPitch () const |
| QFont::StyleHint | styleHint () const |
| bool | rawMode () const |
| bool | exactMatch () const |
Private Attributes | |
| QFontPrivate * | d |
| QFontInfo::QFontInfo | ( | const QFont & | font | ) |
Constructs a font info object for font.
The font must be screen-compatible, i.e. a font you use when drawing text in widgets or pixmaps, not QPicture or QPrinter.
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 QPainter::fontInfo() to get the font info when painting. This will give correct results also when painting on paint device that is not screen-compatible.
Definition at line 1853 of file qfont.cpp.
References d, QBasicAtomic::ref(), and QFontPrivate::ref.
Here is the call graph for this function:

| QFontInfo::QFontInfo | ( | const QFontInfo & | fi | ) |
Constructs a copy of fi.
Definition at line 1860 of file qfont.cpp.
References d, QBasicAtomic::ref(), and QFontPrivate::ref.
Here is the call graph for this function:

| QFontInfo::~QFontInfo | ( | ) |
Destroys the font info object.
Definition at line 1867 of file qfont.cpp.
References d, QBasicAtomic::deref(), and QFontPrivate::ref.
Here is the call graph for this function:

Assigns the font info in fi.
Definition at line 1876 of file qfont.cpp.
References d, and qAtomicAssign().
01877 { 01878 qAtomicAssign(d, fi.d); 01879 return *this; 01880 }
Here is the call graph for this function:

| QString QFontInfo::family | ( | ) | const |
Returns the family name of the matched window system font.
Definition at line 1887 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontDef::family, and QFontEngine::fontDef.
Referenced by QFontComboBoxPrivate::_q_updateModel().
01888 { 01889 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 01890 Q_ASSERT(engine != 0); 01891 return engine->fontDef.family; 01892 }
Here is the call graph for this function:

| int QFontInfo::pixelSize | ( | ) | const |
Returns the pixel size of the matched window system font.
Definition at line 1923 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontEngine::fontDef, and QFontDef::pixelSize.
Referenced by Q3SVGPaintEnginePrivate::parseLen(), and qt_set_x11_resources().
01924 { 01925 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 01926 Q_ASSERT(engine != 0); 01927 return engine->fontDef.pixelSize; 01928 }
Here is the call graph for this function:

| int QFontInfo::pointSize | ( | ) | const |
Returns the point size of the matched window system font.
Definition at line 1899 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontEngine::fontDef, QFontDef::pointSize, and qRound().
Referenced by Q3SVGPaintEnginePrivate::applyStyle(), qt_set_x11_resources(), and QFontDialog::setFont().
01900 { 01901 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 01902 Q_ASSERT(engine != 0); 01903 return qRound(engine->fontDef.pointSize); 01904 }
Here is the call graph for this function:

| qreal QFontInfo::pointSizeF | ( | ) | const |
Returns the point size of the matched window system font.
Definition at line 1911 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontEngine::fontDef, and QFontDef::pointSize.
01912 { 01913 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 01914 Q_ASSERT(engine != 0); 01915 return engine->fontDef.pointSize; 01916 }
Here is the call graph for this function:

| bool QFontInfo::italic | ( | ) | const |
Returns the italic value of the matched window system font.
Definition at line 1935 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontEngine::fontDef, QFontDef::style, and QFont::StyleNormal.
01936 { 01937 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 01938 Q_ASSERT(engine != 0); 01939 return engine->fontDef.style != QFont::StyleNormal; 01940 }
Here is the call graph for this function:

| QFont::Style QFontInfo::style | ( | ) | const |
Returns the style value of the matched window system font.
Definition at line 1947 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontEngine::fontDef, and QFontDef::style.
Referenced by QFontDatabase::styleString().
01948 { 01949 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 01950 Q_ASSERT(engine != 0); 01951 return (QFont::Style)engine->fontDef.style; 01952 }
Here is the call graph for this function:

| int QFontInfo::weight | ( | ) | const |
Returns the weight of the matched window system font.
Definition at line 1959 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontEngine::fontDef, and QFontDef::weight.
Referenced by QFontDatabase::styleString().
01960 { 01961 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 01962 Q_ASSERT(engine != 0); 01963 return engine->fontDef.weight; 01964 01965 }
Here is the call graph for this function:

| bool QFontInfo::bold | ( | ) | const [inline] |
Returns true if weight() would return a value greater than QFont::Normal; otherwise returns false.
Definition at line 49 of file qfontinfo.h.
References QFont::Normal.
00049 { return weight() > QFont::Normal; }
| bool QFontInfo::underline | ( | ) | const |
Returns the underline value of the matched window system font.
Definition at line 1986 of file qfont.cpp.
References d, and QFontPrivate::underline.
| bool QFontInfo::overline | ( | ) | const |
Returns the overline value of the matched window system font.
Definition at line 2001 of file qfont.cpp.
References d, and QFontPrivate::overline.
| bool QFontInfo::strikeOut | ( | ) | const |
Returns the strikeout value of the matched window system font.
Definition at line 2014 of file qfont.cpp.
References d, and QFontPrivate::strikeOut.
| bool QFontInfo::fixedPitch | ( | ) | const |
Returns the fixed pitch value of the matched window system font.
Definition at line 2024 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontDef::fixedPitch, QFontDef::fixedPitchComputed, QFontEngine::fontDef, g, l, and QFontEngine::stringToCMap().
02025 { 02026 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 02027 Q_ASSERT(engine != 0); 02028 #ifdef Q_OS_MAC 02029 if (!engine->fontDef.fixedPitchComputed) { 02030 QChar ch[2] = { QChar('i'), QChar('m') }; 02031 QGlyphLayout g[2]; 02032 int l = 2; 02033 engine->stringToCMap(ch, 2, g, &l, 0); 02034 engine->fontDef.fixedPitch = g[0].advance.x == g[1].advance.x; 02035 engine->fontDef.fixedPitchComputed = true; 02036 } 02037 #endif 02038 return engine->fontDef.fixedPitch; 02039 }
Here is the call graph for this function:

| QFont::StyleHint QFontInfo::styleHint | ( | ) | const |
Returns the style of the matched window system font.
Currently only returns the style hint set in QFont.
Definition at line 2048 of file qfont.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontEngine::fontDef, and QFontDef::styleHint.
02049 { 02050 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 02051 Q_ASSERT(engine != 0); 02052 return (QFont::StyleHint) engine->fontDef.styleHint; 02053 }
Here is the call graph for this function:

| bool QFontInfo::rawMode | ( | ) | const |
Returns true if the font is a raw mode font; otherwise returns false.
If it is a raw mode font, all other functions in QFontInfo will return the same values set in the QFont, regardless of the font actually used.
Definition at line 2065 of file qfont.cpp.
References d, and QFontPrivate::rawMode.
Referenced by qt_set_x11_resources().
| bool QFontInfo::exactMatch | ( | ) | const |
Returns true if the matched window system font is exactly the same as the one specified by the font; otherwise returns false.
Definition at line 2076 of file qfont.cpp.
References QFontEngine::Box, QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontDef::exactMatch(), QFontEngine::fontDef, QFontPrivate::rawMode, QFontPrivate::request, and QFontEngine::type().
02077 { 02078 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 02079 Q_ASSERT(engine != 0); 02080 return (d->rawMode 02081 ? engine->type() != QFontEngine::Box 02082 : d->request.exactMatch(engine->fontDef)); 02083 }
Here is the call graph for this function:

QFontPrivate* QFontInfo::d [private] |
Definition at line 60 of file qfontinfo.h.
Referenced by exactMatch(), family(), fixedPitch(), italic(), operator=(), overline(), pixelSize(), pointSize(), pointSizeF(), QFontInfo(), rawMode(), strikeOut(), style(), styleHint(), underline(), weight(), and ~QFontInfo().
1.5.1