| 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 | |
| 11 | QT_BEGIN_NAMESPACE |
| 12 | |
| 13 | struct CmapSubtable0; |
| 14 | struct CmapSubtable4; |
| 15 | struct CmapSubtable6; |
| 16 | struct CmapSubtable10; |
| 17 | struct CmapSubtable12; |
| 18 | class DistanceFieldModelWorker : public QObject |
| 19 | { |
| 20 | Q_OBJECT |
| 21 | public: |
| 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 | |
| 33 | signals: |
| 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 | |
| 42 | private: |
| 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 | |
| 53 | QT_END_NAMESPACE |
| 54 | |
| 55 | #endif // DISTANCEFIELDMODELWORKER_H |
| 56 | |