Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QFont QFontDatabase::font ( const QString family,
const QString style,
int  pointSize 
) const

Returns a QFont object that has family family, style style and point size pointSize. If no matching font could be created, a QFont object that uses the application's default font is returned.

Definition at line 1743 of file qfontdatabase.cpp.

References QApplication::font(), QString::isEmpty(), load(), and QFont::setStyle().

Referenced by CharacterWidget::updateStyle().

    QString familyName, foundryName;
    parseFontName(family, foundryName, familyName);

    QMutexLocker locker(fontDatabaseMutex());


    QtFontFoundry allStyles(foundryName);
    QtFontFamily *f = d->family(familyName);
    if (!f) return QApplication::font();

    for (int j = 0; j < f->count; j++) {
        QtFontFoundry *foundry = f->foundries[j];
        if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) {
            for (int k = 0; k < foundry->count; k++)
                allStyles.style(foundry->styles[k]->key, true);

    QtFontStyle::Key styleKey(style);
    QtFontStyle *s = bestStyle(&allStyles, styleKey);

    if (!s) // no styles found?
        return QApplication::font();
    QFont fnt(family, pointSize, s->key.weight);
    return fnt;

Generated by  Doxygen 1.6.0   Back to index