blob: ab186c9e57021a465a3f0cd168b4158b065d983a [file] [log] [blame]
Florin Malitab3418102020-10-15 18:10:29 -04001/*
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
Florin Malitab3418102020-10-15 18:10:29 -040011#include "include/utils/SkTextUtils.h"
Florin Malita39fe8c82020-10-20 10:43:03 -040012#include "modules/svg/include/SkSVGTransformableNode.h"
Florin Malitab3418102020-10-15 18:10:29 -040013#include "modules/svg/include/SkSVGTypes.h"
14
15class SkRRect;
16
Florin Malita39fe8c82020-10-20 10:43:03 -040017class SkSVGText final : public SkSVGTransformableNode {
Florin Malitab3418102020-10-15 18:10:29 -040018 public:
19 ~SkSVGText() override = default;
20 static sk_sp<SkSVGText> Make() {
21 return sk_sp<SkSVGText>(new SkSVGText()); }
22
Florin Malita056385b2020-10-27 22:57:56 -040023 SVG_ATTR(X , SkSVGLength , SkSVGLength(0))
24 SVG_ATTR(Y , SkSVGLength , SkSVGLength(0))
25 SVG_ATTR(Text, SkSVGStringType, SkSVGStringType())
Florin Malitab3418102020-10-15 18:10:29 -040026
27 protected:
28 void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
29
Florin Malita39fe8c82020-10-20 10:43:03 -040030 void onRender(const SkSVGRenderContext&) const override;
31 void appendChild(sk_sp<SkSVGNode>) override;
Florin Malitab3418102020-10-15 18:10:29 -040032
33 SkPath onAsPath(const SkSVGRenderContext&) const override;
34
35 void loadFont();
36
37 private:
38 SkSVGText();
Florin Malita39fe8c82020-10-20 10:43:03 -040039
40 SkFont resolveFont(const SkSVGRenderContext&) const;
41
Florin Malita39fe8c82020-10-20 10:43:03 -040042 using INHERITED = SkSVGTransformableNode;
Florin Malitab3418102020-10-15 18:10:29 -040043};
44
45#endif // SkSVGText_DEFINED