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 | QT_BEGIN_NAMESPACE |
25 | |
26 | class Q_SVG_PRIVATE_EXPORT QSvgGlyph |
27 | { |
28 | public: |
29 | QSvgGlyph(QChar unicode, const QPainterPath &path, qreal horizAdvX); |
30 | QSvgGlyph() : m_unicode(0), m_horizAdvX(0) {} |
31 | |
32 | QChar m_unicode; |
33 | QPainterPath m_path; |
34 | qreal m_horizAdvX; |
35 | }; |
36 | |
37 | |
38 | class Q_SVG_PRIVATE_EXPORT QSvgFont : public QSvgRefCounted |
39 | { |
40 | public: |
41 | static constexpr qreal DEFAULT_UNITS_PER_EM = 1000; |
42 | QSvgFont(qreal horizAdvX); |
43 | |
44 | void setFamilyName(const QString &name); |
45 | QString familyName() const; |
46 | |
47 | void setUnitsPerEm(qreal upem); |
48 | |
49 | void addGlyph(QChar unicode, const QPainterPath &path, qreal horizAdvX = -1); |
50 | |
51 | void draw(QPainter *p, const QPointF &point, const QString &str, qreal pixelSize, Qt::Alignment alignment) const; |
52 | public: |
53 | QString m_familyName; |
54 | qreal m_unitsPerEm = DEFAULT_UNITS_PER_EM; |
55 | qreal m_horizAdvX; |
56 | QHash<QChar, QSvgGlyph> m_glyphs; |
57 | }; |
58 | |
59 | QT_END_NAMESPACE |
60 | |
61 | #endif // QSVGFONT_P_H |
62 | |