Skip to content

PythonQt.QtGui.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
Arabic attribute Any (shared captured text)
Armenian attribute Any (shared captured text)
Bengali attribute Any (shared captured text)
Cyrillic attribute Any
Devanagari attribute Any
FixedFont attribute Any
GeneralFont attribute Any
Georgian attribute Any (shared captured text)
Greek attribute Any (shared captured text)
Gujarati attribute Any (shared captured text)
Gurmukhi attribute Any
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
Oriya attribute Any (shared captured text)
Other attribute Any (shared captured text)
Runic attribute Any
SimplifiedChinese attribute Any
Sinhala attribute Any (shared captured text)
SmallestReadableFont attribute Any
Symbol attribute Any
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.
Tamil attribute Any (shared captured text)
Telugu attribute Any (shared captured text)
Thaana attribute Any
Thai attribute Any (shared captured text)
Tibetan attribute Any (shared captured text)
TitleFont attribute Any
TraditionalChinese attribute Any
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.
WritingSystemsCount attribute Any
__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
addApplicationFontFromData function (self, fontData: Any) -> int X.addApplicationFontFromData(fontData) -> int
applicationFontFamilies function (self, id: int) -> tuple X.applicationFontFamilies(id) -> tuple
bold function (self, family: str, style: str) -> bool X.bold(family, style) -> bool
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
font function (self, family: str, style: str, pointSize: int) -> Any X.font(family, style, pointSize) -> PythonQt.QtGui.QFont
hasFamily function (self, family: str) -> bool X.hasFamily(family) -> bool
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
isFixedPitch function (self, family: str, style: str) -> bool X.isFixedPitch(family, style) -> bool
isPrivateFamily function (self, family: str) -> bool X.isPrivateFamily(family) -> bool
isScalable function (self, family: str, style: str) -> bool X.isScalable(family, style) -> bool
isSmoothlyScalable function (self, family: str, style: str) -> bool X.isSmoothlyScalable(family, style) -> bool
italic function (self, family: str, style: str) -> bool X.italic(family, style) -> bool
pointSizes function (self, family: str, style: str) -> tuple X.pointSizes(family, style) -> tuple
removeAllApplicationFonts function (self) -> bool X.removeAllApplicationFonts() -> bool
removeApplicationFont function (self, id: int) -> bool X.removeApplicationFont(id) -> bool
smoothSizes function (self, family: str, style: str) -> tuple X.smoothSizes(family, style) -> tuple
standardSizes function (self) -> tuple X.standardSizes() -> tuple
styleString function (self, font: Any) -> str X.styleString(font) -> str
styles function (self, family: str) -> tuple X.styles(family) -> tuple
supportsThreadedFontRendering function (self) -> bool X.supportsThreadedFontRendering() -> bool
systemFont function (self, type: Any) -> Any X.systemFont(type) -> PythonQt.QtGui.QFont
weight function (self, family: str, style: str) -> int X.weight(family, style) -> int
writingSystemName function (self, writingSystem: Any) -> str X.writingSystemName(writingSystem) -> str
writingSystemSample function (self, writingSystem: Any) -> str X.writingSystemSample(writingSystem) -> str
writingSystems function (self, family: Any) -> tuple X.writingSystems(family) -> tuple