Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsvgfont_p.h
Go to the documentation of this file.
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 QSVGFONT_P_H
5#define QSVGFONT_P_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 "qpainterpath.h"
19#include "qhash.h"
20#include "qstring.h"
21#include "qsvgstyle_p.h"
22#include "qtsvgglobal_p.h"
23
24#include <memory>
25
27
28class Q_SVG_EXPORT QSvgGlyph
29{
30public:
31 QSvgGlyph(QChar unicode, const QPainterPath &path, qreal horizAdvX);
32 QSvgGlyph() : m_unicode(0), m_horizAdvX(0) {}
33
34 QChar m_unicode;
35 QPainterPath m_path;
36 qreal m_horizAdvX;
37};
38
39
40class Q_SVG_EXPORT QSvgFont : public QSvgRefCounted
41{
42public:
43 static constexpr qreal DEFAULT_UNITS_PER_EM = 1000;
44 QSvgFont(qreal horizAdvX);
45
46 void setFamilyName(const QString &name);
47 QString familyName() const;
48
49 void setUnitsPerEm(qreal upem);
50
51 void addGlyph(QChar unicode, const QPainterPath &path, qreal horizAdvX = -1);
52 bool addMissingGlyph(const QPainterPath &path, qreal horizAdvX);
53
54 void draw(QPainter *p, const QPointF &point, const QString &str,
55 qreal pixelSize, Qt::Alignment alignment) const;
56 QRectF boundingRect(QPainter *p, const QPointF &point, const QString &str,
57 qreal pixelSize, Qt::Alignment alignment) const;
58
59public:
60 QString m_familyName;
61 qreal m_unitsPerEm = DEFAULT_UNITS_PER_EM;
62 qreal m_horizAdvX;
63 // not about a missing <glyph> element, but the font's <missing-glyph> element:
64 std::unique_ptr<const QSvgGlyph> m_missingGlyph;
65 QHash<QChar, QSvgGlyph> m_glyphs;
66
67private:
68 void draw_helper(QPainter *p, const QPointF &point, const QString &str, qreal pixelSize,
69 Qt::Alignment alignment, QRectF *boundingRect = nullptr) const;
70};
71
72QT_END_NAMESPACE
73
74#endif // QSVGFONT_P_H
friend class QPainter
QRectF decoratedInternalBounds(QPainter *p, QSvgExtraStates &states) const override
QSvgNode * link() const
void setLink(QSvgNode *link)
void drawCommand(QPainter *p, QSvgExtraStates &states) override
bool isResolved() const
QRectF internalBounds(QPainter *p, QSvgExtraStates &states) const override
bool isRecursing() const
QPointF start() const
const QString & linkId() const
QSvgUse(const QPointF &start, QSvgNode *parent, const QString &linkId)
QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *link)
Type type() const override
void drawCommand(QPainter *, QSvgExtraStates &) override
Type type() const override
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568