Detailed Description
The QPlatformFontDatabase class makes it possible to customize how fonts are discovered and how they are rendered
QPlatformFontDatabase is the superclass which is intended to let platform implementations use native font handling.
Qt has its internal font database which it uses to discover available fonts on the user's system. To be able to populate this database subclass this class, and reimplement populateFontDatabase().
Use the function registerFont() to populate the internal font database.
Sometimes a specified font does not have the required glyphs; in such a case, the fallbackForFamily() function is called automatically to find alternative font families that can supply alternatives to the missing glyphs.
Member Function Documentation
QStringList QPlatformFontDatabase::addApplicationFont ( const QByteArray & fontData, const QString & fileName ) [virtual]
Adds an application font described by the font contained supplied fontData or using the font contained in the file referenced by fileName. Returns a list of family names, or an empty list if the font could not be added.
Note: The default implementation of this function does not add an application font. Subclasses should reimplement this function to perform the necessary loading and registration of fonts.
Returns a list of alternative fonts for the specified family and style and script using the styleHint given.
QString QPlatformFontDatabase::fontDir () const [virtual]
Returns the path to the font directory.
The font directory is stored in the general Qt settings unless it has been overridden by the QT_QPA_FONTDIR environment variable.
When using builds of Qt that do not support settings, the QT_QPA_FONTDIR environment variable is the only way to specify the font directory.
QFontEngine * QPlatformFontDatabase::fontEngine ( const QFontDef & fontDef, QUnicodeTables::Script script, void * handle ) [virtual]
Returns the font engine that can be used to render the font described by the font definition, fontDef, in the specified script.
QFontEngine * QPlatformFontDatabase::fontEngine ( const QByteArray & fontData, qreal pixelSize, QFont::HintingPreference hintingPreference ) [virtual]
void QPlatformFontDatabase::populateFontDatabase () [virtual]
This function is called once at startup by Qts internal fontdatabase. Reimplement this function in a subclass for a convenient place to initialise the internal fontdatabase.
The default implementation looks in the fontDir() location and registers all qpf2 fonts.
void QPlatformFontDatabase::registerFont ( const QString & familyName, const QString & foundryName, QFont::Weight weight, QFont::Style style, QFont::Stretch stretch, bool antialiased, bool scalable, int pixelSize, const QSupportedWritingSystems & writingSystems, void * usrPtr ) [static]
Registers a font with the given set of attributes describing the font's foundry, family name, style and stretch information, pixel size, and supported writing systems. Additional information about whether the font can be scaled and antialiased can also be provided.
The foundry name and font family are described by foundryName and familyName. The font weight (light, normal, bold, etc.), style (normal, oblique, italic) and stretch information (condensed, expanded, unstretched, etc.) are specified by weight, style and stretch.
Some fonts can be antialiased and scaled; scalable and antialiased can be set to true for fonts with these attributes. The intended pixel size of non-scalable fonts is specified by pixelSize; this value will be ignored for scalable fonts.
The writing systems supported by the font are specified by the writingSystems argument.
See also registerQPF2Font().
void QPlatformFontDatabase::registerQPF2Font ( const QByteArray & dataArray, void * handle ) [static]
Registers the pre-rendered QPF2 font contained in the given dataArray.
See also registerFont().
void QPlatformFontDatabase::releaseHandle ( void * handle ) [virtual]
Releases the font handle and deletes any associated data loaded from a file.