Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
distancefieldmodel.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef DISTANCEFIELDMODEL_H
5#define DISTANCEFIELDMODEL_H
6
7#include <QAbstractListModel>
8#include <QRawFont>
9#include <QtGui/qpainterpath.h>
10#include <QtGui/private/qtextengine_p.h>
11#include <QMultiHash>
12#include <QScopedPointer>
13#include <QMetaEnum>
14#include <QThread>
15
17
18class QThread;
21{
23public:
25 Other = 0x00,
26 BasicLatin = 0x20,
34 Cyrillic = 0x400,
36 Armenian = 0x530,
37 Hebrew = 0x590,
38 Arabic = 0x600,
39 Syriac = 0x700,
40 Thaana = 0x780,
41 Devanagari = 0x900,
42 Bengali = 0x980,
43 Gurmukhi = 0xa00,
44 Gujarati = 0xa80,
45 Oriya = 0xb00,
46 Tamil = 0xb80,
47 Telugu = 0xc00,
48 Kannada = 0xc80,
49 Malayalam = 0xd00,
50 Sinhala = 0xd80,
51 Thai = 0xe00,
52 Lao = 0xe80,
53 Tibetan = 0xf00,
54 Myanmar = 0x1000,
55 Georgian = 0x10a0,
56 HangulJamo = 0x1100,
57 Ethiopic = 0x1200,
58 Cherokee = 0x13a0,
60 Ogham = 0x1680,
61 Runic = 0x16a0,
62 Tagalog = 0x1700,
63 Hanunoo = 0x1720,
64 Buhid = 0x1740,
65 Tagbanwa = 0x1760,
66 Khmer = 0x1780,
67 Mongolian = 0x1800,
68 Limbu = 0x1900,
69 TaiLe = 0x1950,
70 KhmerSymbols = 0x19e0,
73 GreekExtended = 0x1f00,
79 NumberForms = 0x2150,
80 Arrows = 0x2190,
86 BoxDrawing = 0x2500,
87 BlockElements = 0x2580,
90 Dingbats = 0x2700,
102 Hiragana = 0x3040,
103 Katakana = 0x30a0,
104 Bopomofo = 0x3100,
106 Kanbun = 0x3190,
114 YiSyllables = 0xa000,
115 YiRadicals = 0xa490,
130 Specials = 0xfff0,
133 AegeanNumbers = 0x10100,
134 OldItalic = 0x10300,
135 Gothic = 0x10330,
136 Ugaritic = 0x10380,
137 Deseret = 0x10400,
138 Shavian = 0x10450,
139 Osmanya = 0x10480,
142 MusicalSymbols = 0x1d100,
147 Tags = 0xe0000,
148 End = 0xe007f
149 };
150 Q_ENUM(UnicodeRange)
151
152 explicit DistanceFieldModel(QObject *parent = nullptr);
154
155 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
156
157 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
158 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
159
160 void setFont(const QString &fileName);
161
163 QList<glyph_t> glyphIndexesForUnicodeRange(UnicodeRange range) const;
164 QString nameForUnicodeRange(UnicodeRange range) const;
165 glyph_t glyphIndexForUcs4(quint32 ucs4) const;
166
167 QImage distanceField(int row) const
168 {
169 return m_distanceFields.at(row);
170 }
171
172 QPainterPath path(int row) const
173 {
174 return m_paths.at(row);
175 }
176
177 qreal pixelSize() const { return m_pixelSize; }
178 bool doubleGlyphResolution() const { return m_doubleGlyphResolution; }
179
180signals:
184 void error(const QString &errorString);
185
186private slots:
188 const QPainterPath &path,
190 quint32 ucs4);
191 void reserveSpace(quint16 glyphCount,
192 bool doubleResolution,
193 qreal pixelSize);
194
195private:
196 UnicodeRange unicodeRangeForUcs4(quint32 ucs4) const;
197
198 QRawFont m_font;
199 DistanceFieldModelWorker *m_worker;
200 QScopedPointer<QThread> m_workerThread;
201 quint16 m_glyphCount;
202 QList<QImage> m_distanceFields;
203 QList<QPainterPath> m_paths;
204 QMultiHash<UnicodeRange, glyph_t> m_glyphsPerUnicodeRange;
205 QHash<quint32, glyph_t> m_glyphsPerUcs4;
206 bool m_doubleGlyphResolution;
207 qreal m_pixelSize;
208 QMetaEnum m_rangeEnum;
209};
210
211QT_END_NAMESPACE
212
213#endif // DISTANCEFIELDMODEL_H
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
void error(const QString &errorString)
void setFont(const QString &fileName)
QImage distanceField(int row) const
QString nameForUnicodeRange(UnicodeRange range) const
QList< glyph_t > glyphIndexesForUnicodeRange(UnicodeRange range) const
bool doubleGlyphResolution() const
QPainterPath path(int row) const
glyph_t glyphIndexForUcs4(quint32 ucs4) const
void distanceFieldGenerated()
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the data for the given role and section in the header with the specified orientation.
QList< UnicodeRange > unicodeRanges() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the data stored under the given role for the item referred to by the index.
void closeEvent(QCloseEvent *event) override
[21]
~MainWindow() override
MainWindow(QWidget *parent=nullptr)
void open(const QString &path)
Combined button and popup list for selecting options.
#define ALIGN_OFFSET(offset)
static QT_BEGIN_NAMESPACE void openHelp()
#define PAD_BUFFER(buffer, size)
#define TO_FIXED_POINT(value)
quint32 checkSumAdjustment
quint16 majorVersion
quint32 fontRevision
quint16 minorVersion
quint32 textureHeight
quint32 textureOffsetX
quint32 boundingRectWidth
quint32 boundingRectHeight
quint32 textureOffsetY
quint16 pixelSize
quint8 padding
quint8 minorVersion
quint32 textureSize
quint8 majorVersion
quint32 numGlyphs
quint32 checkSum
quint32 length
quint32 offset