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
qfontdatabase.cpp File Reference

(cba15d99f0cfd59ccc962f1d40168c4dca17776e)

#include "qfontdatabase.h"
#include "qfontdatabase_p.h"
#include "qloggingcategory.h"
#include "qalgorithms.h"
#include "qguiapplication.h"
#include "qvarlengtharray.h"
#include "qthread.h"
#include "qmutex.h"
#include "qfile.h"
#include "qfileinfo.h"
#include "qfontengine_p.h"
#include <qpa/qplatformintegration.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformfontdatabase.h>
#include <qpa/qplatformtheme.h>
#include <QtCore/qcache.h>
#include <QtCore/qmath.h>
#include <stdlib.h>
#include <algorithm>
#include <qtgui_tracepoints_p.h>
#include "moc_qfontdatabase.cpp"
+ Include dependency graph for qfontdatabase.cpp:

Go to the source code of this file.

Classes

struct  QtFontDesc
 

Macros

#define SMOOTH_SCALABLE   0xffff
 

Functions

 Q_TRACE_POINT (qtgui, QFontDatabase_loadEngine, const QString &families, int pointSize)
 
 Q_TRACE_POINT (qtgui, QFontDatabasePrivate_addAppFont, const QString &fileName)
 
 Q_TRACE_POINT (qtgui, QFontDatabase_addApplicationFont, const QString &fileName)
 
 Q_TRACE_POINT (qtgui, QFontDatabase_load, const QString &family, int pointSize)
 
static int getFontWeight (const QString &weightString)
 
static bool equalsCaseInsensitive (const QString &a, const QString &b)
 
Q_GUI_EXPORT int qt_script_for_writing_system (QFontDatabase::WritingSystem writingSystem)
 
static bool familySupportsWritingSystem (QtFontFamily *family, size_t writingSystem)
 
Q_GUI_EXPORT QFontDatabase::WritingSystem qt_writing_system_for_script (int script)
 
static void parseFontName (const QString &name, QString &foundry, QString &family)
 
static void initFontDef (const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi)
 
static QStringList familyList (const QFontDef &req)
 
void qt_cleanupFontDatabase ()
 
QRecursiveMutexqt_fontdatabase_mutex ()
 
void qt_registerFont (const QString &familyName, const QString &stylename, const QString &foundryname, int weight, QFont::Style style, int stretch, bool antialiased, bool scalable, int pixelSize, bool fixedPitch, const QSupportedWritingSystems &writingSystems, void *handle)
 
void qt_registerFontFamily (const QString &familyName)
 
void qt_registerAliasToFontFamily (const QString &familyName, const QString &alias)
 
QString qt_resolveFontFamilyAlias (const QString &alias)
 
bool qt_isFontFamilyPopulated (const QString &familyName)
 
static QStringList fallbacksForFamily (const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)
 
QStringList qt_fallbacksForFamily (const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)
 
static QtFontStylebestStyle (QtFontFoundry *foundry, const QtFontStyle::Key &styleKey, const QString &styleName=QString())
 
static bool matchFamilyName (const QString &familyName, QtFontFamily *f)
 
static QString styleStringHelper (int weight, QFont::Style style)
 
Q_GUI_EXPORT QByteArray qt_fontdata_from_index (int index)
 
Q_GUI_EXPORT QStringList qt_sort_families_by_writing_system (QChar::Script script, const QStringList &families)
 

Variables

static const int scriptForWritingSystem []
 

Macro Definition Documentation

◆ SMOOTH_SCALABLE

Function Documentation

◆ bestStyle()

static QtFontStyle * bestStyle ( QtFontFoundry * foundry,
const QtFontStyle::Key & styleKey,
const QString & styleName = QString() )
static

Definition at line 828 of file qfontdatabase.cpp.

References QtFontFoundry::count, d, dist(), i, QString::isEmpty(), QtFontStyle::key, qAbs(), qCDebug, QtFontStyle::Key::stretch, QtFontStyle::Key::style, QtFontStyle::styleName, QFont::StyleNormal, QtFontFoundry::styles, and QtFontStyle::Key::weight.

Referenced by QFontDatabase::font().

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

◆ equalsCaseInsensitive()

static bool equalsCaseInsensitive ( const QString & a,
const QString & b )
inlinestatic

Definition at line 252 of file qfontdatabase.cpp.

References Qt::CaseInsensitive.

Referenced by QtFontFamily::matchesFamilyName().

+ Here is the caller graph for this function:

◆ fallbacksForFamily()

static QStringList fallbacksForFamily ( const QString & family,
QFont::Style style,
QFont::StyleHint styleHint,
QChar::Script script )
static

Definition at line 662 of file qfontdatabase.cpp.

References cacheKey(), contains(), db, QFontDatabasePrivate::ensureFontDatabase(), i, j, and QGuiApplicationPrivate::platformIntegration().

Referenced by QCoreTextFontDatabase::fallbacksForFamily(), QFontDatabasePrivate::findFont(), and qt_fallbacksForFamily().

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

◆ familyList()

static QStringList familyList ( const QFontDef & req)
static

Definition at line 502 of file qfontdatabase.cpp.

References QFontDef::families, i, and QFont::substitutes().

Referenced by QFontDatabasePrivate::load(), and splitIntoFamilies().

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

◆ familySupportsWritingSystem()

static bool familySupportsWritingSystem ( QtFontFamily * family,
size_t writingSystem )
static

Tests if the given family family supports writing system writingSystem, including the special case for Han script mapping to several subsequent writing systems

Definition at line 400 of file qfontdatabase.cpp.

References QFontDatabase::Any, QFontDatabase::Japanese, Q_ASSERT, QFontDatabase::SimplifiedChinese, QtFontFamily::Supported, QtFontFamily::writingSystems, and QFontDatabase::WritingSystemsCount.

Referenced by QPlatformFontDatabase::fallbacksForFamily(), and qt_sort_families_by_writing_system().

+ Here is the caller graph for this function:

◆ getFontWeight()

static int getFontWeight ( const QString & weightString)
static

Definition at line 56 of file qfontdatabase.cpp.

References QFont::Black, QFont::Bold, Qt::CaseInsensitive, contains(), QFont::DemiBold, QFont::ExtraBold, QFont::ExtraLight, QFont::Light, QFont::Medium, QStringView::mid(), QFont::Normal, s2, QFont::Thin, QString::toLower(), and QCoreApplication::translate().

Referenced by QtFontStyle::Key::Key().

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

◆ initFontDef()

static void initFontDef ( const QtFontDesc & desc,
const QFontDef & request,
QFontDef * fontDef,
bool multi )
static

Definition at line 474 of file qfontdatabase.cpp.

References QFontDef::families, QFontDef::fixedPitch, QFontDef::ignorePitch, QFontDef::pixelSize, QGuiApplicationPrivate::platformIntegration(), QFontDef::pointSize, QFont::PreferMatch, request, QFontDef::style, QFontDef::styleHint, QFontDef::styleStrategy, and QFontDef::weight.

Referenced by QFontDatabasePrivate::findFont().

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

◆ matchFamilyName()

static bool matchFamilyName ( const QString & familyName,
QtFontFamily * f )
static

Definition at line 1002 of file qfontdatabase.cpp.

References QString::isEmpty().

Referenced by qt_sort_families_by_writing_system().

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

◆ parseFontName()

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

This makes sense of the font family name:

if the family name contains a '[' and a ']', then we take the text between the square brackets as the foundry, and the text before the square brackets as the family (ie. "Arial [Monotype]")

Definition at line 430 of file qfontdatabase.cpp.

References QString::clear(), QString::data(), i, QString::left(), QString::mid(), and QString::size().

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

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

◆ Q_TRACE_POINT() [1/4]

Q_TRACE_POINT ( qtgui ,
QFontDatabase_addApplicationFont ,
const QString & fileName )

◆ Q_TRACE_POINT() [2/4]

Q_TRACE_POINT ( qtgui ,
QFontDatabase_load ,
const QString & family,
int pointSize )

◆ Q_TRACE_POINT() [3/4]

Q_TRACE_POINT ( qtgui ,
QFontDatabase_loadEngine ,
const QString & families,
int pointSize )

◆ Q_TRACE_POINT() [4/4]

Q_TRACE_POINT ( qtgui ,
QFontDatabasePrivate_addAppFont ,
const QString & fileName )

◆ qt_cleanupFontDatabase()

void qt_cleanupFontDatabase ( )

Definition at line 518 of file qfontdatabase.cpp.

References db, and QFontDatabasePrivate::instance().

Referenced by QGuiApplicationPrivate::~QGuiApplicationPrivate().

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

◆ qt_fallbacksForFamily()

QStringList qt_fallbacksForFamily ( const QString & family,
QFont::Style style,
QFont::StyleHint styleHint,
QChar::Script script )

Definition at line 696 of file qfontdatabase.cpp.

References fallbacksForFamily().

Referenced by QFont::defaultFamily(), and QFontEngineMulti::ensureFallbackFamiliesQueried().

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

◆ qt_fontdata_from_index()

Q_GUI_EXPORT QByteArray qt_fontdata_from_index ( int index)

Definition at line 2153 of file qfontdatabase.cpp.

References QFontDatabasePrivate::instance().

Referenced by QFreetypeFace::getFace().

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

◆ qt_fontdatabase_mutex()

QRecursiveMutex * qt_fontdatabase_mutex ( )

Definition at line 526 of file qfontdatabase.cpp.

Referenced by QFontPrivate::engineForScript().

+ Here is the caller graph for this function:

◆ qt_isFontFamilyPopulated()

bool qt_isFontFamilyPopulated ( const QString & familyName)

Definition at line 609 of file qfontdatabase.cpp.

References d, QFontDatabasePrivate::instance(), QtFontFamily::populated, and QFontDatabasePrivate::RequestFamily.

Referenced by QPlatformFontDatabase::isFamilyPopulated().

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

◆ qt_registerAliasToFontFamily()

void qt_registerAliasToFontFamily ( const QString & familyName,
const QString & alias )

Definition at line 580 of file qfontdatabase.cpp.

References QtFontFamily::aliases, Qt::CaseInsensitive, d, QFontDatabasePrivate::instance(), QString::isEmpty(), qCDebug, and QFontDatabasePrivate::RequestFamily.

Referenced by QPlatformFontDatabase::registerAliasToFontFamily().

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

◆ qt_registerFont()

void qt_registerFont ( const QString & familyName,
const QString & stylename,
const QString & foundryname,
int weight,
QFont::Style style,
int stretch,
bool antialiased,
bool scalable,
int pixelSize,
bool fixedPitch,
const QSupportedWritingSystems & writingSystems,
void * handle )

Definition at line 537 of file qfontdatabase.cpp.

References QtFontStyle::antialiased, d, QFontDatabasePrivate::EnsureCreated, QtFontFamily::fixedPitch, QPlatformIntegration::fontDatabase(), i, QFontDatabasePrivate::instance(), QtFontSize::pixelSize, QtFontStyle::pixelSize(), QGuiApplicationPrivate::platformIntegration(), qCDebug, SMOOTH_SCALABLE, QtFontStyle::smoothScalable, QtFontStyle::Key::style, QtFontFoundry::style(), QtFontFamily::Supported, QSupportedWritingSystems::supported(), and QFontDatabase::WritingSystemsCount.

Referenced by QPlatformFontDatabase::registerFont().

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

◆ qt_registerFontFamily()

void qt_registerFontFamily ( const QString & familyName)

Definition at line 572 of file qfontdatabase.cpp.

References QFontDatabasePrivate::EnsureCreated, QFontDatabasePrivate::instance(), and qCDebug.

Referenced by QPlatformFontDatabase::registerFontFamily().

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

◆ qt_resolveFontFamilyAlias()

QString qt_resolveFontFamilyAlias ( const QString & alias)

Definition at line 598 of file qfontdatabase.cpp.

References d, i, QFontDatabasePrivate::instance(), and QString::isEmpty().

Referenced by QPlatformFontDatabase::resolveFontFamilyAlias().

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

◆ qt_script_for_writing_system()

Q_GUI_EXPORT int qt_script_for_writing_system ( QFontDatabase::WritingSystem writingSystem)

Definition at line 388 of file qfontdatabase.cpp.

References scriptForWritingSystem.

Referenced by QRawFont::fromFont().

+ Here is the caller graph for this function:

◆ qt_sort_families_by_writing_system()

Q_GUI_EXPORT QStringList qt_sort_families_by_writing_system ( QChar::Script script,
const QStringList & families )

Definition at line 2716 of file qfontdatabase.cpp.

References QFontDatabase::Any, db, familySupportsWritingSystem(), i, QFontDatabasePrivate::instance(), matchFamilyName(), Q_UNLIKELY, qt_writing_system_for_script(), and QFontDatabase::WritingSystemsCount.

Referenced by QCoreTextFontDatabase::fallbacksForFamily().

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

◆ qt_writing_system_for_script()

Q_GUI_EXPORT QFontDatabase::WritingSystem qt_writing_system_for_script ( int script)

Definition at line 414 of file qfontdatabase.cpp.

References scriptForWritingSystem, and QFontDatabase::WritingSystemsCount.

Referenced by QPlatformFontDatabase::fallbacksForFamily(), and qt_sort_families_by_writing_system().

+ Here is the caller graph for this function:

◆ styleStringHelper()

static QString styleStringHelper ( int weight,
QFont::Style style )
static

Definition at line 1100 of file qfontdatabase.cpp.

References QFont::Black, QFont::Bold, QFont::DemiBold, QFont::ExtraBold, QFont::ExtraLight, QFont::Light, QFont::Medium, QFont::Normal, QFont::StyleItalic, QFont::StyleOblique, QFont::Thin, and QCoreApplication::translate().

Referenced by QFontDatabase::isSmoothlyScalable(), QFontDatabase::styles(), QFontDatabase::styleString(), and QFontDatabase::styleString().

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

Variable Documentation

◆ scriptForWritingSystem

const int scriptForWritingSystem[]
static