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/qloggingcategory.h> |
54 | #include <QtCore/QString> |
55 | #include <QtCore/QStringList> |
56 | #include <QtCore/QList> |
57 | #include <QtGui/QFontDatabase> |
58 | #include <QtGui/private/qfontengine_p.h> |
59 | #include <QtGui/private/qfont_p.h> |
60 | #include <QtGui/private/qfontdatabase_p.h> |
61 | |
62 | QT_BEGIN_NAMESPACE |
63 | |
64 | Q_DECLARE_LOGGING_CATEGORY(lcQpaFonts) |
65 | |
66 | class QWritingSystemsPrivate; |
67 | |
68 | class Q_GUI_EXPORT QSupportedWritingSystems |
69 | { |
70 | public: |
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 | |
80 | private: |
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 | |
92 | Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); |
93 | Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); |
94 | |
95 | #ifndef QT_NO_DEBUG_STREAM |
96 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &); |
97 | #endif |
98 | |
99 | class QFontRequestPrivate; |
100 | class QFontEngineMulti; |
101 | |
102 | class Q_GUI_EXPORT QPlatformFontDatabase |
103 | { |
104 | public: |
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, QFontDatabasePrivate::ApplicationFont *font = nullptr); |
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 [2]); |
130 | static QSupportedWritingSystems writingSystemsFromOS2Table(const char *os2Table, size_t length); |
131 | |
132 | //callback |
133 | static void registerFont(const QString &familyname, const QString &stylename, |
134 | const QString &foundryname, QFont::Weight weight, |
135 | QFont::Style style, QFont::Stretch stretch, bool antialiased, |
136 | bool scalable, int pixelSize, bool fixedPitch, |
137 | const QSupportedWritingSystems &writingSystems, void *handle); |
138 | |
139 | static void registerFontFamily(const QString &familyName); |
140 | static void registerAliasToFontFamily(const QString &familyName, const QString &alias); |
141 | |
142 | static bool isFamilyPopulated(const QString &familyName); |
143 | }; |
144 | |
145 | QT_END_NAMESPACE |
146 | |
147 | #endif // QPLATFORMFONTDATABASE_H |
148 | |