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// Qt-Security score:significant reason:default
4
5
6#ifndef QSVGFONT_P_H
7#define QSVGFONT_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtCore/qhash.h>
21#include "qpainterpath.h"
22#include "qlist.h"
23#include "qstring.h"
24
25#include "qsvgstyle_p.h"
26
27#include <memory>
28
30
31class Q_SVG_EXPORT QSvgGlyph
32{
33public:
34 QSvgGlyph(const QString &unicode, const QPainterPath &path, qreal horizAdvX);
35 QSvgGlyph() : m_horizAdvX(0) {}
36
37 QString m_unicode;
38 QPainterPath m_path;
39 qreal m_horizAdvX;
40};
41
42
43class Q_SVG_EXPORT QSvgFont : public QSvgRefCounted
44{
45public:
46 static constexpr qreal DEFAULT_UNITS_PER_EM = 1000;
47 QSvgFont(qreal horizAdvX);
48 ~QSvgFont() override;
49
50 void setFamilyName(const QString &name);
51 QString familyName() const;
52
53 void setUnitsPerEm(qreal upem);
54
55 void addGlyph(const QString &unicode, const QPainterPath &path, qreal horizAdvX = -1);
56 bool addMissingGlyph(const QPainterPath &path, qreal horizAdvX);
57
58 void draw(QPainter *p, const QPointF &point, const QList<const QSvgGlyph *> &glyphs,
59 qreal pixelSize, Qt::Alignment alignment) const;
60 QRectF boundingRect(QPainter *p, const QPointF &point, const QList<const QSvgGlyph *> &glyphs,
61 qreal pixelSize, Qt::Alignment alignment) const;
62 const QSvgGlyph *findFirstGlyphFor(QStringView text) const;
63 QList<const QSvgGlyph *> toGlyphs(QStringView text) const;
64
65public:
66 QString m_familyName;
67 qreal m_unitsPerEm = DEFAULT_UNITS_PER_EM;
68 qreal m_horizAdvX;
69 // not about a missing <glyph> element, but the font's <missing-glyph> element:
70 std::unique_ptr<const QSvgGlyph> m_missingGlyph;
71 // The following needs to preserve the order of glyphs because
72 // "17.6 Glyph selection rules" in SVG Tiny 1.2 reads:
73 // "the 'font' element must be searched from its first
74 // 'glyph' element to its last in logical order"
75 QList<QSvgGlyph> m_glyphs;
76
77private:
78 // to speed up finding glyphs
79 mutable QHash<char32_t, QList<qsizetype>> m_possibleGlyphIndicesForChar;
80 mutable qsizetype m_firstUnscannedGlyphIdx = 0;
81
82 void draw_helper(QPainter *p, const QPointF &point,
83 const QList<const QSvgGlyph *> &glyphs, qreal pixelSize,
84 Qt::Alignment alignment, QRectF *boundingRect = nullptr) const;
85};
86
87QT_END_NAMESPACE
88
89#endif // QSVGFONT_P_H
friend class QPainter
Combined button and popup list for selecting options.
@ AssumeTrustedSource
Definition qtsvgglobal.h:20
@ DisableSMILAnimations
Definition qtsvgglobal.h:23
@ DisableCSSAnimations
Definition qtsvgglobal.h:24
@ Tiny12FeaturesOnly
Definition qtsvgglobal.h:19
@ NoOption
Definition qtsvgglobal.h:18
@ DisableAnimations
Definition qtsvgglobal.h:27
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582
#define qPrintable(string)
Definition qstring.h:1683
static QByteArray qt_inflateSvgzDataFrom(QIODevice *device, bool doCheckContent=true)
static bool isValidMatrix(const QTransform &transform)
static bool hasSvgHeader(const QByteArray &buf)
std::optional< int > calculateSizeValue(bool isPercent, int sizeValue, qreal viewBoxSizeValue)