Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qcoretextfontdatabase_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCORETEXTFONTDATABASE_H
5#define QCORETEXTFONTDATABASE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qglobal.h>
19
20#include <qpa/qplatformfontdatabase.h>
21#include <qpa/qplatformtheme.h>
22#include <private/qcore_mac_p.h>
23
24Q_FORWARD_DECLARE_CF_TYPE(CTFontDescriptor);
26
27QT_DECL_METATYPE_EXTERN_TAGGED(QCFType<CGFontRef>, QCFType_CGFontRef, Q_GUI_EXPORT)
28QT_DECL_METATYPE_EXTERN_TAGGED(QCFType<CFURLRef>, QCFType_CFURLRef, Q_GUI_EXPORT)
29
31
33{
34public:
37 void populateFontDatabase() override;
38 bool populateFamilyAliases(const QString &missingFamily) override;
39 void populateFamily(const QString &familyName) override;
40 void invalidate() override;
41
42 QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const override;
44 void releaseHandle(void *handle) override;
45 bool isPrivateFontFamily(const QString &family) const override;
46 QFont defaultFont() const override;
47 bool fontsAlwaysScalable() const override;
48 QList<int> standardSizes() const override;
49
50 // For iOS and macOS platform themes
51 QFont *themeFont(QPlatformTheme::Font) const;
52
53private:
54 void populateThemeFonts();
55 void populateFromDescriptor(CTFontDescriptorRef font, const QString &familyName = QString(), QFontDatabasePrivate::ApplicationFont *applicationFont = nullptr);
56 static CFArrayRef fallbacksForFamily(const QString &family);
57
60 QHash<QChar::Script, QString> m_hardcodedFallbackFonts;
61 mutable QSet<QString> m_privateFamilies;
62
63 bool m_hasPopulatedAliases;
64
65#if defined(Q_OS_MACOS)
66 QMacNotificationObserver m_fontSetObserver;
67#endif
68};
69
70// Split out into separate template class so that the compiler doesn't have
71// to generate code for each override in QCoreTextFontDatabase for each T.
72
73template <class T>
75{
76public:
77 QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override;
78 QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override;
79};
80
82
83#endif // QCORETEXTFONTDATABASE_H
\inmodule QtCore
Definition qbytearray.h:57
Script
Definition qchar.h:144
QFontEngine * fontEngine(const QFontDef &fontDef, void *handle) override
Returns the font engine that can be used to render the font described by the font definition,...
\reentrant
Definition qfont.h:20
StyleHint
Style hints are used by the \l{QFont}{font matching} algorithm to find an appropriate default family ...
Definition qfont.h:23
HintingPreference
Definition qfont.h:52
Style
This enum describes the different styles of glyphs that are used to display text.
Definition qfont.h:73
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
The QPlatformFontDatabase class makes it possible to customize how fonts are discovered and how they ...
virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *font=nullptr)
Adds an application font described by the font contained supplied fontData or using the font containe...
virtual QFont defaultFont() const
Returns the default system font.
virtual bool populateFamilyAliases(const QString &missingFamily)
virtual QFontEngine * fontEngine(const QFontDef &fontDef, void *handle)
Returns the font engine that can be used to render the font described by the font definition,...
virtual bool fontsAlwaysScalable() const
Return true if all fonts are considered scalable when using this font database.
virtual void releaseHandle(void *handle)
Releases the specified font handle.
virtual QStringList 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 styleHint...
virtual void populateFamily(const QString &familyName)
This function is called whenever a lazily populated family, populated through registerFontFamily(),...
virtual bool isPrivateFontFamily(const QString &family) const
Returns true if the font family is private.
virtual void invalidate()
This function is called whenever the font database is invalidated.
virtual QList< int > standardSizes() const
Return list of standard font sizes when using this font database.
virtual void populateFontDatabase()
This function is called once at startup by Qt's internal font database.
Definition qset.h:18
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
Combined button and popup list for selecting options.
#define Q_FORWARD_DECLARE_CF_TYPE(type)
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
Definition qmetatype.h:1355
GLuint64 GLenum void * handle
GLenum GLsizeiptr const void * fontData
double qreal
Definition qtypes.h:92