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
23QT_BEGIN_NAMESPACE
24
25struct FontFile
26{
27 QString fileName;
28 int indexValue;
29
30 // Note: The data may be implicitly shared throughout the
31 // font database and platform font database, so be careful
32 // to never detach when accessing this member!
33 const QByteArray data;
34};
35
36class Q_GUI_EXPORT QFreeTypeFontDatabase : public QPlatformFontDatabase
37{
38public:
39 void populateFontDatabase() override;
40 QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override;
41 QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override;
42 QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName, QFontDatabasePrivate::ApplicationFont *applicationFont = nullptr) override;
43 void releaseHandle(void *handle) override;
44
45 static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file, QFontDatabasePrivate::ApplicationFont *applicationFont = nullptr);
46};
47
48QT_END_NAMESPACE
49
50#endif // QFREETYPEFONTDATABASE_H
51

source code of qtbase/src/gui/text/freetype/qfreetypefontdatabase_p.h