| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QDISTANCEFIELD_H |
| 5 | #define QDISTANCEFIELD_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtGui/private/qtguiglobal_p.h> |
| 19 | #include <qrawfont.h> |
| 20 | #include <private/qfontengine_p.h> |
| 21 | #include <QtCore/qshareddata.h> |
| 22 | #include <QtCore/qglobal.h> |
| 23 | #include <QLoggingCategory> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(const QRawFont &f); |
| 28 | bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(QFontEngine *fontEngine); |
| 29 | |
| 30 | int Q_GUI_EXPORT QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont); |
| 31 | int Q_GUI_EXPORT QT_DISTANCEFIELD_TILESIZE(bool narrowOutlineFont); |
| 32 | int Q_GUI_EXPORT QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont); |
| 33 | int Q_GUI_EXPORT QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont); |
| 34 | int Q_GUI_EXPORT QT_DISTANCEFIELD_HIGHGLYPHCOUNT(); |
| 35 | |
| 36 | class Q_GUI_EXPORT QDistanceFieldData : public QSharedData |
| 37 | { |
| 38 | public: |
| 39 | QDistanceFieldData() : glyph(0), width(0), height(0), nbytes(0), data(nullptr) {} |
| 40 | QDistanceFieldData(const QDistanceFieldData &other); |
| 41 | ~QDistanceFieldData(); |
| 42 | |
| 43 | static QDistanceFieldData *create(const QSize &size); |
| 44 | static QDistanceFieldData *create(const QPainterPath &path, bool doubleResolution); |
| 45 | static QDistanceFieldData *create(QSize size, const QPainterPath &path, bool doubleResolution); |
| 46 | |
| 47 | glyph_t glyph; |
| 48 | int width; |
| 49 | int height; |
| 50 | int nbytes; |
| 51 | uchar *data; |
| 52 | }; |
| 53 | |
| 54 | class Q_GUI_EXPORT QDistanceField |
| 55 | { |
| 56 | public: |
| 57 | QDistanceField(); |
| 58 | QDistanceField(int width, int height); |
| 59 | QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution = false); |
| 60 | QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false); |
| 61 | QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution = false); |
| 62 | QDistanceField(QSize size, const QPainterPath &path, glyph_t glyph, bool doubleResolution = false); |
| 63 | |
| 64 | bool isNull() const; |
| 65 | |
| 66 | glyph_t glyph() const; |
| 67 | void setGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution = false); |
| 68 | void setGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false); |
| 69 | |
| 70 | int width() const; |
| 71 | int height() const; |
| 72 | |
| 73 | QDistanceField copy(const QRect &rect = QRect()) const; |
| 74 | inline QDistanceField copy(int x, int y, int w, int h) const |
| 75 | { return copy(rect: QRect(x, y, w, h)); } |
| 76 | |
| 77 | uchar *bits(); |
| 78 | const uchar *bits() const; |
| 79 | const uchar *constBits() const; |
| 80 | |
| 81 | uchar *scanLine(int); |
| 82 | const uchar *scanLine(int) const; |
| 83 | const uchar *constScanLine(int) const; |
| 84 | |
| 85 | QImage toImage(QImage::Format format = QImage::Format_ARGB32_Premultiplied) const; |
| 86 | |
| 87 | private: |
| 88 | QDistanceField(QDistanceFieldData *data); |
| 89 | QSharedDataPointer<QDistanceFieldData> d; |
| 90 | |
| 91 | friend class QDistanceFieldData; |
| 92 | }; |
| 93 | |
| 94 | QT_END_NAMESPACE |
| 95 | |
| 96 | #endif // QDISTANCEFIELD_H |
| 97 | |