Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QFontDatabasePrivate Class Reference

#include <qfontdatabase_p.h>

+ Collaboration diagram for QFontDatabasePrivate:

Classes

struct  ApplicationFont
 

Public Types

enum  FamilyRequestFlags { RequestFamily = 0 , EnsureCreated , EnsurePopulated }
 

Public Member Functions

 QFontDatabasePrivate ()
 
 ~QFontDatabasePrivate ()
 
void clearFamilies ()
 
QtFontFamilyfamily (const QString &f, FamilyRequestFlags flags=EnsurePopulated)
 
int addAppFont (const QByteArray &fontData, const QString &fileName)
 
bool isApplicationFont (const QString &fileName)
 
void invalidate ()
 

Static Public Member Functions

static QFontDatabasePrivateinstance ()
 
static void parseFontName (const QString &name, QString &foundry, QString &family)
 
static QString resolveFontFamilyAlias (const QString &family)
 
static QFontEnginefindFont (const QFontDef &request, int script, bool preferScriptOverFamily=false)
 
static void load (const QFontPrivate *d, int script)
 
static QFontDatabasePrivateensureFontDatabase ()
 

Public Attributes

int count
 
QtFontFamily ** families
 
bool populated = false
 
QHash< QChar::Script, QStringListapplicationFallbackFontFamilies
 
QCache< QtFontFallbacksCacheKey, QStringListfallbacksCache
 
QList< ApplicationFontapplicationFonts
 

Detailed Description

Singleton implementation of the public QFontDatabase APIs, accessed through QFontDatabasePrivate::instance().

The database is organized in multiple levels:

The font database is the single source of truth when doing font matching, so the database must be sufficiently filled before attempting a match.

The database is populated (filled) from two sources:

  1. The system (platform's) view of the available fonts

    Initiated via QFontDatabasePrivate::populateFontDatabase().

    a. Can be registered lazily by family only, by calling QPlatformFontDatabase::registerFontFamily(), and later populated via QPlatformFontDatabase::populateFamily().

    b. Or fully registered with all styles, by calling QPlatformFontDatabase::registerFont().

  2. The fonts registered by the application via Qt APIs

    Initiated via QFontDatabase::addApplicationFont() and QFontDatabase::addApplicationFontFromData().

    Application fonts are always fully registered when added.

Fonts can be added at any time, so the database may grow even after QFontDatabasePrivate::populateFontDatabase() has been completed.

The database does not support granular removal of fonts, so if the system fonts change, or an application font is removed, the font database will be cleared and then filled from scratch, via QFontDatabasePrivate:invalidate() and QFontDatabasePrivate::ensureFontDatabase().

Definition at line 180 of file qfontdatabase_p.h.

Member Enumeration Documentation

◆ FamilyRequestFlags

Enumerator
RequestFamily 
EnsureCreated 
EnsurePopulated 

Definition at line 195 of file qfontdatabase_p.h.

Constructor & Destructor Documentation

◆ QFontDatabasePrivate()

QFontDatabasePrivate::QFontDatabasePrivate ( )
inline

Definition at line 183 of file qfontdatabase_p.h.

◆ ~QFontDatabasePrivate()

QFontDatabasePrivate::~QFontDatabasePrivate ( )
inline

Definition at line 189 of file qfontdatabase_p.h.

Member Function Documentation

◆ addAppFont()

int QFontDatabasePrivate::addAppFont ( const QByteArray & fontData,
const QString & fileName )

Definition at line 2159 of file qfontdatabase.cpp.

References emit, fileName, font, i, QFontCache::instance(), QString::number(), QGuiApplicationPrivate::platformIntegration(), Q_TRACE, and qApp.

+ Here is the call graph for this function:

◆ clearFamilies()

void QFontDatabasePrivate::clearFamilies ( )

Definition at line 271 of file qfontdatabase.cpp.

References QtFontStyle::count, and font.

◆ ensureFontDatabase()

QFontDatabasePrivate * QFontDatabasePrivate::ensureFontDatabase ( )
static

Initializes the font database if necessary and returns its pointer. Mutex lock must be held when calling this function.

Definition at line 1324 of file qfontdatabase.cpp.

References d, font, i, instance(), QGuiApplicationPrivate::platformIntegration(), Q_UNLIKELY, qCDebug, qFatal, and qGuiApp.

Referenced by QFontDatabase::bold(), fallbacksForFamily(), QFontDatabase::families(), QFontDatabase::font(), QFontDatabase::hasFamily(), QFontDatabase::isBitmapScalable(), QFontDatabase::isFixedPitch(), QFontDatabase::isSmoothlyScalable(), QFontDatabase::italic(), QFontDatabase::pointSizes(), QFontDatabase::smoothSizes(), QFontDatabase::styles(), QFontDatabase::weight(), QFontDatabase::writingSystems(), and QFontDatabase::writingSystems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ family()

QtFontFamily * QFontDatabasePrivate::family ( const QString & f,
FamilyRequestFlags flags = EnsurePopulated )

Definition at line 298 of file qfontdatabase.cpp.

References Qt::CaseInsensitive, QtFontStyle::count, pos, and Q_CHECK_PTR().

+ Here is the call graph for this function:

◆ findFont()

QFontEngine * QFontDatabasePrivate::findFont ( const QFontDef & req,
int script,
bool preferScriptOverFamily = false )
static

Definition at line 2486 of file qfontdatabase.cpp.

References QFont::AnyStyle, engine, fallbacksForFamily(), QFontDef::families, QFontCache::findEngine(), i, initFontDef(), QFontCache::instance(), QtFontStyle::key, match(), QFont::NoFontMerging, parseFontName(), QGuiApplicationPrivate::platformIntegration(), qCDebug, request, and QFont::TypeWriter.

Referenced by QRawFont::fromFont(), load(), and QFontEngineMulti::loadEngine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instance()

◆ invalidate()

void QFontDatabasePrivate::invalidate ( )

Definition at line 286 of file qfontdatabase.cpp.

References emit, QFontCache::instance(), QGuiApplicationPrivate::platformIntegration(), qCDebug, and qGuiApp.

+ Here is the call graph for this function:

◆ isApplicationFont()

bool QFontDatabasePrivate::isApplicationFont ( const QString & fileName)

Definition at line 2195 of file qfontdatabase.cpp.

References fileName, and i.

◆ load()

void QFontDatabasePrivate::load ( const QFontPrivate * d,
int script )
static

Definition at line 2614 of file qfontdatabase.cpp.

References QFontEngine::Box, QSet< T >::constBegin(), d, QFontDef::fallBackFamilies, QFontDef::families, familyList(), QFontCache::findEngineData(), findFont(), QString::first(), QGuiApplication::font(), i, QFontCache::insertEngineData(), QFontCache::instance(), it, QFont::NoFontMerging, QFontDef::pixelSize, QFontDef::pointSize, Q_ASSERT, Q_TRACE, and qRound().

Referenced by QFontPrivate::engineForScript().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseFontName()

void QFontDatabasePrivate::parseFontName ( const QString & name,
QString & foundry,
QString & family )
static

Definition at line 2147 of file qfontdatabase.cpp.

References parseFontName().

Referenced by QFontDef::exactMatch(), findFamilyInModel(), and QFontDialogPrivate::updateFamilies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveFontFamilyAlias()

QString QFontDatabasePrivate::resolveFontFamilyAlias ( const QString & family)
static

Definition at line 2711 of file qfontdatabase.cpp.

References QGuiApplicationPrivate::platformIntegration().

Referenced by QFontDatabase::hasFamily().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ applicationFallbackFontFamilies

QHash<QChar::Script, QStringList> QFontDatabasePrivate::applicationFallbackFontFamilies

Definition at line 207 of file qfontdatabase_p.h.

◆ applicationFonts

QList<ApplicationFont> QFontDatabasePrivate::applicationFonts

Definition at line 231 of file qfontdatabase_p.h.

◆ count

int QFontDatabasePrivate::count

Definition at line 203 of file qfontdatabase_p.h.

◆ fallbacksCache

QCache<QtFontFallbacksCacheKey, QStringList> QFontDatabasePrivate::fallbacksCache

Definition at line 209 of file qfontdatabase_p.h.

◆ families

QtFontFamily** QFontDatabasePrivate::families

Definition at line 204 of file qfontdatabase_p.h.

◆ populated

bool QFontDatabasePrivate::populated = false

Definition at line 205 of file qfontdatabase_p.h.


The documentation for this class was generated from the following files: