CopperSpice API  1.9.1
QPlatformFontDatabase Class Reference

Customize how fonts are discovered and how they are rendered. More...

Public Methods

virtual QStringList addApplicationFont (const QByteArray &fontData, const QString &fileName)
virtual QFont defaultFont () const
virtual QStringList fallbacksForFamily (const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
virtual QString fontDir () const
virtual QFontEngine * fontEngine (const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference)
virtual QFontEngine * fontEngine (const QFontDef &fontDef, void *handle)
virtual QFontEngineMulti * fontEngineMulti (QFontEngine *fontEngine, QChar::Script script)
virtual bool fontsAlwaysScalable () const
virtual void invalidate ()
virtual bool isPrivateFontFamily (const QString &family) const
virtual void populateFamily (const QString &familyName)
virtual void populateFontDatabase ()
virtual void releaseHandle (void *handle)
virtual QString resolveFontFamilyAlias (const QString &family) const
virtual QList< int > standardSizes () const
QFontEngine::SubpixelAntialiasingType subpixelAntialiasingTypeHint () const

Static Public Methods

static void registerAliasToFontFamily (const QString &familyName, const QString &alias)
static void registerFont (const QString &familyName, const QString &styleName, const QString &foundryName, QFont::Weight weight, QFont::Style style, QFont::Stretch stretch, bool antialiased, bool scalable, int pixelSize, bool fixedPitch, const QSupportedWritingSystems &writingSystems, void *handle)
static void registerFontFamily (const QString &familyName)
static void registerQPF2Font (const QByteArray &dataArray, void *handle)
static QFont::Weight weightFromInteger (int weight)
static QSupportedWritingSystems writingSystemsFromTrueTypeBits (quint32 unicodeRange[4], quint32 codePageRange[2])

Related Functions

These are not member functions

QString qt_resolveFontFamilyAlias (const QString &alias)

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.

CopperSpice 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.

See also

Method Documentation

QStringList QPlatformFontDatabase::addApplicationFont ( const QByteArray fontData,
const QString fileName 

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.

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.
QFont QPlatformFontDatabase::defaultFont ( ) const

Returns the default system font.

See also
QStringList QPlatformFontDatabase::fallbacksForFamily ( const QString family,
QFont::Style  style,
QFont::StyleHint  styleHint,
QChar::Script  script 
) const

Returns a list of alternative fonts for the specified family and style and script using the given styleHint.

Default implementation returns a list of fonts for which style and script support has been reported during the font database population.

QString QPlatformFontDatabase::fontDir ( ) const

Returns the directory containing the fonts used by the database.

QFontEngine * QPlatformFontDatabase::fontEngine ( const QByteArray fontData,
qreal  pixelSize,
QFont::HintingPreference  hintingPreference 

Returns the font engine that can be used to render the font described by the font definition, fontDef based on handle.

QFontEngine * QPlatformFontDatabase::fontEngine ( const QFontDef &  fontDef,
void *  handle 

Returns the font engine that can be used to render the font described by the font definition, fontDef based on handle.

QFontEngineMulti * QPlatformFontDatabase::fontEngineMulti ( QFontEngine *  fontEngine,
QChar::Script  script 

Returns a multi font engine in the specified script to encapsulate fontEngine with the option to fall back to the fonts given by fallbacks if fontEngine does not support a certain character.

bool QPlatformFontDatabase::fontsAlwaysScalable ( ) const

Return true if all fonts are considered scalable when using this font database. Defaults to false.

void QPlatformFontDatabase::invalidate ( )

This function is called whenever the font database is invalidated.

Reimplement this function to clear any internal data structures that will need to be rebuilt at the next call to populateFontDatabase().

bool QPlatformFontDatabase::isPrivateFontFamily ( const QString family) const

Returns true if the font family is private. For any given family name, the result is platform dependent.

void QPlatformFontDatabase::populateFamily ( const QString familyName)

This method is called whenever a lazily populated family, populated through registerFontFamily(), needs full population.

You are expected to fully populate the family by calling registerFont() for each font that matches the family name.

void QPlatformFontDatabase::populateFontDatabase ( )

This method is called once at startup by the CopperSpice internal font database. Reimplement this function in a subclass for a convenient place to initialize the internal font database.

You may lazily populate the database by calling registerFontFamily() instead of registerFont(), in which case you will get a callback to populateFamily() when the required family needs population. You then call registerFont() to finish population of the family.

The default implementation looks in the fontDir() location and registers all qpf2 fonts.

void QPlatformFontDatabase::registerAliasToFontFamily ( const QString familyName,
const QString alias 

Helper function that register the alias for the familyName.

void QPlatformFontDatabase::registerFont ( const QString familyName,
const QString styleName,
const QString foundryName,
QFont::Weight  weight,
QFont::Style  style,
QFont::Stretch  stretch,
bool  antialiased,
bool  scalable,
int  pixelSize,
bool  fixedPitch,
const QSupportedWritingSystems writingSystems,
void *  handle 

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. The handle argument is passed to the underlying implementation.

See also
registerQPF2Font(), registerFontFamily()
void QPlatformFontDatabase::registerFontFamily ( const QString familyName)

Registers a font family with the font database. The font will be lazily populated by a callback to populateFamily() when the font database determines that the family needs population.

See also
populateFamily(), registerFont()
void QPlatformFontDatabase::registerQPF2Font ( const QByteArray dataArray,
void *  handle 

Registers the pre-rendered QPF2 font contained in the given dataArray, passing the given handle.

See also
void QPlatformFontDatabase::releaseHandle ( void *  handle)

Releases the specified font handle.

QString QPlatformFontDatabase::resolveFontFamilyAlias ( const QString family) const

Additional documentation pending.

QList< int > QPlatformFontDatabase::standardSizes ( ) const

Return list of standard font sizes when using this font database.

QFontEngine::SubpixelAntialiasingType QPlatformFontDatabase::subpixelAntialiasingTypeHint ( ) const

Additional documentation pending.

QFont::Weight QPlatformFontDatabase::weightFromInteger ( int  weight)

Helper methods which returns the font weight matching a given opentype integer value.

QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits ( quint32  unicodeRange[4],
quint32  codePageRange[2] 

Helper function that determines the writing systems support by a given unicodeRange and codePageRange.

Friends And Related Function Documentation

QString qt_resolveFontFamilyAlias ( const QString alias)

Resolve alias to actual font family names.