![]() |
Qt 6.x
The Qt SDK
|
#include <qfontdatabase_p.h>
Classes | |
struct | ApplicationFont |
Public Types | |
enum | FamilyRequestFlags { RequestFamily = 0 , EnsureCreated , EnsurePopulated } |
Public Member Functions | |
QFontDatabasePrivate () | |
~QFontDatabasePrivate () | |
void | clearFamilies () |
QtFontFamily * | family (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 QFontDatabasePrivate * | instance () |
static void | parseFontName (const QString &name, QString &foundry, QString &family) |
static QString | resolveFontFamilyAlias (const QString &family) |
static QFontEngine * | findFont (const QFontDef &request, int script, bool preferScriptOverFamily=false) |
static void | load (const QFontPrivate *d, int script) |
static QFontDatabasePrivate * | ensureFontDatabase () |
Public Attributes | |
int | count |
QtFontFamily ** | families |
bool | populated = false |
QCache< QtFontFallbacksCacheKey, QStringList > | fallbacksCache |
QList< ApplicationFont > | applicationFonts |
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:
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().
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.
Enumerator | |
---|---|
RequestFamily | |
EnsureCreated | |
EnsurePopulated |
Definition at line 195 of file qfontdatabase_p.h.
|
inline |
Definition at line 183 of file qfontdatabase_p.h.
|
inline |
Definition at line 189 of file qfontdatabase_p.h.
int QFontDatabasePrivate::addAppFont | ( | const QByteArray & | fontData, |
const QString & | fileName | ||
) |
Definition at line 2158 of file qfontdatabase.cpp.
References QPlatformFontDatabase::addApplicationFont(), QFontCache::clear(), emit, fileName, font, QPlatformIntegration::fontDatabase(), i, QFontCache::instance(), QString::number(), QGuiApplicationPrivate::platformIntegration(), Q_TRACE, and qApp.
Referenced by QFontDatabase::addApplicationFont(), and QFontDatabase::addApplicationFontFromData().
void QFontDatabasePrivate::clearFamilies | ( | ) |
Definition at line 271 of file qfontdatabase.cpp.
References QtFontStyle::count, and font.
|
static |
Initializes the font database if necessary and returns its pointer. Mutex lock must be held when calling this function.
Definition at line 1323 of file qfontdatabase.cpp.
References d, font, QPlatformIntegration::fontDatabase(), i, instance(), QGuiApplicationPrivate::platformIntegration(), QPlatformFontDatabase::populateFontDatabase(), 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().
QtFontFamily * QFontDatabasePrivate::family | ( | const QString & | f, |
FamilyRequestFlags | flags = EnsurePopulated |
||
) |
Definition at line 298 of file qfontdatabase.cpp.
References Qt::CaseInsensitive, QtFontStyle::count, QtFontFamily::ensurePopulated(), pos, and Q_CHECK_PTR().
Referenced by qt_registerFontFamily().
|
static |
Definition at line 2365 of file qfontdatabase.cpp.
References QFont::AnyStyle, QList< T >::append(), desc, engine, fallbacksForFamily(), QFontDef::families, QFontCache::findEngine(), QPlatformIntegration::fontDatabase(), i, initFontDef(), QFontCache::instance(), QString::isEmpty(), QtFontStyle::key, match(), QFont::NoFontMerging, parseFontName(), QGuiApplicationPrivate::platformIntegration(), QPlatformFontDatabase::populateFamilyAliases(), qCDebug, request, QChar::Script_Common, and QFont::TypeWriter.
Referenced by QRawFont::fromFont(), load(), and QFontEngineMulti::loadEngine().
|
static |
Definition at line 531 of file qfontdatabase.cpp.
Referenced by QFontDatabase::addApplicationFont(), QFontDatabase::addApplicationFontFromData(), QFontDatabase::applicationFontFamilies(), ensureFontDatabase(), QPlatformFontDatabase::fallbacksForFamily(), qt_cleanupFontDatabase(), qt_fontdata_from_index(), qt_isFontFamilyPopulated(), qt_registerAliasToFontFamily(), qt_registerFont(), qt_registerFontFamily(), qt_resolveFontFamilyAlias(), qt_sort_families_by_writing_system(), QFontDatabase::removeAllApplicationFonts(), QFontDatabase::removeApplicationFont(), and QPlatformFontDatabase::repopulateFontDatabase().
void QFontDatabasePrivate::invalidate | ( | ) |
Definition at line 286 of file qfontdatabase.cpp.
References QFontCache::clear(), emit, QPlatformIntegration::fontDatabase(), QFontCache::instance(), QPlatformFontDatabase::invalidate(), QGuiApplicationPrivate::platformIntegration(), qCDebug, and qGuiApp.
Referenced by QPlatformFontDatabase::repopulateFontDatabase().
bool QFontDatabasePrivate::isApplicationFont | ( | const QString & | fileName | ) |
Definition at line 2194 of file qfontdatabase.cpp.
|
static |
Definition at line 2493 of file qfontdatabase.cpp.
References QFontEngine::Box, d, QFontDef::fallBackFamilies, QFont::families(), QFontDef::families, familyList(), QFontCache::findEngineData(), findFont(), QString::first(), QGuiApplication::font(), QFontEngine::fontDef, i, QFontCache::insertEngineData(), QFontCache::instance(), it, QBasicAtomicInteger< T >::loadRelaxed(), QFont::NoFontMerging, QFontDef::pixelSize, QFontDef::pointSize, Q_ASSERT, Q_TRACE, qRound(), QBasicAtomicInteger< T >::ref(), QFontEngine::ref, QChar::ScriptCount, QFontEngine::symbol, and QFontEngine::type().
Referenced by QFontPrivate::engineForScript().
|
static |
Definition at line 2146 of file qfontdatabase.cpp.
References parseFontName(), and QT_PREPEND_NAMESPACE().
Referenced by QFontDef::exactMatch(), findFamilyInModel(), and QFontDialogPrivate::updateFamilies().
Definition at line 2590 of file qfontdatabase.cpp.
References QPlatformIntegration::fontDatabase(), QGuiApplicationPrivate::platformIntegration(), and QPlatformFontDatabase::resolveFontFamilyAlias().
Referenced by QFontDatabase::hasFamily().
QList<ApplicationFont> QFontDatabasePrivate::applicationFonts |
Definition at line 229 of file qfontdatabase_p.h.
Referenced by qt_fontdata_from_index().
int QFontDatabasePrivate::count |
Definition at line 203 of file qfontdatabase_p.h.
QCache<QtFontFallbacksCacheKey, QStringList> QFontDatabasePrivate::fallbacksCache |
Definition at line 207 of file qfontdatabase_p.h.
QtFontFamily** QFontDatabasePrivate::families |
Definition at line 204 of file qfontdatabase_p.h.
bool QFontDatabasePrivate::populated = false |
Definition at line 205 of file qfontdatabase_p.h.