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