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
25QT_BEGIN_NAMESPACE
26
27bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(const QRawFont &f);
28bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(QFontEngine *fontEngine);
29
30int Q_GUI_EXPORT QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont);
31int Q_GUI_EXPORT QT_DISTANCEFIELD_TILESIZE(bool narrowOutlineFont);
32int Q_GUI_EXPORT QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont);
33int Q_GUI_EXPORT QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont);
34int Q_GUI_EXPORT QT_DISTANCEFIELD_HIGHGLYPHCOUNT();
35
36class Q_GUI_EXPORT QDistanceFieldData : public QSharedData
37{
38public:
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
46 glyph_t glyph;
47 int width;
48 int height;
49 int nbytes;
50 uchar *data;
51};
52
53class Q_GUI_EXPORT QDistanceField
54{
55public:
56 QDistanceField();
57 QDistanceField(int width, int height);
58 QDistanceField(const QRawFont &font, glyph_t glyph, bool doubleResolution = false);
59 QDistanceField(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false);
60 QDistanceField(const QPainterPath &path, glyph_t glyph, bool doubleResolution = false);
61
62 bool isNull() const;
63
64 glyph_t glyph() const;
65 void setGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution = false);
66 void setGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubleResolution = false);
67
68 int width() const;
69 int height() const;
70
71 QDistanceField copy(const QRect &rect = QRect()) const;
72 inline QDistanceField copy(int x, int y, int w, int h) const
73 { return copy(rect: QRect(x, y, w, h)); }
74
75 uchar *bits();
76 const uchar *bits() const;
77 const uchar *constBits() const;
78
79 uchar *scanLine(int);
80 const uchar *scanLine(int) const;
81 const uchar *constScanLine(int) const;
82
83 QImage toImage(QImage::Format format = QImage::Format_ARGB32_Premultiplied) const;
84
85private:
86 QDistanceField(QDistanceFieldData *data);
87 QSharedDataPointer<QDistanceFieldData> d;
88
89 friend class QDistanceFieldData;
90};
91
92QT_END_NAMESPACE
93
94#endif // QDISTANCEFIELD_H
95

source code of qtbase/src/gui/text/qdistancefield_p.h