Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSVGText.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkSVGText_DEFINED
9#define SkSVGText_DEFINED
10
11#include <vector>
12
15
17
18// Base class for text-rendering nodes.
20public:
22
23protected:
25
27
28 // Text nodes other than the root <text> element are not rendered directly.
29 void onRender(const SkSVGRenderContext&) const override {}
30
31private:
32 SkPath onAsPath(const SkSVGRenderContext&) const override;
33
34 using INHERITED = SkSVGTransformableNode;
35};
36
37// Base class for nestable text containers (<text>, <tspan>, etc).
39public:
40 SVG_ATTR(X, std::vector<SkSVGLength>, {})
41 SVG_ATTR(Y, std::vector<SkSVGLength>, {})
42 SVG_ATTR(Dx, std::vector<SkSVGLength>, {})
43 SVG_ATTR(Dy, std::vector<SkSVGLength>, {})
44 SVG_ATTR(Rotate, std::vector<SkSVGNumberType>, {})
45
47
48 void appendChild(sk_sp<SkSVGNode>) final;
49
50protected:
52
53 void onShapeText(const SkSVGRenderContext&, SkSVGTextContext*, SkSVGXmlSpace) const override;
54
55 bool parseAndSetAttribute(const char*, const char*) override;
56
57private:
58 std::vector<sk_sp<SkSVGTextFragment>> fChildren;
59
60 using INHERITED = SkSVGTextFragment;
61};
62
63class SkSVGText final : public SkSVGTextContainer {
64public:
65 static sk_sp<SkSVGText> Make() { return sk_sp<SkSVGText>(new SkSVGText()); }
66
67private:
68 SkSVGText() : INHERITED(SkSVGTag::kText) {}
69
70 void onRender(const SkSVGRenderContext&) const override;
71
72 SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
73 SkPath onAsPath(const SkSVGRenderContext&) const override;
74
75 using INHERITED = SkSVGTextContainer;
76};
77
78class SkSVGTSpan final : public SkSVGTextContainer {
79public:
81
82private:
83 SkSVGTSpan() : INHERITED(SkSVGTag::kTSpan) {}
84
85 using INHERITED = SkSVGTextContainer;
86};
87
88class SkSVGTextLiteral final : public SkSVGTextFragment {
89public:
93
95
96private:
97 SkSVGTextLiteral() : INHERITED(SkSVGTag::kTextLiteral) {}
98
99 void onShapeText(const SkSVGRenderContext&, SkSVGTextContext*, SkSVGXmlSpace) const override;
100
102
103 using INHERITED = SkSVGTextFragment;
104};
105
106class SkSVGTextPath final : public SkSVGTextContainer {
107public:
109
110 SVG_ATTR(Href , SkSVGIRI , {} )
111 SVG_ATTR(StartOffset, SkSVGLength, SkSVGLength(0))
112
113private:
114 SkSVGTextPath() : INHERITED(SkSVGTag::kTextPath) {}
115
116 void onShapeText(const SkSVGRenderContext&, SkSVGTextContext*, SkSVGXmlSpace) const override;
117 bool parseAndSetAttribute(const char*, const char*) override;
118
119 using INHERITED = SkSVGTextContainer;
120};
121
122#endif // SkSVGText_DEFINED
#define SK_API
Definition SkAPI.h:35
SkSVGTag
Definition SkSVGNode.h:23
#define SVG_ATTR(attr_name, attr_type, attr_default)
Definition SkSVGNode.h:203
SkSVGXmlSpace
Definition SkSVGTypes.h:714
SkString SkSVGStringType
Definition SkSVGTypes.h:28
static const SkScalar Y
static const SkScalar X
static sk_sp< SkSVGTSpan > Make()
Definition SkSVGText.h:80
void onShapeText(const SkSVGRenderContext &, SkSVGTextContext *, SkSVGXmlSpace) const override
void appendChild(sk_sp< SkSVGNode >) final
bool parseAndSetAttribute(const char *, const char *) override
SkSVGTextContainer(SkSVGTag t)
Definition SkSVGText.h:51
SkPath onAsPath(const SkSVGRenderContext &) const override
void renderText(const SkSVGRenderContext &, SkSVGTextContext *, SkSVGXmlSpace) const
SkSVGTextFragment(SkSVGTag t)
Definition SkSVGText.h:24
void onRender(const SkSVGRenderContext &) const override
Definition SkSVGText.h:29
virtual void onShapeText(const SkSVGRenderContext &, SkSVGTextContext *, SkSVGXmlSpace) const =0
void onShapeText(const SkSVGRenderContext &, SkSVGTextContext *, SkSVGXmlSpace) const override
static sk_sp< SkSVGTextLiteral > Make()
Definition SkSVGText.h:90
void appendChild(sk_sp< SkSVGNode >) override
Definition SkSVGText.h:101
static sk_sp< SkSVGTextPath > Make()
Definition SkSVGText.h:108
void onShapeText(const SkSVGRenderContext &, SkSVGTextContext *, SkSVGXmlSpace) const override
bool parseAndSetAttribute(const char *, const char *) override
void onRender(const SkSVGRenderContext &) const override
static sk_sp< SkSVGText > Make()
Definition SkSVGText.h:65
SkRect onObjectBoundingBox(const SkSVGRenderContext &) const override
SkPath onAsPath(const SkSVGRenderContext &) const override
constexpr char kText[]
Definition glyph_pos.cpp:28