1/****************************************************************************
2**
3** Copyright (C) 2018 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the tools applications of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
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 General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef DISTANCEFIELDMODELWORKER_H
30#define DISTANCEFIELDMODELWORKER_H
31
32#include <QObject>
33#include <QRawFont>
34#include <QtGui/private/qtextengine_p.h>
35
36QT_BEGIN_NAMESPACE
37
38struct CmapSubtable0;
39struct CmapSubtable4;
40struct CmapSubtable6;
41struct CmapSubtable10;
42struct CmapSubtable12;
43class DistanceFieldModelWorker : public QObject
44{
45 Q_OBJECT
46public:
47 explicit DistanceFieldModelWorker(QObject *parent = nullptr);
48
49 Q_INVOKABLE void generateOneDistanceField();
50 Q_INVOKABLE void loadFont(const QString &fileName);
51
52 void readCmapSubtable(const CmapSubtable0 *subtable, const void *end);
53 void readCmapSubtable(const CmapSubtable4 *subtable, const void *end);
54 void readCmapSubtable(const CmapSubtable6 *subtable, const void *end);
55 void readCmapSubtable(const CmapSubtable10 *subtable, const void *end);
56 void readCmapSubtable(const CmapSubtable12 *subtable, const void *end);
57
58signals:
59 void fontLoaded(quint16 glyphCount, bool doubleResolution, qreal pixelSize);
60 void fontGenerated();
61 void distanceFieldGenerated(const QImage &distanceField,
62 const QPainterPath &path,
63 glyph_t glyphId,
64 quint32 cmapAssignment);
65 void error(const QString &errorString);
66
67private:
68 void readGlyphCount();
69 void readCmap();
70
71 QRawFont m_font;
72 quint16 m_glyphCount;
73 quint16 m_nextGlyphId;
74 bool m_doubleGlyphResolution;
75 QHash<glyph_t, quint32> m_cmapping;
76};
77
78QT_END_NAMESPACE
79
80#endif // DISTANCEFIELDMODELWORKER_H
81

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