Krita Source Code Documentation
Loading...
Searching...
No Matches
KoSvgTextContentElement.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KOSVGTEXTCONTENTELEMENT_H
8#define KOSVGTEXTCONTENTELEMENT_H
9
10#include "KoSvgText.h"
11#include "KoSvgTextProperties.h"
12#include "SvgLoadingContext.h"
13#include "SvgSavingContext.h"
14
15#include <kritaflake_export.h>
16#include <QScopedPointer>
17
27struct KRITAFLAKE_EXPORT KoSvgTextContentElement
28{
29public:
32 : properties(rhs.properties)
33 , localTransformations(rhs.localTransformations)
34 , textPathInfo(rhs.textPathInfo)
35 , textLength(rhs.textLength)
36 , lengthAdjust(rhs.lengthAdjust)
37 , textDecorations(rhs.textDecorations)
38 , text(rhs.text)
39 , finalResultIndex(rhs.finalResultIndex)
40 , associatedOutline(rhs.associatedOutline)
41 {
42 if (rhs.textPath) {
43 textPath.reset(rhs.textPath.data()->cloneShape());
44 }
45 }
46
48
51
54
57
59 QScopedPointer<KoShape> textPath{nullptr};
60
65
67 QMap<KoSvgText::TextDecoration, QPainterPath> textDecorations;
68
70 QString text;
71
75 int finalResultIndex = -1;
76
78 QPainterPath associatedOutline;
79
91 bool loadSvg(const QDomElement &element, SvgLoadingContext &context, bool rootNode = false);
92
93 bool loadSvgTextNode(const QDomText &text, SvgLoadingContext &context);
94
95 bool saveSvg(SvgSavingContext &context, bool rootText, bool saveText, QMap<QString, QString> shapeSpecificAttributes);
96
102 int numChars(bool withControls = false, KoSvgTextProperties resolvedProps = KoSvgTextProperties()) const;
103
108 QString getTransformedString(QVector<QPair<int, int>> &positions, KoSvgTextProperties resolvedProps = KoSvgTextProperties()) const;
109
115 void insertText(int start, QString insertText);
122 void removeText(int &start, int length);
123};
124
125#endif // KOSVGTEXTCONTENTELEMENT_H
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
Contains data used for loading svg.
Context for saving svg files.
@ LengthAdjustSpacing
Only stretch the spaces.
Definition KoSvgText.h:251
The KoSvgTextContentElement struct.
KoSvgText::AutoValue textLength
the value 'textLength' attribute of the associated dom element
~KoSvgTextContentElement()=default
QVector< KoSvgText::CharTransformation > localTransformations
Local SVG char transforms.
QMap< KoSvgText::TextDecoration, QPainterPath > textDecorations
Cached text decorations to be used by the painting function.
KoSvgTextProperties properties
The textProperties. This includes.
QPainterPath associatedOutline
The associated outline. Currently only a bounding box.
QString text
Plain text of the current node. Use insertText and removeText to manipulate it.
QScopedPointer< KoShape > textPath
The textpath, if any. Defaults to null.
KoSvgTextContentElement(const KoSvgTextContentElement &rhs)
KoSvgText::TextOnPathInfo textPathInfo
Text path info for the text-on-path algorithm.