Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qfont.cpp File Reference
#include "qfont.h"
#include "qdebug.h"
#include "qpaintdevice.h"
#include "qfontdatabase.h"
#include "qfontmetrics.h"
#include "qfontinfo.h"
#include "qpainter.h"
#include "qhash.h"
#include "qdatastream.h"
#include "qguiapplication.h"
#include "qstringlist.h"
#include "qscreen.h"
#include "qthread.h"
#include "qthreadstorage.h"
#include "qfont_p.h"
#include <private/qfontengine_p.h>
#include <private/qpainter_p.h>
#include <private/qtextengine_p.h>
#include <limits.h>
#include <qpa/qplatformscreen.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformfontdatabase.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtCore/QMutexLocker>
#include <QtCore/QMutex>
#include <array>
#include "moc_qfont.cpp"
+ Include dependency graph for qfont.cpp:

Go to the source code of this file.

Macros

#define FC_DEBUG   if (false) qDebug
 
#define QFONTCACHE_DECREASE_TRIGGER_LIMIT   256
 
#define QT_FONT_ENGINE_FROM_DATA(data, script)   data->engines[script]
 
#define QFONTCACHE_MIN_COST   4*1024
 
#define QFONT_DEBUG_SKIP_DEFAULT(prop)
 

Typedefs

typedef QHash< QString, QStringListQFontSubst
 

Functions

Q_GUI_EXPORT int qt_defaultDpiX ()
 
Q_GUI_EXPORT int qt_defaultDpiY ()
 
Q_GUI_EXPORT int qt_defaultDpi ()
 
static int convertWeights (int weight, bool inverted)
 
static QStringList splitIntoFamilies (const QString &family)
 
Q_GUI_EXPORT int qt_legacyToOpenTypeWeight (int weight)
 
Q_GUI_EXPORT int qt_openTypeToLegacyWeight (int weight)
 
QRecursiveMutexqt_fontdatabase_mutex ()
 
static quint8 get_font_bits (int version, const QFontPrivate *f)
 
static quint8 get_extended_font_bits (const QFontPrivate *f)
 
static void set_font_bits (int version, quint8 bits, QFontPrivate *f)
 
static void set_extended_font_bits (quint8 bits, QFontPrivate *f)
 
QStringList qt_fallbacksForFamily (const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script)
 
QDebug operator<< (QDebug stream, const QFont &font)
 

Variables

bool qt_is_tty_app
 
static constexpr auto fast_timeout = 10s
 
static constexpr auto slow_timeout = 5min
 
static Q_CONSTINIT QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(0)
 

Macro Definition Documentation

◆ FC_DEBUG

#define FC_DEBUG   if (false) qDebug

Definition at line 40 of file qfont.cpp.

◆ QFONT_DEBUG_SKIP_DEFAULT

#define QFONT_DEBUG_SKIP_DEFAULT (   prop)
Value:
if ((font.prop() == defaultFont.prop()) && stream.verbosity() == 1) \
continue;
EGLStreamKHR stream

◆ QFONTCACHE_DECREASE_TRIGGER_LIMIT

#define QFONTCACHE_DECREASE_TRIGGER_LIMIT   256

Definition at line 46 of file qfont.cpp.

◆ QFONTCACHE_MIN_COST

#define QFONTCACHE_MIN_COST   4*1024

Definition at line 3047 of file qfont.cpp.

◆ QT_FONT_ENGINE_FROM_DATA

#define QT_FONT_ENGINE_FROM_DATA (   data,
  script 
)    data->engines[script]

Definition at line 236 of file qfont.cpp.

Typedef Documentation

◆ QFontSubst

Definition at line 1884 of file qfont.cpp.

Function Documentation

◆ convertWeights()

static int convertWeights ( int  weight,
bool  inverted 
)
static

Definition at line 143 of file qfont.cpp.

References QFont::Black, QFont::Bold, QFont::DemiBold, dist(), QFont::ExtraBold, QFont::ExtraLight, QFont::Light, QFont::Medium, QFont::Normal, qAbs(), and QFont::Thin.

Referenced by qt_legacyToOpenTypeWeight(), and qt_openTypeToLegacyWeight().

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

◆ get_extended_font_bits()

static quint8 get_extended_font_bits ( const QFontPrivate f)
static

Definition at line 2029 of file qfont.cpp.

References Q_ASSERT.

◆ get_font_bits()

static quint8 get_font_bits ( int  version,
const QFontPrivate f 
)
static

Definition at line 2004 of file qfont.cpp.

References Q_ASSERT, QDataStream::Qt_4_0, and QFont::StyleOblique.

◆ operator<<()

QDebug operator<< ( QDebug  stream,
const QFont font 
)

Definition at line 3446 of file qfont.cpp.

References other(), QFontDef::pixelSize, QFontDef::pointSize, and QFontPrivate::request.

+ Here is the call graph for this function:

◆ qt_defaultDpi()

Q_GUI_EXPORT int qt_defaultDpi ( )

◆ qt_defaultDpiX()

Q_GUI_EXPORT int qt_defaultDpiX ( )

Definition at line 107 of file qfont.cpp.

References Qt::AA_Use96Dpi, QCoreApplication::instance(), QScreen::logicalDotsPerInchX, QGuiApplication::primaryScreen, qRound(), qt_is_tty_app, and screen.

Referenced by QFakeDevice::QFakeDevice(), QStyleHelper::dpi(), QAlphaPaintEngine::flushAndInit(), QPicture::metric(), QBlittablePlatformPixmap::metric(), QRasterPlatformPixmap::metric(), QOpenGLWidget::metric(), QTextDocument::print(), and QQuickLayoutStyleInfo::spacing().

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

◆ qt_defaultDpiY()

Q_GUI_EXPORT int qt_defaultDpiY ( )

Definition at line 122 of file qfont.cpp.

References Qt::AA_Use96Dpi, QCoreApplication::instance(), QScreen::logicalDotsPerInchY, QGuiApplication::primaryScreen, qRound(), qt_is_tty_app, and screen.

Referenced by QFakeDevice::QFakeDevice(), QTextEngine::calculateTabWidth(), QAlphaPaintEngine::flushAndInit(), QPicture::metric(), QBlittablePlatformPixmap::metric(), QRasterPlatformPixmap::metric(), QOpenGLWidget::metric(), QFontDatabase::pointSizes(), QTextDocument::print(), qt_defaultDpi(), and QFontDatabase::smoothSizes().

+ 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 695 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_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_legacyToOpenTypeWeight()

Q_GUI_EXPORT int qt_legacyToOpenTypeWeight ( int  weight)

Definition at line 192 of file qfont.cpp.

References convertWeights().

Referenced by QFont::fromString().

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

◆ qt_openTypeToLegacyWeight()

Q_GUI_EXPORT int qt_openTypeToLegacyWeight ( int  weight)

Definition at line 198 of file qfont.cpp.

References convertWeights().

+ Here is the call graph for this function:

◆ set_extended_font_bits()

static void set_extended_font_bits ( quint8  bits,
QFontPrivate f 
)
static

Definition at line 2059 of file qfont.cpp.

References Q_ASSERT.

◆ set_font_bits()

static void set_font_bits ( int  version,
quint8  bits,
QFontPrivate f 
)
static

◆ splitIntoFamilies()

static QStringList splitIntoFamilies ( const QString family)
static

Definition at line 172 of file qfont.cpp.

References QList< T >::at(), QString::endsWith(), familyList(), i, QString::isEmpty(), list, QString::mid(), QString::size(), QList< T >::size(), QString::split(), QString::startsWith(), and str.

Referenced by QFont::QFont().

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

Variable Documentation

◆ fast_timeout

constexpr auto fast_timeout = 10s
staticconstexpr

Definition at line 3042 of file qfont.cpp.

◆ font_cache_id

Q_CONSTINIT QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(0)
static

Definition at line 3072 of file qfont.cpp.

◆ qt_is_tty_app

bool qt_is_tty_app
extern

Definition at line 120 of file qguiapplication.cpp.

Referenced by qt_defaultDpiX(), and qt_defaultDpiY().

◆ slow_timeout

constexpr auto slow_timeout = 5min
staticconstexpr

Definition at line 3043 of file qfont.cpp.