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 QFONTDATABASE_H
41#define QFONTDATABASE_H
42
43#include <QtGui/qtguiglobal.h>
44#include <QtGui/qwindowdefs.h>
45#include <QtCore/qstring.h>
46#include <QtGui/qfont.h>
47
48QT_BEGIN_NAMESPACE
49
50
51class QStringList;
52template <class T> class QList;
53struct QFontDef;
54class QFontEngine;
55
56class QFontDatabasePrivate;
57
58class Q_GUI_EXPORT QFontDatabase
59{
60 Q_GADGET
61public:
62 // do not re-order or delete entries from this enum without updating the
63 // QPF2 format and makeqpf!!
64 enum WritingSystem {
65 Any,
66
67 Latin,
68 Greek,
69 Cyrillic,
70 Armenian,
71 Hebrew,
72 Arabic,
73 Syriac,
74 Thaana,
75 Devanagari,
76 Bengali,
77 Gurmukhi,
78 Gujarati,
79 Oriya,
80 Tamil,
81 Telugu,
82 Kannada,
83 Malayalam,
84 Sinhala,
85 Thai,
86 Lao,
87 Tibetan,
88 Myanmar,
89 Georgian,
90 Khmer,
91 SimplifiedChinese,
92 TraditionalChinese,
93 Japanese,
94 Korean,
95 Vietnamese,
96
97 Symbol,
98 Other = Symbol,
99
100 Ogham,
101 Runic,
102 Nko,
103
104 WritingSystemsCount
105 };
106 Q_ENUM(WritingSystem)
107
108 enum SystemFont {
109 GeneralFont,
110 FixedFont,
111 TitleFont,
112 SmallestReadableFont
113 };
114 Q_ENUM(SystemFont)
115
116 static QList<int> standardSizes();
117
118 QFontDatabase();
119
120 QList<WritingSystem> writingSystems() const;
121 QList<WritingSystem> writingSystems(const QString &family) const;
122
123 QStringList families(WritingSystem writingSystem = Any) const;
124 QStringList styles(const QString &family) const;
125 QList<int> pointSizes(const QString &family, const QString &style = QString());
126 QList<int> smoothSizes(const QString &family, const QString &style);
127 QString styleString(const QFont &font);
128 QString styleString(const QFontInfo &fontInfo);
129
130 QFont font(const QString &family, const QString &style, int pointSize) const;
131
132 bool isBitmapScalable(const QString &family, const QString &style = QString()) const;
133 bool isSmoothlyScalable(const QString &family, const QString &style = QString()) const;
134 bool isScalable(const QString &family, const QString &style = QString()) const;
135 bool isFixedPitch(const QString &family, const QString &style = QString()) const;
136
137 bool italic(const QString &family, const QString &style) const;
138 bool bold(const QString &family, const QString &style) const;
139 int weight(const QString &family, const QString &style) const;
140
141 bool hasFamily(const QString &family) const;
142 bool isPrivateFamily(const QString &family) const;
143
144 static QString writingSystemName(WritingSystem writingSystem);
145 static QString writingSystemSample(WritingSystem writingSystem);
146
147 static int addApplicationFont(const QString &fileName);
148 static int addApplicationFontFromData(const QByteArray &fontData);
149 static QStringList applicationFontFamilies(int id);
150 static bool removeApplicationFont(int id);
151 static bool removeAllApplicationFonts();
152
153#if QT_DEPRECATED_SINCE(5, 2)
154 QT_DEPRECATED static bool supportsThreadedFontRendering();
155#endif
156
157 static QFont systemFont(SystemFont type);
158
159private:
160 static void createDatabase();
161 static void parseFontName(const QString &name, QString &foundry, QString &family);
162 static QString resolveFontFamilyAlias(const QString &family);
163 static QFontEngine *findFont(const QFontDef &request, int script /* QChar::Script */);
164 static void load(const QFontPrivate *d, int script /* QChar::Script */);
165
166 friend struct QFontDef;
167 friend class QFontPrivate;
168 friend class QFontDialog;
169 friend class QFontDialogPrivate;
170 friend class QFontEngineMulti;
171 friend class QRawFont;
172
173 QFontDatabasePrivate *d;
174};
175
176QT_END_NAMESPACE
177
178#endif // QFONTDATABASE_H
179