1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QPLATFORMFONTDATABASE_H
41#define QPLATFORMFONTDATABASE_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is part of the QPA API and is not meant to be used
48// in applications. Usage of this API may make your code
49// source and binary incompatible with future versions of Qt.
50//
51
52#include <QtGui/qtguiglobal.h>
53#include <QtCore/QString>
54#include <QtCore/QStringList>
55#include <QtCore/QList>
56#if QT_DEPRECATED_SINCE(5, 5)
57#include <QtCore/QHash>
58#endif
59#include <QtGui/QFontDatabase>
60#include <QtGui/private/qfontengine_p.h>
61#include <QtGui/private/qfont_p.h>
62
63QT_BEGIN_NAMESPACE
64
65
66class QWritingSystemsPrivate;
67
68class Q_GUI_EXPORT QSupportedWritingSystems
69{
70public:
71
72 QSupportedWritingSystems();
73 QSupportedWritingSystems(const QSupportedWritingSystems &other);
74 QSupportedWritingSystems &operator=(const QSupportedWritingSystems &other);
75 ~QSupportedWritingSystems();
76
77 void setSupported(QFontDatabase::WritingSystem, bool supported = true);
78 bool supported(QFontDatabase::WritingSystem) const;
79
80private:
81 void detach();
82
83 QWritingSystemsPrivate *d;
84
85 friend Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
86 friend Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
87#ifndef QT_NO_DEBUG_STREAM
88 friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &);
89#endif
90};
91
92Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
93Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
94
95#ifndef QT_NO_DEBUG_STREAM
96Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &);
97#endif
98
99class QFontRequestPrivate;
100class QFontEngineMulti;
101
102class Q_GUI_EXPORT QPlatformFontDatabase
103{
104public:
105 virtual ~QPlatformFontDatabase();
106 virtual void populateFontDatabase();
107 virtual bool populateFamilyAliases(const QString &missingFamily) { Q_UNUSED(missingFamily); return false; }
108 virtual void populateFamily(const QString &familyName);
109 virtual void invalidate();
110
111 virtual QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script);
112 virtual QFontEngine *fontEngine(const QFontDef &fontDef, void *handle);
113 virtual QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
114 virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
115 virtual void releaseHandle(void *handle);
116
117 virtual QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
118
119 virtual QString fontDir() const;
120
121 virtual QFont defaultFont() const;
122 virtual bool isPrivateFontFamily(const QString &family) const;
123
124 virtual QString resolveFontFamilyAlias(const QString &family) const;
125 virtual bool fontsAlwaysScalable() const;
126 virtual QList<int> standardSizes() const;
127
128 // helper
129 static QSupportedWritingSystems writingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]);
130 static QFont::Weight weightFromInteger(int weight);
131
132 //callback
133 static void registerQPF2Font(const QByteArray &dataArray, void *handle);
134 static void registerFont(const QString &familyname, const QString &stylename,
135 const QString &foundryname, QFont::Weight weight,
136 QFont::Style style, QFont::Stretch stretch, bool antialiased,
137 bool scalable, int pixelSize, bool fixedPitch,
138 const QSupportedWritingSystems &writingSystems, void *handle);
139
140 static void registerFontFamily(const QString &familyName);
141 static void registerAliasToFontFamily(const QString &familyName, const QString &alias);
142
143 static bool isFamilyPopulated(const QString &familyName);
144};
145
146QT_END_NAMESPACE
147
148#endif // QPLATFORMFONTDATABASE_H
149

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