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 DISTANCEFIELDMODELWORKER_H
5#define DISTANCEFIELDMODELWORKER_H
6
7#include <QObject>
8#include <QRawFont>
9#include <QtGui/private/qtextengine_p.h>
10
11QT_BEGIN_NAMESPACE
12
13struct CmapSubtable0;
14struct CmapSubtable4;
15struct CmapSubtable6;
16struct CmapSubtable10;
17struct CmapSubtable12;
18class DistanceFieldModelWorker : public QObject
19{
20 Q_OBJECT
21public:
22 explicit DistanceFieldModelWorker(QObject *parent = nullptr);
23
24 Q_INVOKABLE void generateOneDistanceField();
25 Q_INVOKABLE void loadFont(const QString &fileName);
26
27 void readCmapSubtable(const CmapSubtable0 *subtable, const void *end);
28 void readCmapSubtable(const CmapSubtable4 *subtable, const void *end);
29 void readCmapSubtable(const CmapSubtable6 *subtable, const void *end);
30 void readCmapSubtable(const CmapSubtable10 *subtable, const void *end);
31 void readCmapSubtable(const CmapSubtable12 *subtable, const void *end);
32
33signals:
34 void fontLoaded(quint16 glyphCount, bool doubleResolution, qreal pixelSize);
35 void fontGenerated();
36 void distanceFieldGenerated(const QImage &distanceField,
37 const QPainterPath &path,
38 glyph_t glyphId,
39 quint32 cmapAssignment);
40 void error(const QString &errorString);
41
42private:
43 void readGlyphCount();
44 void readCmap();
45
46 QRawFont m_font;
47 quint16 m_glyphCount;
48 quint16 m_nextGlyphId;
49 bool m_doubleGlyphResolution;
50 QHash<glyph_t, quint32> m_cmapping;
51};
52
53QT_END_NAMESPACE
54
55#endif // DISTANCEFIELDMODELWORKER_H
56

source code of qttools/src/distancefieldgenerator/distancefieldmodelworker.h