10#include <QtGui/qrawfont.h>
11#include <QtGui/qpainterpath.h>
24 m_font.
setPixelSize(curveGlyphAtlasFontSize > 0 ?
qreal(curveGlyphAtlasFontSize) : 10.0);
33 for (
glyph_t glyphIndex : glyphs) {
34 if (!m_glyphs.
contains(glyphIndex)) {
42 [&glyph](
const std::array<QVector2D, 3> &
s,
43 const std::array<QVector2D, 3> &
p,
44 const std::array<QVector2D, 3> &
n,
46 glyph.strokeVertices.
append(
s.at(0));
47 glyph.strokeVertices.
append(
s.at(1));
48 glyph.strokeVertices.
append(
s.at(2));
50 glyph.strokeUvs.
append(
p.at(0));
51 glyph.strokeUvs.
append(
p.at(1));
52 glyph.strokeUvs.
append(
p.at(2));
54 glyph.strokeNormals.
append(
n.at(0));
55 glyph.strokeNormals.
append(
n.at(1));
56 glyph.strokeNormals.
append(
n.at(2));
61 quadPath = quadPath.subPathsClosed();
62 quadPath.addCurvatureData();
68 [&glyph](
const std::array<QVector2D, 3> &
v,
69 const std::array<QVector2D, 3> &
n,
78 glyph.uvs.
append(uvForPoint(
v.at(1)));
79 glyph.uvs.
append(uvForPoint(
v.at(2)));
89 m_glyphs.
insert(glyphIndex, glyph);
98 const Glyph &glyph = m_glyphs[glyphIndex];
105 if (glyph.strokeElementIsLine.
at(
i)) {
107 std::array<QVector2D, 2>({ glyph.strokeUvs.
at(
i * 3 + 0) +
v, glyph.strokeUvs.
at(
i * 3 + 2) +
v }),
108 { glyph.strokeNormals.
at(
i * 3 + 0), glyph.strokeNormals.
at(
i * 3 + 1), glyph.strokeNormals.
at(
i * 3 + 2) });
111 { glyph.strokeUvs.
at(
i * 3 + 0) +
v, glyph.strokeUvs.
at(
i * 3 + 1) +
v, glyph.strokeUvs.
at(
i * 3 + 2) +
v },
112 { glyph.strokeNormals.
at(
i * 3 + 0), glyph.strokeNormals.
at(
i * 3 + 1), glyph.strokeNormals.
at(
i * 3 + 2) });
121 qreal pixelSize)
const
123 const Glyph &glyph = m_glyphs[glyphIndex];
125 const float scaleFactor = pixelSize / m_font.
pixelSize();
129 scaleFactor * glyph.vertices.
at(
i * 3 + 1) +
v,
130 scaleFactor * glyph.vertices.
at(
i * 3 + 2) +
v,
131 glyph.uvs.
at(
i * 3 + 0),
132 glyph.uvs.
at(
i * 3 + 1),
133 glyph.uvs.
at(
i * 3 + 2),
134 glyph.normals.
at(
i * 3 + 0),
135 glyph.normals.
at(
i * 3 + 1),
136 glyph.normals.
at(
i * 3 + 2),
137 glyph.duvdx.
at(
i) / scaleFactor,
138 glyph.duvdy.
at(
i) / scaleFactor);
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
\inmodule QtCore\reentrant
static QQuadPath fromPainterPath(const QPainterPath &path, PathHints hints={})
The QRawFont class provides access to a single physical instance of a font.
qreal pixelSize() const
Returns the pixel size set for this QRawFont.
void setPixelSize(qreal pixelSize)
Sets the pixel size with which this font should be rendered to pixelSize.
QPainterPath pathForGlyph(quint32 glyphIndex) const
This function returns the shape of the glyph at a given glyphIndex in the underlying font if the QRaw...
void appendTriangle(const std::array< QVector2D, 3 > &v, const std::array< QVector2D, 3 > &n, std::function< QVector3D(QVector2D)> uvForPoint)
QSGCurveGlyphAtlas(const QRawFont &font)
void addStroke(QSGCurveStrokeNode *node, glyph_t glyph, const QPointF &position) const
void addGlyph(QSGCurveFillNode *node, glyph_t glyph, const QPointF &position, qreal pixelSize) const
virtual ~QSGCurveGlyphAtlas()
void populate(const QList< glyph_t > &glyphs)
static void processStroke(const QQuadPath &strokePath, float miterLimit, float penWidth, Qt::PenJoinStyle joinStyle, Qt::PenCapStyle capStyle, addStrokeTriangleCallback addTriangle, int subdivisions=3)
std::function< QVector3D(QVector2D)> uvForPointCallback
static bool solveOverlaps(QQuadPath &path)
static void processFill(const QQuadPath &path, Qt::FillRule fillRule, addTriangleCallback addTriangle)
void appendTriangle(const std::array< QVector2D, 3 > &v, const std::array< QVector2D, 3 > &p, const std::array< QVector2D, 3 > &n)
The QVector2D class represents a vector or vertex in 2D space.
The QVector3D class represents a vector or vertex in 3D space.
Combined button and popup list for selecting options.
GLint GLfloat GLfloat GLfloat v2
GLsizei const GLfloat * v
[13]
GLint GLfloat GLfloat GLfloat GLfloat v3
GLsizei const GLchar *const * path
static bool isLine(const QBezier &bezier)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept