Coverage Report

Created: 2026-07-30 07:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/text/qplatformfontdatabase.h
Line
Count
Source
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 QPLATFORMFONTDATABASE_H
5
#define QPLATFORMFONTDATABASE_H
6
7
//
8
//  W A R N I N G
9
//  -------------
10
//
11
// This file is part of the QPA API and is not meant to be used
12
// in applications. Usage of this API may make your code
13
// source and binary incompatible with future versions of Qt.
14
//
15
16
#include <QtGui/qtguiglobal.h>
17
#include <QtCore/qloggingcategory.h>
18
#include <QtCore/QString>
19
#include <QtCore/QStringList>
20
#include <QtCore/QList>
21
#include <QtGui/QFontDatabase>
22
#include <QtGui/private/qfontengine_p.h>
23
#include <QtGui/private/qfontdatabase_p.h>
24
25
QT_BEGIN_NAMESPACE
26
27
QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(lcQpaFonts, Q_GUI_EXPORT)
28
29
class QWritingSystemsPrivate;
30
31
class Q_GUI_EXPORT QSupportedWritingSystems
32
{
33
public:
34
35
    QSupportedWritingSystems();
36
    QSupportedWritingSystems(const QSupportedWritingSystems &other);
37
    QSupportedWritingSystems &operator=(const QSupportedWritingSystems &other);
38
    ~QSupportedWritingSystems();
39
40
    void setSupported(QFontDatabase::WritingSystem, bool supported = true);
41
    bool supported(QFontDatabase::WritingSystem) const;
42
43
private:
44
    void detach();
45
46
    QWritingSystemsPrivate *d;
47
48
    friend Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
49
    friend Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
50
#ifndef QT_NO_DEBUG_STREAM
51
    friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &);
52
#endif
53
};
54
55
Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
56
Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
57
58
#ifndef QT_NO_DEBUG_STREAM
59
Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &);
60
#endif
61
62
class QFontRequestPrivate;
63
class QFontEngineMulti;
64
65
class Q_GUI_EXPORT QPlatformFontDatabase
66
{
67
public:
68
    virtual ~QPlatformFontDatabase();
69
    virtual void populateFontDatabase();
70
0
    virtual bool populateFamilyAliases(const QString &missingFamily) { Q_UNUSED(missingFamily); return false; }
71
    virtual void populateFamily(const QString &familyName);
72
    virtual void invalidate();
73
74
    virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QFontDatabasePrivate::ExtendedScript script) const;
75
    virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *font = nullptr);
76
77
    virtual QFontEngine *fontEngine(const QFontDef &fontDef, void *handle);
78
    virtual QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
79
    virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QFontDatabasePrivate::ExtendedScript script);
80
    virtual void releaseHandle(void *handle);
81
82
    virtual QString fontDir() const;
83
84
    virtual QFont defaultFont() const;
85
    virtual bool isPrivateFontFamily(const QString &family) const;
86
87
    virtual QString resolveFontFamilyAlias(const QString &family) const;
88
    virtual bool fontsAlwaysScalable() const;
89
    virtual QList<int> standardSizes() const;
90
91
    virtual bool supportsVariableApplicationFonts() const;
92
    virtual bool supportsColrv0Fonts() const;
93
94
    // helper
95
    static QSupportedWritingSystems writingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]);
96
    static QSupportedWritingSystems writingSystemsFromOS2Table(const char *os2Table, size_t length);
97
98
    //callback
99
    static void registerFont(const QString &familyname, const QString &stylename,
100
                             const QString &foundryname, QFont::Weight weight,
101
                             QFont::Style style, QFont::Stretch stretch, bool antialiased,
102
                             bool scalable, int pixelSize, bool fixedPitch, bool colorFont,
103
                             const QSupportedWritingSystems &writingSystems, void *handle);
104
105
    static void registerFontFamily(const QString &familyName);
106
    static void registerAliasToFontFamily(const QString &familyName, const QString &alias);
107
108
    static void repopulateFontDatabase();
109
110
    static bool isFamilyPopulated(const QString &familyName);
111
};
112
113
QT_END_NAMESPACE
114
115
#endif // QPLATFORMFONTDATABASE_H