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/qfont_p.h>
24#include <QtGui/private/qfontdatabase_p.h>
25
26QT_BEGIN_NAMESPACE
27
28Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaFonts, Q_GUI_EXPORT)
29
30class QWritingSystemsPrivate;
31
32class Q_GUI_EXPORT QSupportedWritingSystems
33{
34public:
35
36 QSupportedWritingSystems();
37 QSupportedWritingSystems(const QSupportedWritingSystems &other);
38 QSupportedWritingSystems &operator=(const QSupportedWritingSystems &other);
39 ~QSupportedWritingSystems();
40
41 void setSupported(QFontDatabase::WritingSystem, bool supported = true);
42 bool supported(QFontDatabase::WritingSystem) const;
43
44private:
45 void detach();
46
47 QWritingSystemsPrivate *d;
48
49 friend Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
50 friend Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
51#ifndef QT_NO_DEBUG_STREAM
52 friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &);
53#endif
54};
55
56Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
57Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
58
59#ifndef QT_NO_DEBUG_STREAM
60Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &);
61#endif
62
63class QFontRequestPrivate;
64class QFontEngineMulti;
65
66class Q_GUI_EXPORT QPlatformFontDatabase
67{
68public:
69 virtual ~QPlatformFontDatabase();
70 virtual void populateFontDatabase();
71 virtual bool populateFamilyAliases(const QString &missingFamily) { Q_UNUSED(missingFamily); return false; }
72 virtual void populateFamily(const QString &familyName);
73 virtual void invalidate();
74
75 virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
76 virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *font = nullptr);
77
78 virtual QFontEngine *fontEngine(const QFontDef &fontDef, void *handle);
79 virtual QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
80 virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script);
81 virtual void releaseHandle(void *handle);
82
83 virtual QString fontDir() const;
84
85 virtual QFont defaultFont() const;
86 virtual bool isPrivateFontFamily(const QString &family) const;
87
88 virtual QString resolveFontFamilyAlias(const QString &family) const;
89 virtual bool fontsAlwaysScalable() const;
90 virtual QList<int> standardSizes() const;
91
92 // helper
93 static QSupportedWritingSystems writingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]);
94 static QSupportedWritingSystems writingSystemsFromOS2Table(const char *os2Table, size_t length);
95
96 //callback
97 static void registerFont(const QString &familyname, const QString &stylename,
98 const QString &foundryname, QFont::Weight weight,
99 QFont::Style style, QFont::Stretch stretch, bool antialiased,
100 bool scalable, int pixelSize, bool fixedPitch,
101 const QSupportedWritingSystems &writingSystems, void *handle);
102
103 static void registerFontFamily(const QString &familyName);
104 static void registerAliasToFontFamily(const QString &familyName, const QString &alias);
105
106 static void repopulateFontDatabase();
107
108 static bool isFamilyPopulated(const QString &familyName);
109};
110
111QT_END_NAMESPACE
112
113#endif // QPLATFORMFONTDATABASE_H
114

source code of qtbase/src/gui/text/qplatformfontdatabase.h