Skip to content

PythonQt.Qt.QFontDatabase

QFontDatabase

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

The most common uses of this class are to query the database for the list of font families() and for the pointSizes() and styles() that are available for each family. An alternative to pointSizes() is smoothSizes() which returns the sizes at which a given family and style will look attractive.

If the font family is available from two or more foundries the foundry name is included in the family name; for example: "Helvetica [Adobe]" and "Helvetica [Cronyx]". When you specify a family, you can either use the old hyphenated "foundry-family" format or the bracketed "family [foundry]" format; for example: "Cronyx-Helvetica" or "Helvetica [Cronyx]". If the family has a foundry it is always returned using the bracketed format, as is the case with the value returned by families().

The font() function returns a QFont given a family, style and point size.

A family and style combination can be checked to see if it is italic() or bold(), and to retrieve its weight(). Similarly we can call isBitmapScalable(), isSmoothlyScalable(), isScalable() and isFixedPitch().

Use the styleString() to obtain a text version of a style.

The QFontDatabase class also supports some static functions, for example, standardSizes(). You can retrieve the description of a writing system using writingSystemName(), and a sample of characters in a writing system with writingSystemSample().

Example:

    QFontDatabase database;
    QTreeWidget fontTree;
    fontTree.setColumnCount(2);
    fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");

    const QStringList fontFamilies = database.families();
    for (const QString &family : fontFamilies) {
        QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
        familyItem->setText(0, family);

        const QStringList fontStyles = database.styles(family);
        for (const QString &style : fontStyles) {
            QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
            styleItem->setText(0, style);

            QString sizes;
            const QList<int> smoothSizes = database.smoothSizes(family, style)
            for (int points : smoothSizes)
                sizes += QString::number(points) + ' ';

            styleItem->setText(1, sizes.trimmed());
        }
    }

This example gets the list of font families, the list of styles for each family, and the point sizes that are available for each combination of family and style, displaying this information in a tree view.

Source: https://doc.qt.io/archives/qt-5.15/qfontdatabase.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
Any attribute Any (shared captured text)
Arabic attribute Any (shared captured text)
Armenian attribute Any (shared captured text)
Bengali attribute Any (shared captured text)
Cyrillic attribute Any (shared captured text)
Devanagari attribute Any (shared captured text)
FixedFont attribute Any (shared captured text)
GeneralFont attribute Any (shared captured text)
Georgian attribute Any (shared captured text)
Greek attribute Any (shared captured text)
Gujarati attribute Any (shared captured text)
Gurmukhi attribute Any (shared captured text)
Hebrew attribute Any (shared captured text)
Japanese attribute Any (shared captured text)
Kannada attribute Any (shared captured text)
Khmer attribute Any (shared captured text)
Korean attribute Any (shared captured text)
Lao attribute Any (shared captured text)
Latin attribute Any (shared captured text)
Malayalam attribute Any (shared captured text)
Myanmar attribute Any (shared captured text)
Nko attribute Any (shared captured text)
Ogham attribute Any (shared captured text)
Oriya attribute Any (shared captured text)
Other attribute Any (shared captured text)
Runic attribute Any (shared captured text)
SimplifiedChinese attribute Any (shared captured text)
Sinhala attribute Any (shared captured text)
SmallestReadableFont attribute Any (shared captured text)
Symbol attribute Any (shared captured text)
Syriac attribute Any (shared captured text)
SystemFont attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
Tamil attribute Any (shared captured text)
Telugu attribute Any (shared captured text)
Thaana attribute Any (shared captured text)
Thai attribute Any (shared captured text)
Tibetan attribute Any (shared captured text)
TitleFont attribute Any (shared captured text)
TraditionalChinese attribute Any (shared captured text)
Vietnamese attribute Any (shared captured text)
WritingSystem attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
WritingSystemsCount attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
addApplicationFont function (self, fileName: str) -> int X.addApplicationFont(fileName) -> int (shared captured text)
addApplicationFontFromData function (self, fontData: Any) -> int X.addApplicationFontFromData(fontData) -> int (shared captured text)
applicationFontFamilies function (self, id: int) -> tuple X.applicationFontFamilies(id) -> tuple (shared captured text)
bold function (self, family: str, style: str) -> bool X.bold(family, style) -> bool (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
families function (self, writingSystem: Any) -> tuple X.families(writingSystem) -> tuple (shared captured text)
font function (self, family: str, style: str, pointSize: int) -> Any X.font(family, style, pointSize) -> PythonQt.QtGui.QFont (shared captured text)
hasFamily function (self, family: str) -> bool X.hasFamily(family) -> bool (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
isBitmapScalable function (self, family: str, style: str) -> bool X.isBitmapScalable(family, style) -> bool (shared captured text)
isFixedPitch function (self, family: str, style: str) -> bool X.isFixedPitch(family, style) -> bool (shared captured text)
isPrivateFamily function (self, family: str) -> bool X.isPrivateFamily(family) -> bool (shared captured text)
isScalable function (self, family: str, style: str) -> bool X.isScalable(family, style) -> bool (shared captured text)
isSmoothlyScalable function (self, family: str, style: str) -> bool X.isSmoothlyScalable(family, style) -> bool (shared captured text)
italic function (self, family: str, style: str) -> bool X.italic(family, style) -> bool (shared captured text)
pointSizes function (self, family: str, style: str) -> tuple X.pointSizes(family, style) -> tuple (shared captured text)
removeAllApplicationFonts function (self) -> bool X.removeAllApplicationFonts() -> bool (shared captured text)
removeApplicationFont function (self, id: int) -> bool X.removeApplicationFont(id) -> bool (shared captured text)
smoothSizes function (self, family: str, style: str) -> tuple X.smoothSizes(family, style) -> tuple (shared captured text)
standardSizes function (self) -> tuple X.standardSizes() -> tuple (shared captured text)
styleString function (self, font: Any) -> str X.styleString(font) -> str (shared captured text)
styles function (self, family: str) -> tuple X.styles(family) -> tuple (shared captured text)
supportsThreadedFontRendering function (self) -> bool X.supportsThreadedFontRendering() -> bool (shared captured text)
systemFont function (self, type: Any) -> Any X.systemFont(type) -> PythonQt.QtGui.QFont (shared captured text)
weight function (self, family: str, style: str) -> int X.weight(family, style) -> int (shared captured text)
writingSystemName function (self, writingSystem: Any) -> str X.writingSystemName(writingSystem) -> str (shared captured text)
writingSystemSample function (self, writingSystem: Any) -> str X.writingSystemSample(writingSystem) -> str (shared captured text)
writingSystems function (self, family: Any) -> tuple X.writingSystems(family) -> tuple (shared captured text)