1 | // Copyright (C) 2020 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 QFREETYPEFONTDATABASE_H |
5 | #define QFREETYPEFONTDATABASE_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 <qpa/qplatformfontdatabase.h> |
19 | #include <QtCore/QByteArray> |
20 | #include <QtCore/QString> |
21 | #include <QtCore/private/qglobal_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | struct FontFile |
26 | { |
27 | QString fileName; |
28 | int indexValue; |
29 | int instanceIndex = -1; |
30 | |
31 | // Note: The data may be implicitly shared throughout the |
32 | // font database and platform font database, so be careful |
33 | // to never detach when accessing this member! |
34 | const QByteArray data; |
35 | }; |
36 | |
37 | class Q_GUI_EXPORT QFreeTypeFontDatabase : public QPlatformFontDatabase |
38 | { |
39 | public: |
40 | void populateFontDatabase() override; |
41 | QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; |
42 | QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override; |
43 | QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *applicationFont = nullptr) override; |
44 | void releaseHandle(void *handle) override; |
45 | bool supportsVariableApplicationFonts() const override; |
46 | |
47 | static void addNamedInstancesForFace(void *face, int faceIndex, |
48 | const QString &family, const QString &styleName, |
49 | QFont::Weight weight, QFont::Stretch stretch, |
50 | QFont::Style style, bool fixedPitch, |
51 | const QSupportedWritingSystems &writingSystems, |
52 | const QByteArray &fileName, const QByteArray &fontData); |
53 | |
54 | static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file, QFontDatabasePrivate::ApplicationFont *applicationFont = nullptr); |
55 | }; |
56 | |
57 | QT_END_NAMESPACE |
58 | |
59 | #endif // QFREETYPEFONTDATABASE_H |
60 | |