#include <qfont.h>
Collaboration diagram for QFont:

When you create a QFont object you specify various attributes that you want the font to have. Qt will use the font with the specified attributes, or if no matching font exists, Qt will use the closest matching installed font. The attributes of the font that is actually used are retrievable from a QFontInfo object. If the window system provides an exact match exactMatch() returns true. Use QFontMetrics to get measurements, e.g. the pixel length of a string using QFontMetrics::width().
Use QApplication::setFont() to set the application's default font.
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. 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.
Create QFonts like this:
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(). QFontInfo objects should be created after the font's attributes have been set. A QFontInfo 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 QFontInfo object.
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 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 QFont 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 QSettings, 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.
Under X11 you can set a font using its system specific name with setRawName().
Loading fonts can be expensive, especially on X11. 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.
fontmatching The font matching algorithm works as follows: 1 The specified font family is searched for. If not found, the styleHint() is used to select a replacement family. Each replacement font family is searched for. If none of these are found or there was no styleHint(), "helvetica" will be searched for. If "helvetica" isn't found Qt will try the lastResortFamily(). If the lastResortFamily() isn't found Qt will try the lastResortFont() which will always return a name of some kind.
Note that the actual font matching algorithm varies from platform to platform.
Once a font is found, the remaining attributes are matched in order of priority: 1 fixedPitch() pointSize() (see below) weight() style()
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.
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 QFontInfo object can be used to determine the actual values used for drawing the text.
Examples:
QFont f("Helvetica");
QFont f("Helvetica [Cronyx]");
You can specify the foundry you want in the family name. The font f in the above example will be set to "Helvetica [Cronyx]".
To determine the attributes of the font actually used in the window system, use a QFontInfo object, e.g.
To find out font metrics use a QFontMetrics object, e.g.
QFontMetrics fm(f1); int textWidthInPixels = fm.width("How many pixels wide is this text?"); int textHeightInPixels = fm.height();
For more general information on fonts, see the comp.fonts FAQ. Information on encodings can be found from Roman Czyborra's page.
Definition at line 39 of file qfont.h.
Public Types | |
| enum | StyleHint |
| enum | StyleStrategy |
| enum | Weight |
| enum | Style |
| enum | Stretch |
Public Member Functions | |
| QFont () | |
| QFont (const QString &family, int pointSize=-1, int weight=-1, bool italic=false) | |
| QFont (const QFont &, QPaintDevice *pd) | |
| QFont (const QFont &) | |
| ~QFont () | |
| QString | family () const |
| void | setFamily (const QString &) |
| int | pointSize () const |
| void | setPointSize (int) |
| qreal | pointSizeF () const |
| void | setPointSizeF (qreal) |
| int | pixelSize () const |
| void | setPixelSize (int) |
| int | weight () const |
| void | setWeight (int) |
| bool | bold () const |
| void | setBold (bool) |
| void | setStyle (Style style) |
| Style | style () const |
| bool | italic () const |
| void | setItalic (bool b) |
| bool | underline () const |
| void | setUnderline (bool) |
| bool | overline () const |
| void | setOverline (bool) |
| bool | strikeOut () const |
| void | setStrikeOut (bool) |
| bool | fixedPitch () const |
| void | setFixedPitch (bool) |
| bool | kerning () const |
| void | setKerning (bool) |
| StyleHint | styleHint () const |
| StyleStrategy | styleStrategy () const |
| void | setStyleHint (StyleHint, StyleStrategy=PreferDefault) |
| void | setStyleStrategy (StyleStrategy s) |
| int | stretch () const |
| void | setStretch (int) |
| bool | rawMode () const |
| void | setRawMode (bool) |
| bool | exactMatch () const |
| QFont & | operator= (const QFont &) |
| bool | operator== (const QFont &) const |
| bool | operator!= (const QFont &) const |
| bool | operator< (const QFont &) const |
| operator QVariant () const | |
| bool | isCopyOf (const QFont &) const |
| Qt::HANDLE | handle () const |
| void | setRawName (const QString &) |
| QString | rawName () const |
| QString | key () const |
| QString | toString () const |
| bool | fromString (const QString &) |
| QString | defaultFamily () const |
| QString | lastResortFamily () const |
| QString | lastResortFont () const |
| QFont | resolve (const QFont &) const |
| uint | resolve () const |
| void | resolve (uint mask) |
Static Public Member Functions | |
| static QString | substitute (const QString &) |
| static QStringList | substitutes (const QString &) |
| static QStringList | substitutions () |
| static void | insertSubstitution (const QString &, const QString &) |
| static void | insertSubstitutions (const QString &, const QStringList &) |
| static void | removeSubstitution (const QString &) |
| static void | initialize () |
| static void | cleanup () |
| static void | cacheStatistics () |
Private Member Functions | |
| QFont (QFontPrivate *) | |
| void | detach () |
Private Attributes | |
| QFontPrivate * | d |
| uint | resolve_mask |
Friends | |
| class | QFontMetrics |
| class | QFontMetricsF |
| class | QFontInfo |
| class | QPainter |
| class | QPSPrintEngineFont |
| class | QApplication |
| class | QWidget |
| class | QWidgetPrivate |
| class | Q3TextFormatCollection |
| class | QTextLayout |
| class | QTextEngine |
| class | QStackTextEngine |
| class | QTextLine |
| struct | QScriptLine |
| class | QGLContext |
| class | QWin32PaintEngine |
| class | QPainterPath |
| class | QTextItemInt |
| Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QFont &) |
| Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QFont &) |
| enum QFont::StyleHint |
Style hints are used by the {QFont}{font matching} algorithm to find an appropriate default family if a selected font family is not available.
AnyStyle leaves the font matching algorithm to choose the family. This is the default.
SansSerif the font matcher prefer sans serif fonts. Helvetica is a synonym for SansSerif.
Serif the font matcher prefers serif fonts. Times is a synonym for Serif.
TypeWriter the font matcher prefers fixed pitch fonts. Courier a synonym for TypeWriter.
OldEnglish the font matcher prefers decorative fonts. Decorative is a synonym for OldEnglish.
System the font matcher prefers system fonts.
Definition at line 42 of file qfont.h.
00042 { 00043 Helvetica, SansSerif = Helvetica, 00044 Times, Serif = Times, 00045 Courier, TypeWriter = Courier, 00046 OldEnglish, Decorative = OldEnglish, 00047 System, 00048 AnyStyle 00049 };
| enum QFont::StyleStrategy |
The style strategy tells the {QFont}{font matching} algorithm what type of fonts should be used to find an appropriate default family.
The following strategies are available:
PreferDefault the default style strategy. It does not prefer any type of font. PreferBitmap prefers bitmap fonts (as opposed to outline fonts). PreferDevice prefers device fonts. PreferOutline prefers outline fonts (as opposed to bitmap fonts). ForceOutline forces the use of outline fonts. NoAntialias don't antialias the fonts. PreferAntialias antialias if possible. OpenGLCompatible forces the use of OpenGL compatible fonts. NoFontMerging If a font does not contain a character requested to draw then Qt automatically chooses a similar looking for that contains the character. This flag disables this feature.
Any of these may be OR-ed with one of these flags:
PreferMatch prefer an exact match. The font matcher will try to use the exact font size that has been specified. PreferQuality prefer the best quality font. The font matcher will use the nearest standard point size that the font supports.
Definition at line 51 of file qfont.h.
00051 { 00052 PreferDefault = 0x0001, 00053 PreferBitmap = 0x0002, 00054 PreferDevice = 0x0004, 00055 PreferOutline = 0x0008, 00056 ForceOutline = 0x0010, 00057 PreferMatch = 0x0020, 00058 PreferQuality = 0x0040, 00059 PreferAntialias = 0x0080, 00060 NoAntialias = 0x0100, 00061 OpenGLCompatible = 0x0200, 00062 NoFontMerging = 0x8000 00063 };
| enum QFont::Weight |
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.
This enum contains the predefined font weights:
Light 25 Normal 50 DemiBold 63 Bold 75 Black 87
Definition at line 65 of file qfont.h.
00065 { 00066 Light = 25, 00067 Normal = 50, 00068 DemiBold = 63, 00069 Bold = 75, 00070 Black = 87 00071 };
| enum QFont::Style |
This enum describes the different styles of glyphs that are used to display text.
StyleNormal Normal glyphs used in unstyled text. StyleItalic Italic glyphs that are specifically designed for the purpose of representing italicized text. StyleOblique Glyphs with an italic appearance that are typically based on the unstyled glyphs, but are not fine-tuned for the purpose of representing italicized text.
Definition at line 73 of file qfont.h.
00073 { 00074 StyleNormal, 00075 StyleItalic, 00076 StyleOblique 00077 };
| enum QFont::Stretch |
Predefined stretch values that follow the CSS naming convention. The higher the value, the more stretched the text is.
UltraCondensed 50 ExtraCondensed 62 Condensed 75 SemiCondensed 87 Unstretched 100 SemiExpanded 112 Expanded 125 ExtraExpanded 150 UltraExpanded 200
Definition at line 79 of file qfont.h.
00079 { 00080 UltraCondensed = 50, 00081 ExtraCondensed = 62, 00082 Condensed = 75, 00083 SemiCondensed = 87, 00084 Unstretched = 100, 00085 SemiExpanded = 112, 00086 Expanded = 125, 00087 ExtraExpanded = 150, 00088 UltraExpanded = 200 00089 };
| QFont::QFont | ( | ) |
Constructs a font object that uses the application's default font.
Definition at line 501 of file qfont.cpp.
References d, QBasicAtomic::ref(), and QFontPrivate::ref.
00502 :d(QApplication::font().d), resolve_mask(0) 00503 { 00504 d->ref.ref(); 00505 }
Here is the call graph for this function:

| QFont::QFont | ( | const QString & | family, | |
| int | pointSize = -1, |
|||
| int | weight = -1, |
|||
| bool | italic = false | |||
| ) |
Constructs a font object with the specified family, pointSize, weight and italic settings.
If pointSize is <= 0, it is set to 12.
The family name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". If the family 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 {QFont}{font matching} algorithm.
Definition at line 523 of file qfont.cpp.
References d, family(), QFontPrivate::Family, QFontDef::family, Normal, QFontDef::pixelSize, QFontDef::pointSize, qt_font_tread_test(), QFontPrivate::request, resolve_mask, QFontPrivate::Size, QFontDef::style, StyleItalic, StyleNormal, and QFontDef::weight.
00524 :d(new QFontPrivate) 00525 { 00526 qt_font_tread_test(); 00527 00528 resolve_mask = QFontPrivate::Family; 00529 00530 if (pointSize <= 0) { 00531 pointSize = 12; 00532 } else { 00533 resolve_mask |= QFontPrivate::Size; 00534 } 00535 00536 if (weight < 0) { 00537 weight = Normal; 00538 } else { 00539 resolve_mask |= QFontPrivate::Weight | QFontPrivate::Style; 00540 } 00541 00542 d->request.family = family; 00543 d->request.pointSize = qreal(pointSize); 00544 d->request.pixelSize = -1; 00545 d->request.weight = weight; 00546 d->request.style = italic ? QFont::StyleItalic : QFont::StyleNormal; 00547 }
Here is the call graph for this function:

| QFont::QFont | ( | const QFont & | font, | |
| QPaintDevice * | pd | |||
| ) |
Constructs a font from font for use on the paint device pd.
Definition at line 444 of file qfont.cpp.
References d, QPaintDevice::devType(), QFontPrivate::dpi, info, QPaintDevice::logicalDpiY(), QInternal::Printer, qt_x11Info(), QBasicAtomic::ref(), QFontPrivate::ref, and QFontPrivate::screen.
00445 : resolve_mask(font.resolve_mask) 00446 { 00447 Q_ASSERT(pd != 0); 00448 int dpi = pd->logicalDpiY(); 00449 #ifdef Q_WS_X11 00450 const QX11Info *info = qt_x11Info(pd); 00451 int screen = info ? info->screen() : 0; 00452 #else 00453 const int screen = 0; 00454 #endif 00455 if (font.d->dpi != dpi || font.d->screen != screen ) { 00456 d = new QFontPrivate(*font.d); 00457 d->dpi = dpi; 00458 d->screen = screen; 00459 } else { 00460 d = font.d; 00461 d->ref.ref(); 00462 } 00463 #ifdef Q_WS_WIN 00464 if (pd->devType() == QInternal::Printer && pd->getDC()) 00465 d->hdc = pd->getDC(); 00466 #endif 00467 }
Here is the call graph for this function:

| QFont::QFont | ( | const QFont & | font | ) |
Constructs a font that is a copy of font.
Definition at line 552 of file qfont.cpp.
References d, QBasicAtomic::ref(), QFontPrivate::ref, and resolve_mask.
00553 { 00554 d = font.d; 00555 d->ref.ref(); 00556 resolve_mask = font.resolve_mask; 00557 }
Here is the call graph for this function:

| QFont::~QFont | ( | ) |
Destroys the font object and frees all allocated resources.
Definition at line 562 of file qfont.cpp.
References d, QBasicAtomic::deref(), and QFontPrivate::ref.
Here is the call graph for this function:

| QFont::QFont | ( | QFontPrivate * | ) | [private] |
Definition at line 472 of file qfont.cpp.
References d, data, qt_font_tread_test(), QBasicAtomic::ref(), and QFontPrivate::ref.
00473 : resolve_mask(QFontPrivate::Complete) 00474 { 00475 qt_font_tread_test(); 00476 00477 d = data; 00478 d->ref.ref(); 00479 }
Here is the call graph for this function:

| QString QFont::family | ( | ) | const |
Returns the requested font family name, i.e. the name set in the constructor or the last setFont() call.
Definition at line 584 of file qfont.cpp.
References d, QFontDef::family, and QFontPrivate::request.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), Q3SVGPaintEnginePrivate::applyStyle(), qdesigner_internal::compareFonts(), QAbstractFormBuilder::createProperty(), Q3TextEdit::family(), MainWindow::findSizes(), MainWindow::findStyles(), Q3TextFormatCollection::format(), getFcPattern(), Q3TextFormat::makeFormatChangeTags(), Q3TextFormat::makeFormatEndTags(), CharacterWidget::mouseMoveEvent(), parseFont(), MainWindow::printPage(), QFont(), Q3TextDocument::richText(), Q3TextFormat::setFamily(), setFamily(), QPainter::setFont(), QTextCharFormat::setFont(), QFontDialog::setFont(), Q3TextParagraph::setFormat(), qdesigner_internal::FontProperty::setValue(), toString(), QFontDialog::updateFamilies(), CharacterWidget::updateFont(), CharacterWidget::updateStyle(), and writingSystemForFont().
| void QFont::setFamily | ( | const QString & | family | ) |
Sets the family name of the font. The name is case insensitive and may include a foundry name.
The family name may optionally also include a foundry name, e.g. "Helvetica [Cronyx]". If the family 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 {QFont}{font matching} algorithm.
Definition at line 602 of file qfont.cpp.
References QFontDef::addStyle, QString::clear(), d, detach(), family(), QFontPrivate::Family, QFontDef::family, QFontPrivate::request, and resolve_mask.
Referenced by Q3TextFormatCollection::format(), fromString(), QFontFamilyDelegate::paint(), parseQFont(), parseShorthandFontProperty(), QTextFormatPrivate::recalcFont(), Q3TextFormat::setFamily(), setFontFamilyFromValues(), qdesigner_internal::QPropertyEditorDelegate::setModelData(), setRawName(), Q3SVGPaintEnginePrivate::setStyleProperty(), MainWindow::setupEditor(), QAbstractFormBuilder::toVariant(), and CharacterWidget::updateFont().
00603 { 00604 detach(); 00605 00606 d->request.family = family; 00607 #if defined(Q_WS_X11) 00608 d->request.addStyle.clear(); 00609 #endif // Q_WS_X11 00610 00611 resolve_mask |= QFontPrivate::Family; 00612 }
Here is the call graph for this function:

| int QFont::pointSize | ( | ) | const |
Returns the point size of the font. Returns -1 if the font size was specified in pixels.
Definition at line 620 of file qfont.cpp.
References d, QFontDef::pointSize, qRound(), and QFontPrivate::request.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), Calculator::Calculator(), qdesigner_internal::compareFontSizes(), QAbstractFormBuilder::createProperty(), QPlastiqueStyle::drawControl(), QTextEngine::font(), TextEdit::fontChanged(), QTextEngine::fontEngine(), Q3TextFormatCollection::format(), getFontSet(), ItemDialog::ItemDialog(), Q3TextFormat::makeFormatChangeTags(), Q3TextFormat::makeFormatEndTags(), BasicToolsPlugin::mouseMove(), QFontFamilyDelegate::paint(), Q3TextEdit::pointSize(), QTextFormatPrivate::resolveFont(), Q3StyleSheet::scaleFont(), qdesigner_internal::RichTextEditor::setDefaultFont(), QPainter::setFont(), QFontDialog::setFont(), Q3TextParagraph::setFormat(), Q3TextFormat::setPointSize(), TextEdit::setupTextActions(), qdesigner_internal::FontProperty::setValue(), QFontFamilyDelegate::sizeHint(), qdesigner_internal::TabOrderEditor::TabOrderEditor(), Q3TextFormatCollection::updateDefaultFormat(), QPicturePaintEngine::updateFont(), CharacterWidget::updateStyle(), Q3TextFormat::width(), WigglyWidget::WigglyWidget(), QTextEdit::zoomIn(), Q3TextEdit::zoomIn(), and Q3TextEdit::zoomOut().
Here is the call graph for this function:

| void QFont::setPointSize | ( | int | pointSize | ) |
Sets the point size to pointSize. The point size must be greater than zero.
Definition at line 631 of file qfont.cpp.
References d, detach(), QFontDef::pixelSize, QFontDef::pointSize, QFontPrivate::request, resolve_mask, and QFontPrivate::Size.
Referenced by Calculator::Calculator(), ColorDock::ColorDock(), qdesigner_internal::FontProperty::decoration(), GraphWidget::drawBackground(), QPlastiqueStyle::drawControl(), XFormView::drawTextType(), QTextEngine::font(), QTextEngine::fontEngine(), Q3TextFormatCollection::format(), ItemDialog::ItemDialog(), BasicToolsPlugin::mouseMove(), QFontFamilyDelegate::paint(), PrintOut::PrintOut(), Q3StyleSheet::scaleFont(), qdesigner_internal::QPropertyEditorDelegate::setModelData(), Q3TextFormat::setPointSize(), PathDeformRenderer::setText(), MainWindow::setupEditor(), QFontFamilyDelegate::sizeHint(), qdesigner_internal::TabOrderEditor::TabOrderEditor(), QAbstractFormBuilder::toVariant(), CharacterWidget::updateSize(), Q3TextFormat::width(), WigglyWidget::WigglyWidget(), QTextEdit::zoomIn(), Q3TextEdit::zoomIn(), Q3TextEdit::zoomOut(), and Q3TextEdit::zoomTo().
00632 { 00633 Q_ASSERT_X (pointSize > 0, "QFont::setPointSize", "point size must be greater than 0"); 00634 00635 detach(); 00636 00637 d->request.pointSize = qreal(pointSize); 00638 d->request.pixelSize = -1; 00639 00640 resolve_mask |= QFontPrivate::Size; 00641 }
Here is the call graph for this function:

| qreal QFont::pointSizeF | ( | ) | const |
Returns the point size of the font. Returns -1 if the font size was specified in pixels.
Definition at line 668 of file qfont.cpp.
References d, QFontDef::pointSize, and QFontPrivate::request.
Referenced by qdesigner_internal::compareFontSizes(), parseFont(), Launcher::resizeEvent(), QTextFormatPrivate::resolveFont(), QTextCharFormat::setFont(), TitleShape::TitleShape(), and toString().
| void QFont::setPointSizeF | ( | qreal | pointSize | ) |
Sets the point size to pointSize. The point size must be greater than zero. The requested precision may not be achieved on all platforms.
Definition at line 650 of file qfont.cpp.
References d, detach(), QFontDef::pixelSize, QFontDef::pointSize, QFontPrivate::request, resolve_mask, and QFontPrivate::Size.
Referenced by fromString(), HelpWindow::HelpWindow(), parseQFont(), QTextFormatPrivate::recalcFont(), Launcher::resizeEvent(), QTextFormatPrivate::resolveFont(), setFontSizeFromValue(), and TitleShape::TitleShape().
00651 { 00652 Q_ASSERT_X(pointSize > 0.0, "QFont::setPointSizeF", "point size must be greater than 0"); 00653 00654 detach(); 00655 00656 d->request.pointSize = pointSize; 00657 d->request.pixelSize = -1; 00658 00659 resolve_mask |= QFontPrivate::Size; 00660 }
Here is the call graph for this function:

| int QFont::pixelSize | ( | ) | const |
Returns the pixel size of the font if it was set with setPixelSize(). Returns -1 if the size was set with setPointSize() or setPointSizeF().
Definition at line 704 of file qfont.cpp.
References d, QFontDef::pixelSize, and QFontPrivate::request.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), qdesigner_internal::compareFontSizes(), Q3TextFormatCollection::format(), parseDefaultTextStyle(), parseFont(), Q3TextFormat::Q3TextFormat(), QTextFormatPrivate::resolveFont(), Q3StyleSheet::scaleFont(), QTextCharFormat::setFont(), toString(), Q3TextFormatCollection::updateDefaultFormat(), and Q3TextFormat::width().
| void QFont::setPixelSize | ( | int | pixelSize | ) |
Sets the font size to pixelSize pixels.
Using this function makes the font device dependent. Use setPointSize() or setPointSizeF() to set the size of the font in a device independent manner.
Definition at line 682 of file qfont.cpp.
References d, detach(), QFontDef::pixelSize, QFontDef::pointSize, qWarning(), QFontPrivate::request, resolve_mask, and QFontPrivate::Size.
Referenced by Q3TextFormatCollection::format(), fromString(), Helper::Helper(), parseQFont(), QTextFormatPrivate::recalcFont(), QTextFormatPrivate::resolveFont(), Q3StyleSheet::scaleFont(), setFontSizeFromValue(), Q3SVGPaintEnginePrivate::setStyleProperty(), Window::setupShapes(), and Q3TextFormat::width().
00683 { 00684 if (pixelSize <= 0) { 00685 qWarning("QFont::setPixelSize: Pixel size <= 0 (%d)", pixelSize); 00686 return; 00687 } 00688 00689 detach(); 00690 00691 d->request.pixelSize = pixelSize; 00692 d->request.pointSize = -1; 00693 00694 resolve_mask |= QFontPrivate::Size; 00695 }
Here is the call graph for this function:

| int QFont::weight | ( | ) | const |
Returns the weight of the font which is one of the enumerated values from {QFont::Weight}.
Definition at line 768 of file qfont.cpp.
References d, QFontPrivate::request, and QFontDef::weight.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), Q3SVGPaintEnginePrivate::applyStyle(), bold(), QAbstractFormBuilder::createProperty(), Q3TextFormat::makeFormatChangeTags(), Q3TextFormat::makeFormatEndTags(), QTextCharFormat::setFont(), Q3TextParagraph::setFormat(), Q3SVGPaintEnginePrivate::setStyleProperty(), QFontDatabase::styleString(), and toString().
| void QFont::setWeight | ( | int | weight | ) |
Sets the weight the font to weight, which should be a value from the QFont::Weight enumeration.
Definition at line 795 of file qfont.cpp.
References d, detach(), QFontPrivate::request, resolve_mask, and QFontDef::weight.
Referenced by fromString(), Launcher::Launcher(), parseQFont(), parseShorthandFontProperty(), QTextFormatPrivate::recalcFont(), setBold(), setFontWeightFromValue(), Q3SVGPaintEnginePrivate::setStyleProperty(), and QAbstractFormBuilder::toVariant().
00796 { 00797 Q_ASSERT_X(weight >= 0 && weight <= 99, "QFont::setWeight", "Weight must be between 0 and 99"); 00798 00799 detach(); 00800 00801 d->request.weight = weight; 00802 resolve_mask |= QFontPrivate::Weight; 00803 }
Here is the call graph for this function:

| bool QFont::bold | ( | ) | const [inline] |
Returns true if weight() is a value greater than QFont::Normal ; otherwise returns false.
Definition at line 243 of file qfont.h.
References Normal, and weight().
Referenced by Q3TextEdit::bold(), qdesigner_internal::compareFonts(), QAbstractFormBuilder::createProperty(), TextEdit::fontChanged(), Q3TextFormatCollection::format(), getFontSet(), ConnectionWidget::setActive(), Q3TextFormat::setBold(), and qdesigner_internal::FontProperty::setValue().
Here is the call graph for this function:

| void QFont::setBold | ( | bool | enable | ) | [inline] |
If enable is true sets the font's weight to QFont::Bold ; otherwise sets the weight to QFont::Normal.
For finer boldness control use setWeight().
Definition at line 247 of file qfont.h.
References Bold, Normal, and setWeight().
Referenced by PrintOut::addBox(), qdesigner_internal::InlineEditorModel::addTitle(), Q3Table::adjustColumn(), QMessageBox::changeEvent(), QCalendarWidgetPrivate::createHeader(), PPDOptionsModel::data(), GraphWidget::drawBackground(), qdesigner_internal::QPropertyEditor::drawBranches(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsStyle::drawControl(), QWindowsXPStyle::drawControl(), EditorPage::EditorPage(), EditorPage::fontChange(), Q3TextFormatCollection::format(), QMessageBoxPrivate::init(), BasicToolsPlugin::mouseMove(), Q3TextEdit::optimAppend(), Q3TextEdit::optimInsert(), MessagesItemDelegate::paint(), qdesigner_internal::ColorDelegate::paint(), qdesigner_internal::QPropertyEditorDelegate::paint(), Q3TableHeader::paintEvent(), QHeaderView::paintEvent(), QPixelTool::paintEvent(), PluginDialog::populateTreeWidget(), QBalloonTip::QBalloonTip(), qSetBold(), Q3TextFormat::setBold(), qdesigner_internal::RoleEditor::setEdited(), qdesigner_internal::QPropertyEditorDelegate::setModelData(), SpreadSheet::setupContents(), TextEdit::setupTextActions(), QWindowsStyle::sizeFromContents(), QCleanlooksStyle::subControlRect(), qdesigner_internal::TabOrderEditor::TabOrderEditor(), ToolBar::ToolBar(), QAbstractFormBuilder::toVariant(), and TransEditor::TransEditor().
Here is the call graph for this function:

| void QFont::setStyle | ( | Style | style | ) |
Sets the style of the font to style.
Definition at line 754 of file qfont.cpp.
References d, detach(), QFontPrivate::request, resolve_mask, and QFontDef::style.
Referenced by QFontDatabase::font(), fromString(), parseQFont(), parseShorthandFontProperty(), setFontStyleFromValue(), and setItalic().
00755 { 00756 detach(); 00757 00758 d->request.style = style; 00759 resolve_mask |= QFontPrivate::Style; 00760 }
Here is the call graph for this function:

| QFont::Style QFont::style | ( | ) | const |
Returns the style of the font.
Definition at line 743 of file qfont.cpp.
References d, QFontPrivate::request, and QFontDef::style.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), italic(), QFontDatabase::styleString(), and toString().
00744 { 00745 return (QFont::Style)d->request.style; 00746 }
| bool QFont::italic | ( | ) | const [inline] |
Returns true if the style() of the font is not QFont::StyleNormal
Definition at line 250 of file qfont.h.
References style(), and StyleNormal.
Referenced by Q3SVGPaintEnginePrivate::applyStyle(), Q3TextFormatter::bidiReorderLine(), qdesigner_internal::compareFonts(), QAbstractFormBuilder::createProperty(), TextEdit::fontChanged(), Q3TextFormatterBreakWords::format(), Q3TextFormatCollection::format(), getFontSet(), Q3TextEdit::italic(), Q3TextFormat::makeFormatChangeTags(), Q3TextFormat::makeFormatEndTags(), QTextCharFormat::setFont(), Q3TextParagraph::setFormat(), Q3TextFormat::setItalic(), and qdesigner_internal::FontProperty::setValue().
00251 { 00252 return (style() != StyleNormal); 00253 }
Here is the call graph for this function:

| void QFont::setItalic | ( | bool | enable | ) | [inline] |
Sets the style() of the font to QFont::StyleItalic if enable is true; otherwise the style is set to QFont::StyleNormal.
Definition at line 255 of file qfont.h.
References setStyle(), StyleItalic, and StyleNormal.
Referenced by PrintOut::addBox(), QDBusViewModel::data(), Q3TextFormatCollection::format(), fromString(), ItemDialog::ItemDialog(), BackTabTextEdit::loadResource(), QDesignerMenuBar::QDesignerMenuBar(), QTextFormatPrivate::recalcFont(), Q3TextFormat::setItalic(), qdesigner_internal::QPropertyEditorDelegate::setModelData(), Q3SVGPaintEnginePrivate::setStyleProperty(), TextEdit::setupTextActions(), and QAbstractFormBuilder::toVariant().
00255 { 00256 setStyle(b ? StyleItalic : StyleNormal); 00257 }
Here is the call graph for this function:

| bool QFont::underline | ( | ) | const |
Returns true if underline has been set; otherwise returns false.
Definition at line 831 of file qfont.cpp.
References d, and QFontPrivate::underline.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), qdesigner_internal::compareFonts(), QAbstractFormBuilder::createProperty(), TextEdit::fontChanged(), Q3TextFormatCollection::format(), Q3TextFormat::makeFormatChangeTags(), Q3TextFormat::makeFormatEndTags(), qt_drawFontLining(), QGLWidget::renderText(), QTextCharFormat::setFont(), QFontDialog::setFont(), Q3TextFormat::setUnderline(), qdesigner_internal::FontProperty::setValue(), toString(), and Q3TextEdit::underline().
| void QFont::setUnderline | ( | bool | enable | ) |
If enable is true, sets underline on; otherwise sets underline off.
Definition at line 842 of file qfont.cpp.
References d, detach(), resolve_mask, QFontPrivate::underline, and QFontPrivate::Underline.
Referenced by Q3TextParagraph::drawString(), QFontDialog::font(), Q3TextFormatCollection::format(), fromString(), Q3TextFormat::Q3TextFormat(), QTextFormatPrivate::recalcFont(), qdesigner_internal::QPropertyEditorDelegate::setModelData(), setTextDecorationFromValues(), Q3TextFormat::setUnderline(), TextEdit::setupTextActions(), and QAbstractFormBuilder::toVariant().
00843 { 00844 detach(); 00845 00846 d->underline = enable; 00847 resolve_mask |= QFontPrivate::Underline; 00848 }
Here is the call graph for this function:

| bool QFont::overline | ( | ) | const |
Returns true if overline has been set; otherwise returns false.
Definition at line 855 of file qfont.cpp.
References d, and QFontPrivate::overline.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), qdesigner_internal::compareFonts(), Q3TextFormat::makeFormatChangeTags(), qt_drawFontLining(), QGLWidget::renderText(), and QTextCharFormat::setFont().
| void QFont::setOverline | ( | bool | enable | ) |
If enable is true, sets overline on; otherwise sets overline off.
Definition at line 865 of file qfont.cpp.
References d, detach(), QFontPrivate::overline, QFontPrivate::Overline, and resolve_mask.
Referenced by QTextFormatPrivate::recalcFont(), and setTextDecorationFromValues().
00866 { 00867 detach(); 00868 00869 d->overline = enable; 00870 resolve_mask |= QFontPrivate::Overline; 00871 }
Here is the call graph for this function:

| bool QFont::strikeOut | ( | ) | const |
Returns true if strikeout has been set; otherwise returns false.
Definition at line 878 of file qfont.cpp.
References d, and QFontPrivate::strikeOut.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), qdesigner_internal::compareFonts(), QAbstractFormBuilder::createProperty(), Q3TextFormatCollection::format(), Q3TextFormat::makeFormatChangeTags(), Q3TextFormat::makeFormatEndTags(), qt_drawFontLining(), QGLWidget::renderText(), QTextCharFormat::setFont(), QFontDialog::setFont(), Q3TextFormat::setStrikeOut(), qdesigner_internal::FontProperty::setValue(), and toString().
| void QFont::setStrikeOut | ( | bool | enable | ) |
If enable is true, sets strikeout on; otherwise sets strikeout off.
Definition at line 889 of file qfont.cpp.
References d, detach(), resolve_mask, QFontPrivate::StrikeOut, and QFontPrivate::strikeOut.
Referenced by QFontDialog::font(), Q3TextFormatCollection::format(), fromString(), Q3TextFormat::Q3TextFormat(), QTextFormatPrivate::recalcFont(), qdesigner_internal::QPropertyEditorDelegate::setModelData(), Q3TextFormat::setStrikeOut(), setTextDecorationFromValues(), and QAbstractFormBuilder::toVariant().
00890 { 00891 detach(); 00892 00893 d->strikeOut = enable; 00894 resolve_mask |= QFontPrivate::StrikeOut; 00895 }
Here is the call graph for this function:

| bool QFont::fixedPitch | ( | ) | const |
Returns true if fixed pitch has been set; otherwise returns false.
Definition at line 902 of file qfont.cpp.
References d, QFontDef::fixedPitch, and QFontPrivate::request.
Referenced by QTextCharFormat::setFont(), and toString().
00903 { 00904 return d->request.fixedPitch; 00905 }
| void QFont::setFixedPitch | ( | bool | enable | ) |
If enable is true, sets fixed pitch on; otherwise sets fixed pitch off.
Definition at line 913 of file qfont.cpp.
References d, detach(), QFontDef::fixedPitch, QFontPrivate::FixedPitch, QFontDef::ignorePitch, QFontPrivate::request, and resolve_mask.
Referenced by fromString(), QTextFormatPrivate::recalcFont(), and MainWindow::setupEditor().
00914 { 00915 detach(); 00916 00917 d->request.fixedPitch = enable; 00918 d->request.ignorePitch = false; 00919 resolve_mask |= QFontPrivate::FixedPitch; 00920 }
Here is the call graph for this function:

| bool QFont::kerning | ( | ) | const |
Returns true if kerning should be used when drawing text with this font.
Definition at line 927 of file qfont.cpp.
References d, and QFontPrivate::kerning.
Referenced by Q3TextEdit::changeEvent(), QAbstractFormBuilder::createProperty(), Q3TextEdit::init(), Q3TextEdit::setFontInternal(), and qdesigner_internal::FontProperty::setValue().
| void QFont::setKerning | ( | bool | enable | ) |
Enables kerning for this font if enable is true; otherwise disables it. By default, kerning is enabled.
When kerning is enabled, glyph metrics do not add up anymore, even for Latin text. In other words, the assumption that width('a') + width('b') is equal to width("ab") is not neccesairly true.
Definition at line 943 of file qfont.cpp.
References d, detach(), QFontPrivate::Kerning, QFontPrivate::kerning, and resolve_mask.
Referenced by Q3TextEdit::changeEvent(), Q3TextEdit::init(), Q3TextEdit::setFontInternal(), qdesigner_internal::QPropertyEditorDelegate::setModelData(), and QAbstractFormBuilder::toVariant().
00944 { 00945 detach(); 00946 d->kerning = enable; 00947 resolve_mask |= QFontPrivate::Kerning; 00948 }
Here is the call graph for this function:

| QFont::StyleHint QFont::styleHint | ( | ) | const |
Returns the StyleHint.
The style hint affects the {QFont}{font matching} algorithm. See QFont::StyleHint for the list of available hints.
Definition at line 971 of file qfont.cpp.
References d, QFontPrivate::request, and QFontDef::styleHint.
Referenced by toString().
| QFont::StyleStrategy QFont::styleStrategy | ( | ) | const |
Returns the StyleStrategy.
The style strategy affects the {QFont}{font matching} algorithm. See QFont::StyleStrategy for the list of available strategies.
Definition at line 958 of file qfont.cpp.
References d, QFontPrivate::request, and QFontDef::styleStrategy.
Referenced by QAbstractFormBuilder::createProperty(), QGLWidget::fontDisplayListBase(), qdesigner_internal::FontProperty::setValue(), and CharacterWidget::updateStyle().
00959 { 00960 return (StyleStrategy) d->request.styleStrategy; 00961 }
| void QFont::setStyleHint | ( | StyleHint | hint, | |
| StyleStrategy | strategy = PreferDefault | |||
| ) |
Sets the style hint and strategy to hint and strategy, respectively.
If these aren't set explicitly the style hint will default to AnyStyle and the style strategy to PreferDefault.
Qt does not support style hints on X11 since this information is not provided by the window system.
Definition at line 1046 of file qfont.cpp.
References QFontDef::addStyle, QString::clear(), d, detach(), QFontPrivate::request, resolve_mask, QFontDef::styleHint, and QFontDef::styleStrategy.
Referenced by XFormView::drawTextType(), fromString(), and PathDeformRenderer::setText().
01047 { 01048 detach(); 01049 01050 if ((resolve_mask & (QFontPrivate::StyleHint | QFontPrivate::StyleStrategy)) && 01051 (StyleHint) d->request.styleHint == hint && 01052 (StyleStrategy) d->request.styleStrategy == strategy) 01053 return; 01054 01055 d->request.styleHint = hint; 01056 d->request.styleStrategy = strategy; 01057 resolve_mask |= QFontPrivate::StyleHint; 01058 resolve_mask |= QFontPrivate::StyleStrategy; 01059 01060 #if defined(Q_WS_X11) 01061 d->request.addStyle.clear(); 01062 #endif // Q_WS_X11 01063 }
Here is the call graph for this function:

| void QFont::setStyleStrategy | ( | StyleStrategy | s | ) |
Sets the style strategy for the font to s.
Definition at line 1070 of file qfont.cpp.
References d, detach(), QFontPrivate::request, resolve_mask, and QFontDef::styleStrategy.
Referenced by XFormView::drawTextType(), QGLContext::generateFontDisplayLists(), Chip::paint(), qdesigner_internal::QPropertyEditorDelegate::setModelData(), PathDeformRenderer::setText(), QAbstractFormBuilder::toVariant(), CharacterWidget::updateFontMerging(), and CharacterWidget::updateStyle().
01071 { 01072 detach(); 01073 01074 if ((resolve_mask & QFontPrivate::StyleStrategy) && 01075 s == (StyleStrategy)d->request.styleStrategy) 01076 return; 01077 01078 d->request.styleStrategy = s; 01079 resolve_mask |= QFontPrivate::StyleStrategy; 01080 }
Here is the call graph for this function:

| int QFont::stretch | ( | ) | const |
Returns the stretch factor for the font.
Definition at line 1107 of file qfont.cpp.
References d, QFontPrivate::request, and QFontDef::stretch.
| void QFont::setStretch | ( | int | factor | ) |
Sets the stretch factor for the font.
The stretch factor changes the width of all characters in the font by factor percent. For example, setting factor 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.
The stretch factor is only applied to outline fonts. The stretch factor is ignored for bitmap fonts.
NOTE: QFont 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.
Definition at line 1130 of file qfont.cpp.
References d, detach(), qWarning(), QFontPrivate::request, resolve_mask, and QFontDef::stretch.
01131 { 01132 if (factor < 1 || factor > 4000) { 01133 qWarning("QFont::setStretch: Parameter '%d' out of range", factor); 01134 return; 01135 } 01136 01137 detach(); 01138 01139 if ((resolve_mask & QFontPrivate::Stretch) && 01140 d->request.stretch == (uint)factor) 01141 return; 01142 01143 d->request.stretch = (uint)factor; 01144 resolve_mask |= QFontPrivate::Stretch; 01145 }
Here is the call graph for this function:

| bool QFont::rawMode | ( | ) | const |
Returns true if raw mode is used for font name matching; otherwise returns false.
Definition at line 1286 of file qfont.cpp.
References d, and QFontPrivate::rawMode.
Referenced by toString().
| void QFont::setRawMode | ( | bool | enable | ) |
If enable is true, turns raw mode on; otherwise turns raw mode off. This function only has an effect under X11.
If raw mode is enabled, Qt will search for an X font with a complete font name matching the family name, ignoring all other values set for the QFont. If the font name matches several fonts, Qt will use the first font returned by X. QFontInfo cannot be used to fetch information about a QFont using raw mode (it will return the values set in the QFont for all parameters, including the family name).
Definition at line 1164 of file qfont.cpp.
References d, detach(), and QFontPrivate::rawMode.
Referenced by fromString(), and setRawName().
01165 { 01166 detach(); 01167 01168 if ((bool) d->rawMode == enable) return; 01169 01170 d->rawMode = enable; 01171 }
Here is the call graph for this function:

| bool QFont::exactMatch | ( | ) | const |
Returns true if a window system font exactly matching the settings of this font is available.
Definition at line 1179 of file qfont.cpp.
References QFontEngine::Box, QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontDef::exactMatch(), QFontEngine::fontDef, QFontPrivate::rawMode, QFontPrivate::request, and QFontEngine::type().
01180 { 01181 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 01182 Q_ASSERT(engine != 0); 01183 return (d->rawMode 01184 ? engine->type() != QFontEngine::Box 01185 : d->request.exactMatch(engine->fontDef)); 01186 }
Here is the call graph for this function:

Assigns font to this font and returns a reference to it.
Definition at line 571 of file qfont.cpp.
References d, qAtomicAssign(), and resolve_mask.
00572 { 00573 qAtomicAssign(d, font.d); 00574 resolve_mask = font.resolve_mask; 00575 return *this; 00576 }
Here is the call graph for this function:

| bool QFont::operator== | ( | const QFont & | f | ) | const |
Returns true if this font is equal to f; otherwise returns false.
Two QFonts are considered equal if their font attributes are equal. If rawMode() is enabled for both fonts, only the family fields are compared.
Definition at line 1198 of file qfont.cpp.
References d, QFontPrivate::kerning, QFontPrivate::overline, QFontDef::pointSize, QFontPrivate::request, QFontPrivate::strikeOut, and QFontPrivate::underline.
Referenced by operator!=().
01199 { 01200 return (f.d == d 01201 || (f.d->request == d->request 01202 && f.d->request.pointSize == d->request.pointSize 01203 && f.d->underline == d->underline 01204 && f.d->overline == d->overline 01205 && f.d->strikeOut == d->strikeOut 01206 && f.d->kerning == d->kerning)); 01207 }
| bool QFont::operator!= | ( | const QFont & | f | ) | const |
Returns true if this font is different from f; otherwise returns false.
Two QFonts are considered to be different if their font attributes are different. If rawMode() is enabled for both fonts, only the family fields are compared.
Definition at line 1255 of file qfont.cpp.
References operator==().
01256 { 01257 return !(operator==(f)); 01258 }
Here is the call graph for this function:

| bool QFont::operator< | ( | const QFont & | f | ) | const |
Provides an arbitrary comparison of this font and font f. All that is guaranteed is that the operator returns false if both fonts are equal and that (f1 < f2) == !(f2 < f1) if the fonts are not equal.
This function is useful in some circumstances, for example if you want to use QFont objects as keys in a QMap.
Definition at line 1221 of file qfont.cpp.
References QFontDef::addStyle, d, QFontDef::family, QFontPrivate::kerning, QFontPrivate::overline, QFontDef::pixelSize, QFontDef::pointSize, QFontPrivate::request, QFontDef::stretch, QFontPrivate::strikeOut, QFontDef::style, QFontDef::styleHint, QFontDef::styleStrategy, QFontPrivate::underline, and QFontDef::weight.
01222 { 01223 if (f.d == d) return false; 01224 // the < operator for fontdefs ignores point sizes. 01225 QFontDef &r1 = f.d->request; 01226 QFontDef &r2 = d->request; 01227 if (r1.pointSize != r2.pointSize) return r1.pointSize < r2.pointSize; 01228 if (r1.pixelSize != r2.pixelSize) return r1.pixelSize < r2.pixelSize; 01229 if (r1.weight != r2.weight) return r1.weight < r2.weight; 01230 if (r1.style != r2.style) return r1.style < r2.style; 01231 if (r1.stretch != r2.stretch) return r1.stretch < r2.stretch; 01232 if (r1.styleHint != r2.styleHint) return r1.styleHint < r2.styleHint; 01233 if (r1.styleStrategy != r2.styleStrategy) return r1.styleStrategy < r2.styleStrategy; 01234 if (r1.family != r2.family) return r1.family < r2.family; 01235 #ifdef Q_WS_X11 01236 if (r1.addStyle != r2.addStyle) return r1.addStyle < r2.addStyle; 01237 #endif // Q_WS_X11 01238 01239 int f1attrs = (f.d->underline << 3) + (f.d->overline << 2) + (f.d->strikeOut<<1) + f.d->kerning; 01240 int f2attrs = (d->underline << 3) + (d->overline << 2) + (d->strikeOut<<1) + d->kerning; 01241 return f1attrs < f2attrs; 01242 }
| QFont::operator QVariant | ( | ) | const |
Returns the font as a QVariant
Definition at line 1263 of file qfont.cpp.
References QVariant::Font.
01264 { 01265 return QVariant(QVariant::Font, this); 01266 }
| bool QFont::isCopyOf | ( | const QFont & | f | ) | const |
Returns true if this font and f 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.
Definition at line 1275 of file qfont.cpp.
References d.
Referenced by qt_naturalWidgetFont().
| Qt::HANDLE QFont::handle | ( | ) | const |
Returns the window system handle to the font, for low-level access. Using this function is not portable.
Definition at line 207 of file qfont_x11.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QFontEngine::Multi, QFontEngine::type(), and QFontEngine::XLFD.
Referenced by QGLContext::generateFontDisplayLists().
00208 { 00209 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 00210 Q_ASSERT(engine != 0); 00211 if (engine->type() == QFontEngine::Multi) 00212 engine = static_cast<QFontEngineMulti *>(engine)->engine(0); 00213 if (engine->type() == QFontEngine::XLFD) 00214 return static_cast<QFontEngineXLFD *>(engine)->fontStruct()->fid; 00215 return 0; 00216 }
Here is the call graph for this function:

| void QFont::setRawName | ( | const QString & | 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 name to this function.
A font set with setRawName() is still a full-featured QFont. 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 name as its family.
Note that the present implementation does not handle wildcards in XLFDs well, and that font aliases (file fonts.alias in the font directory on X11) are not supported.
Definition at line 260 of file qfont_x11.cpp.
References QFontPrivate::Complete, d, detach(), QFontPrivate::dpi, name, qt_fillFontDef(), qt_fixXLFD(), qWarning(), QFontPrivate::request, resolve_mask, setFamily(), and setRawMode().
00261 { 00262 detach(); 00263 00264 // from qfontdatabase_x11.cpp 00265 extern bool qt_fillFontDef(const QByteArray &xlfd, QFontDef *fd, int dpi); 00266 00267 if (!qt_fillFontDef(qt_fixXLFD(name.toLatin1()), &d->request, d->dpi)) { 00268 qWarning("QFont::setRawName: Invalid XLFD: \"%s\"", name.toLatin1().constData()); 00269 00270 setFamily(name); 00271 setRawMode(true); 00272 } else { 00273 resolve_mask = QFontPrivate::Complete; 00274 } 00275 }
Here is the call graph for this function:

| QString QFont::rawName | ( | ) | const |
Returns the name of the font within the underlying window system.
On Windows and Mac OS X, this is usually just the family name of a TrueType font.
On X11, depending on whether Qt was built with FontConfig support, it is an XLFD (X Logical Font Description) or a FontConfig pattern. An XLFD may be returned even if FontConfig support is enabled.
Using the return value of this function is usually not portable.
Definition at line 233 of file qfont_x11.cpp.
References QUnicodeTables::Common, d, QFontPrivate::engineForScript(), QString::fromLatin1(), and QFontEngine::name().
00234 { 00235 QFontEngine *engine = d->engineForScript(QUnicodeTables::Common); 00236 Q_ASSERT(engine != 0); 00237 return QString::fromLatin1(engine->name()); 00238 }
Here is the call graph for this function:

| QString QFont::key | ( | ) | const |
Returns the font's key, a textual representation of a font. It is typically used as the key for a cache or dictionary of fonts.
Definition at line 1591 of file qfont.cpp.
References toString().
Referenced by QGLWidget::fontDisplayListBase(), Q3TextFormat::getKey(), and Dialog::setFont().
01592 { 01593 return toString(); 01594 }
Here is the call graph for this function:

| QString QFont::toString | ( | ) | const |
Returns a description of the font. The description is a comma-separated list of the attributes, perfectly suited for use in QSettings.
Definition at line 1603 of file qfont.cpp.
References family(), fixedPitch(), QString::number(), pixelSize(), pointSizeF(), rawMode(), strikeOut(), style(), styleHint(), underline(), and weight().
Referenced by MainWindow::fileSave(), and key().
01604 { 01605 const QChar comma(QLatin1Char(',')); 01606 return family() + comma + 01607 QString::number( pointSizeF()) + comma + 01608 QString::number( pixelSize()) + comma + 01609 QString::number((int) styleHint()) + comma + 01610 QString::number( weight()) + comma + 01611 QString::number((int) style()) + comma + 01612 QString::number((int) underline()) + comma + 01613 QString::number((int) strikeOut()) + comma + 01614 QString::number((int)fixedPitch()) + comma + 01615 QString::number((int) rawMode()); 01616 }
Here is the call graph for this function:

| bool QFont::fromString | ( | const QString & | descrip | ) |
Sets this font to match the description descrip. The description is a comma-separated list of the font attributes, as returned by toString().
Definition at line 1626 of file qfont.cpp.
References QByteArray::data(), QString::isEmpty(), l, qMax(), qMin(), qWarning(), setFamily(), setFixedPitch(), setItalic(), setPixelSize(), setPointSizeF(), setRawMode(), setStrikeOut(), setStyle(), setStyleHint(), setUnderline(), setWeight(), QString::split(), toDouble(), and QString::toLatin1().
Referenced by convert().
01627 { 01628 QStringList l(descrip.split(QLatin1Char(','))); 01629 01630 int count = l.count(); 01631 if (!count || (count > 2 && count < 9) || count > 11) { 01632 qWarning("QFont::fromString: Invalid description '%s'", 01633 descrip.isEmpty() ? "(empty)" : descrip.toLatin1().data()); 01634 return false; 01635 } 01636 01637 setFamily(l[0]); 01638 if (count > 1 && l[1].toDouble() > 0.0) 01639 setPointSizeF(l[1].toDouble()); 01640 if (count == 9) { 01641 setStyleHint((StyleHint) l[2].toInt()); 01642 setWeight(qMax(qMin(99, l[3].toInt()), 0)); 01643 setItalic(l[4].toInt()); 01644 setUnderline(l[5].toInt()); 01645 setStrikeOut(l[6].toInt()); 01646 setFixedPitch(l[7].toInt()); 01647 setRawMode(l[8].toInt()); 01648 } else if (count == 10) { 01649 if (l[2].toInt() > 0) 01650 setPixelSize(l[2].toInt()); 01651 setStyleHint((StyleHint) l[3].toInt()); 01652 setWeight(qMax(qMin(99, l[4].toInt()), 0)); 01653 setStyle((QFont::Style)l[5].toInt()); 01654 setUnderline(l[6].toInt()); 01655 setStrikeOut(l[7].toInt()); 01656 setFixedPitch(l[8].toInt()); 01657 setRawMode(l[9].toInt()); 01658 } 01659 01660 return true; 01661 }
Here is the call graph for this function:

Returns the first family name to be used whenever familyName is specified. The lookup is case insensitive.
If there is no substitution for familyName, familyName is returned.
To obtain a list of substitutions use substitutes().
Definition at line 1411 of file qfont.cpp.
References QHash< Key, T >::constEnd(), QHash< Key, T >::constFind(), initFontSubst(), and QString::toLower().
01412 { 01413 initFontSubst(); 01414 01415 QFontSubst *fontSubst = globalFontSubst(); 01416 Q_ASSERT(fontSubst != 0); 01417 QFontSubst::ConstIterator it = fontSubst->constFind(familyName.toLower()); 01418 if (it != fontSubst->constEnd() && !(*it).isEmpty()) 01419 return (*it).first(); 01420 01421 return familyName; 01422 }
Here is the call graph for this function:

| QStringList QFont::substitutes | ( | const QString & | familyName | ) | [static] |
Returns a list of family names to be used whenever familyName is specified. The lookup is case insensitive.
If there is no substitution for familyName, an empty list is returned.
Definition at line 1434 of file qfont.cpp.
References initFontSubst(), QString::toLower(), and QHash< Key, T >::value().
Referenced by MainWindow::addSubstitute(), MainWindow::downSubstitute(), familyList(), MainWindow::fileSave(), MainWindow::removeSubstitute(), MainWindow::substituteSelected(), and MainWindow::upSubstitute().
01435 { 01436 initFontSubst(); 01437 01438 QFontSubst *fontSubst = globalFontSubst(); 01439 Q_ASSERT(fontSubst != 0); 01440 return fontSubst->value(familyName.toLower(), QStringList()); 01441 }
Here is the call graph for this function:

| QStringList QFont::substitutions | ( | ) | [static] |
Returns a sorted list of substituted family names.
Definition at line 1509 of file qfont.cpp.
References QList< T >::append(), QHash< Key, T >::constBegin(), QHash< Key, T >::constEnd(), initFontSubst(), QHash< Key, T >::const_iterator::key(), and QStringList::sort().
Referenced by MainWindow::fileSave().
01510 { 01511 initFontSubst(); 01512 01513 QFontSubst *fontSubst = globalFontSubst(); 01514 Q_ASSERT(fontSubst != 0); 01515 QStringList ret; 01516 QFontSubst::ConstIterator it = fontSubst->constBegin(); 01517 01518 while (it != fontSubst->constEnd()) { 01519 ret.append(it.key()); 01520 ++it; 01521 } 01522 01523 ret.sort(); 01524 return ret; 01525 }
Here is the call graph for this function:

| void QFont::insertSubstitution | ( | const QString & | familyName, | |
| const QString & | substituteName | |||
| ) | [static] |
Inserts substituteName into the substitution table for the family familyName.
Definition at line 1450 of file qfont.cpp.
References QList< T >::append(), QStringList::contains(), initFontSubst(), s, and QString::toLower().
Referenced by MainWindow::addSubstitute().
01452 { 01453 initFontSubst(); 01454 01455 QFontSubst *fontSubst = globalFontSubst(); 01456 Q_ASSERT(fontSubst != 0); 01457 QStringList &list = (*fontSubst)[familyName.toLower()]; 01458 QString s = substituteName.toLower(); 01459 if (!list.contains(s)) 01460 list.append(s); 01461 }
Here is the call graph for this function:

| void QFont::insertSubstitutions | ( | const QString & | familyName, | |
| const QStringList & | substituteNames | |||
| ) | [static] |
Inserts the list of families substituteNames into the substitution list for familyName.
Definition at line 1470 of file qfont.cpp.
References QList< T >::append(), QList< T >::constBegin(), QList< T >::constEnd(), QStringList::contains(), initFontSubst(), s, and QString::toLower().
Referenced by MainWindow::downSubstitute(), MainWindow::removeSubstitute(), and MainWindow::upSubstitute().
01472 { 01473 initFontSubst(); 01474 01475 QFontSubst *fontSubst = globalFontSubst(); 01476 Q_ASSERT(fontSubst != 0); 01477 QStringList &list = (*fontSubst)[familyName.toLower()]; 01478 QStringList::ConstIterator it = substituteNames.constBegin(); 01479 while (it != substituteNames.constEnd()) { 01480 QString s = (*it).toLower(); 01481 if (!list.contains(s)) 01482 list.append(s); 01483 it++; 01484 } 01485 }
Here is the call graph for this function:

| void QFont::removeSubstitution | ( | const QString & | familyName | ) | [static] |
Removes all the substitutions for familyName.
Definition at line 1493 of file qfont.cpp.
References initFontSubst(), QHash< Key, T >::remove(), and QString::toLower().
Referenced by MainWindow::downSubstitute(), MainWindow::removeSubstitute(), and MainWindow::upSubstitute().
01494 { // ### function name should be removeSubstitutions() or 01495 // ### removeSubstitutionList() 01496 initFontSubst(); 01497 01498 QFontSubst *fontSubst = globalFontSubst(); 01499 Q_ASSERT(fontSubst != 0); 01500 fontSubst->remove(familyName.toLower()); 01501 }
Here is the call graph for this function:

| void QFont::initialize | ( | ) | [static] |
Internal function that initializes the font system.
Definition at line 118 of file qfont_x11.cpp.
References codec(), QTextCodec::codecForLocale(), QFontPrivate::defaultEncodingID, QFontCache::instance, mib, QTextCodec::mibEnum(), and qt_encoding_id_for_mib().
00119 { 00120 // create global font cache 00121 if (! QFontCache::instance) (void) new QFontCache; 00122 00123 extern int qt_encoding_id_for_mib(int mib); // from qfontdatabase_x11.cpp 00124 QTextCodec *codec = QTextCodec::codecForLocale(); 00125 // determine the default encoding id using the locale, otherwise 00126 // fallback to latin1 (mib == 4) 00127 int mib = codec ? codec->mibEnum() : 4; 00128 00129 // for asian locales, use the mib for the font codec instead of the locale codec 00130 switch (mib) { 00131 case 38: // eucKR 00132 mib = 36; 00133 break; 00134 00135 case 2025: // GB2312 00136 mib = 57; 00137 break; 00138 00139 case 113: // GBK 00140 mib = -113; 00141 break; 00142 00143 case 114: // GB18030 00144 mib = -114; 00145 break; 00146 00147 case 2026: // Big5 00148 mib = -2026; 00149 break; 00150 00151 case 2101: // Big5-HKSCS 00152 mib = -2101; 00153 break; 00154 00155 case 16: // JIS7 00156 mib = 15; 00157 break; 00158 00159 case 17: // SJIS 00160 case 18: // eucJP 00161 mib = 63; 00162 break; 00163 } 00164 00165 // get the default encoding id for the locale encoding... 00166 QFontPrivate::defaultEncodingID = qt_encoding_id_for_mib(mib); 00167 }
Here is the call graph for this function:

| void QFont::cleanup | ( | ) | [static] |
Definition at line 173 of file qfont_x11.cpp.
References QFontCache::instance.
Referenced by qt_cleanup().
00174 { 00175 // delete the global font cache 00176 delete QFontCache::instance; 00177 }
| void QFont::cacheStatistics | ( | ) | [static] |
| QString QFont::defaultFamily | ( | ) | const |
Returns the family name that corresponds to the current style hint.
Definition at line 297 of file qfont_x11.cpp.
References Courier, d, Decorative, QString::fromLatin1(), Helvetica, QFontPrivate::request, QFontDef::styleHint, System, and Times.
Referenced by getFcPattern().
00298 { 00299 switch (d->request.styleHint) { 00300 case QFont::Times: 00301 return QString::fromLatin1("Times"); 00302 00303 case QFont::Courier: 00304 return QString::fromLatin1("Courier"); 00305 00306 case QFont::Decorative: 00307 return QString::fromLatin1("Old English"); 00308 00309 case QFont::Helvetica: 00310 case QFont::System: 00311 default: 00312 return QString::fromLatin1("Helvetica"); 00313 } 00314 }
Here is the call graph for this function:

| QString QFont::lastResortFamily | ( | ) | const |
Returns the "last resort" font family name.
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 an empty string is returned.
Definition at line 286 of file qfont_x11.cpp.
References QString::fromLatin1().
Referenced by QFontDialog::updateFamilies().
00287 { 00288 return QString::fromLatin1("Helvetica"); 00289 }
Here is the call graph for this function:

| QString QFont::lastResortFont | ( | ) | const |
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".
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 Qt 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.
Definition at line 374 of file qfont_x11.cpp.
References fontExists(), QString::fromLatin1(), i, and QString::isNull().
00375 { 00376 static QString last; 00377 00378 // already found 00379 if (! last.isNull()) 00380 return last; 00381 00382 int i = 0; 00383 const char* f; 00384 00385 while ((f = tryFonts[i])) { 00386 last = QString::fromLatin1(f); 00387 00388 if (fontExists(last)) 00389 return last; 00390 00391 i++; 00392 } 00393 00394 #if defined(CHECK_NULL) 00395 qFatal("QFontPrivate::lastResortFont: Cannot find any reasonable font"); 00396 #endif 00397 00398 return last; 00399 }
Here is the call graph for this function:

Returns a new QFont that has attributes copied from other that have not been previously set on this font.
Definition at line 1295 of file qfont.cpp.
References d, detach(), QFontPrivate::dpi, o, QFontPrivate::resolve(), and resolve_mask.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), QAbstractFormBuilder::createProperty(), QTextEngine::font(), QTextEngine::fontEngine(), qt_naturalWidgetFont(), qdesigner_internal::QPropertyEditorDelegate::resetProperty(), QWidgetPrivate::resolveFont(), QTextFormatPrivate::resolveFont(), QPainter::setFont(), QWidget::setFont(), QWidgetPrivate::setFont_helper(), QItemDelegate::setOptions(), qdesigner_internal::FontProperty::setValue(), and unsetPalette().
01296 { 01297 if (*this == other 01298 && (resolve_mask == other.resolve_mask || resolve_mask == 0) 01299 && d->dpi == other.d->dpi) { 01300 QFont o = other; 01301 o.resolve_mask = resolve_mask; 01302 return o; 01303 } 01304 01305 QFont font(*this); 01306 font.detach(); 01307 font.d->resolve(resolve_mask, other.d); 01308 01309 return font; 01310 }
Here is the call graph for this function:

| uint QFont::resolve | ( | ) | const [inline] |
| void QFont::resolve | ( | uint | mask | ) | [inline] |
| void QFont::detach | ( | ) | [private] |
Definition at line 484 of file qfont.cpp.
References d, QBasicAtomic::deref(), QFontPrivate::engineData, qAtomicDetach(), QFontEngineData::ref, and QFontPrivate::ref.
Referenced by resolve(), setFamily(), setFixedPitch(), setKerning(), setOverline(), setPixelSize(), setPointSize(), setPointSizeF(), setRawMode(), setRawName(), setStretch(), setStrikeOut(), setStyle(), setStyleHint(), setStyleStrategy(), setUnderline(), and setWeight().
00485 { 00486 if (d->ref == 1) { 00487 if (d->engineData) 00488 d->engineData->ref.deref(); 00489 d->engineData = 0; 00490 return; 00491 } 00492 00493 qAtomicDetach(d); 00494 }
Here is the call graph for this function:

friend class QFontMetrics [friend] |
friend class QFontMetricsF [friend] |
friend class QApplication [friend] |
friend class QWidgetPrivate [friend] |
friend class Q3TextFormatCollection [friend] |
friend class QTextLayout [friend] |
friend class QTextEngine [friend] |
friend class QStackTextEngine [friend] |
friend struct QScriptLine [friend] |
friend class QGLContext [friend] |
friend class QPainterPath [friend] |
friend class QTextItemInt [friend] |
| QDataStream & operator<< | ( | QDataStream & | s, | |
| const QFont & | font | |||
| ) | [friend] |
Writes the font font to the data stream s. (toString() writes to a text stream.)
Definition at line 1690 of file qfont.cpp.
01691 { 01692 if (s.version() == 1) { 01693 s << font.d->request.family.toLatin1(); 01694 } else { 01695 s << font.d->request.family; 01696 } 01697 01698 if (s.version() >= QDataStream::Qt_4_0) { 01699 // 4.0 01700 double pointSize = font.d->request.pointSize; 01701 qint32 pixelSize = font.d->request.pixelSize; 01702 s << pointSize; 01703 s << pixelSize; 01704 } else if (s.version() <= 3) { 01705 qint16 pointSize = (qint16) (font.d->request.pointSize * 10); 01706 if (pointSize < 0) { 01707 #ifdef Q_WS_X11 01708 pointSize = (qint16)(font.d->request.pixelSize*720/QX11Info::appDpiY()); 01709 #else 01710 pointSize = (qint16)QFontInfo(font).pointSize() * 10; 01711 #endif 01712 } 01713 s << pointSize; 01714 } else { 01715 s << (qint16) (font.d->request.pointSize * 10); 01716 s << (qint16) font.d->request.pixelSize; 01717 } 01718 01719 s << (quint8) font.d->request.styleHint; 01720 if (s.version() >= 5) 01721 s << (quint8) font.d->request.styleStrategy; 01722 return s << (quint8) 0 01723 << (quint8) font.d->request.weight 01724 << get_font_bits(s.version(), font.d); 01725 }
| QDataStream & operator>> | ( | QDataStream & | s, | |
| QFont & | font | |||
| ) | [friend] |
Reads the font font from the data stream s. (fromString() reads from a text stream.)
Definition at line 1736 of file qfont.cpp.
01737 { 01738 if (!font.d->ref.deref()) 01739 delete font.d; 01740 01741 font.d = new QFontPrivate; 01742 font.resolve_mask = QFontPrivate::Complete; 01743 01744 quint8 styleHint, styleStrategy = QFont::PreferDefault, charSet, weight, bits; 01745 01746 if (s.version() == 1) { 01747 QByteArray fam; 01748 s >> fam; 01749 font.d->request.family = QString::fromLatin1(fam); 01750 } else { 01751 s >> font.d->request.family; 01752 } 01753 01754 if (s.version() >= QDataStream::Qt_4_0) { 01755 // 4.0 01756 double pointSize; 01757 qint32 pixelSize; 01758 s >> pointSize; 01759 s >> pixelSize; 01760 font.d->request.pointSize = qreal(pointSize); 01761 font.d->request.pixelSize = pixelSize; 01762 } else { 01763 qint16 pointSize, pixelSize = -1; 01764 s >> pointSize; 01765 if (s.version() >= 4) 01766 s >> pixelSize; 01767 font.d->request.pointSize = qreal(pointSize / 10.); 01768 font.d->request.pixelSize = pixelSize; 01769 } 01770 s >> styleHint; 01771 if (s.version() >= 5) 01772 s >> styleStrategy; 01773 s >> charSet; 01774 s >> weight; 01775 s >> bits; 01776 01777 font.d->request.styleHint = styleHint; 01778 font.d->request.styleStrategy = styleStrategy; 01779 font.d->request.weight = weight; 01780 01781 set_font_bits(s.version(), bits, font.d); 01782 01783 return s; 01784 }
QFontPrivate* QFont::d [private] |
Definition at line 238 of file qfont.h.
Referenced by QPainterPath::addText(), defaultFamily(), detach(), QTextLine::draw(), QTextEngine::elidedText(), exactMatch(), family(), fixedPitch(), QTextEngine::fontEngine(), QGLContext::generateFontDisplayLists(), handle(), QTextItemInt::initFontAttributes(), isCopyOf(), kerning(), operator<(), operator=(), operator==(), overline(), pixelSize(), pointSize(), pointSizeF(), QFont(), QFontMetrics::QFontMetrics(), QFontMetricsF::QFontMetricsF(), QTextLayout::QTextLayout(), rawMode(), rawName(), resolve(), QScriptLine::setDefaultHeight(), setFamily(), setFixedPitch(), setKerning(), setOverline(), setPixelSize(), setPointSize(), setPointSizeF(), setRawMode(), setRawName(), setStretch(), setStrikeOut(), setStyle(), setStyleHint(), setStyleStrategy(), setUnderline(), setWeight(), QTextEngine::shapeText(), stretch(), strikeOut(), style(), styleHint(), styleStrategy(), underline(), weight(), and ~QFont().
uint QFont::resolve_mask [private] |
Definition at line 239 of file qfont.h.
Referenced by operator=(), QFont(), resolve(), setFamily(), setFixedPitch(), setKerning(), setOverline(), setPixelSize(), setPointSize(), setPointSizeF(), setRawName(), setStretch(), setStrikeOut(), setStyle(), setStyleHint(), setStyleStrategy(), setUnderline(), and setWeight().
1.5.1