Qt logo

QFontInfo Class Reference


The QFontInfo class provides general information about fonts. More...

#include <qfontinfo.h>

List of all member functions.

Public Members


Detailed Description

The QFontInfo class provides general information about fonts.

The QFont class might not always map exactly to the specified font for a paint device. The QFontInfo class provides information of the actual font that matched a QFont specification.

There are three ways you can create a QFontInfo object:

  1. The QFontInfo constructor with a QFont creates a font info object for a screen-compatible font, i.e. the font must not be a printer font.
  2. QWidget::fontInfo() returns the font info for a widget's font. This is equivalent to QFontInfo(widget->font()). Setting a new font for the widget later will not affect the font info object.
  3. QPainter::fontInfo() returns the font info for a painter's current font. The font info object is automatically updated if somebody sets a new painter font (unlike the two above cases, which take a "snapshot" of a font).

Example:

    QFont font("reykjavik",24);
    QFontInfo fi(font);
    if ( font.family() == fi.family() ) {
        ; // got this font
    } else {
        ; // got fi.family() instead
    }

See also: QFont and QFontMetrics.


Member Function Documentation

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. If font is a printer font, you'll probably get wrong results.

Use the QPainter::fontInfo() to get the font info when painting. This is a little slower than using this constructor, but it always gives correct results.

QFontInfo::QFontInfo ( const QFontInfo & fi )

Constructs a copy of fi.

QFontInfo::~QFontInfo ()

Destroys the font info object.

bool QFontInfo::bold () const

Returns TRUE if weight() would return a greater than QFont::Normal, and FALSE otherwise.

See also: weight() and QFont::bold().

QFont::CharSet QFontInfo::charSet() const

Returns the character set of the matched window system font.

See also: QFont::charSet().

bool QFontInfo::exactMatch () const

Returns TRUE if the matched window system font is exactly the one specified by the font.

See also: QFont::exactMatch().

QString QFontInfo::family () const

Returns the family name of the matched window system font.

See also: QFont::family().

bool QFontInfo::fixedPitch () const

Returns the fixed pitch value of the matched window system font. A fixed pitch font is a font that has constant character pixel width.

See also: QFont::fixedPitch().

bool QFontInfo::italic () const

Returns the italic value of the matched window system font.

See also: QFont::italic().

QFontInfo & QFontInfo::operator= ( const QFontInfo & fi )

Font info assignment.

int QFontInfo::pointSize () const

Returns the point size of the matched window system font.

See also: QFont::pointSize().

bool QFontInfo::rawMode () const

Returns TRUE if the font is a raw mode font.

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.

See also: QFont::rawMode().

bool QFontInfo::strikeOut () const

Returns the strike out value of the matched window system font.

See also: QFont::strikeOut().

QFont::StyleHint QFontInfo::styleHint() const

Returns the style of the matched window system font.

Currently only returns the hint set in QFont.

See also: QFont::styleHint().

bool QFontInfo::underline () const

Returns the underline value of the matched window system font.

See also: QFont::underline().

int QFontInfo::weight () const

Returns the weight of the matched window system font.

See also: QFont::weight() and bold().


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.


Copyright İ 1999 Troll TechTrademarks
Qt version 2.0.2