Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 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 | |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 11 | #include "include/utils/SkTextUtils.h" |
Florin Malita | 39fe8c8 | 2020-10-20 10:43:03 -0400 | [diff] [blame] | 12 | #include "modules/svg/include/SkSVGTransformableNode.h" |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 13 | #include "modules/svg/include/SkSVGTypes.h" |
| 14 | |
| 15 | class SkRRect; |
| 16 | |
Florin Malita | 39fe8c8 | 2020-10-20 10:43:03 -0400 | [diff] [blame] | 17 | class SkSVGText final : public SkSVGTransformableNode { |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 18 | public: |
| 19 | ~SkSVGText() override = default; |
| 20 | static sk_sp<SkSVGText> Make() { |
| 21 | return sk_sp<SkSVGText>(new SkSVGText()); } |
| 22 | |
Florin Malita | 056385b | 2020-10-27 22:57:56 -0400 | [diff] [blame] | 23 | SVG_ATTR(X , SkSVGLength , SkSVGLength(0)) |
| 24 | SVG_ATTR(Y , SkSVGLength , SkSVGLength(0)) |
| 25 | SVG_ATTR(Text, SkSVGStringType, SkSVGStringType()) |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 26 | |
| 27 | protected: |
| 28 | void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override; |
| 29 | |
Florin Malita | 39fe8c8 | 2020-10-20 10:43:03 -0400 | [diff] [blame] | 30 | void onRender(const SkSVGRenderContext&) const override; |
| 31 | void appendChild(sk_sp<SkSVGNode>) override; |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 32 | |
| 33 | SkPath onAsPath(const SkSVGRenderContext&) const override; |
| 34 | |
| 35 | void loadFont(); |
| 36 | |
| 37 | private: |
| 38 | SkSVGText(); |
Florin Malita | 39fe8c8 | 2020-10-20 10:43:03 -0400 | [diff] [blame] | 39 | |
| 40 | SkFont resolveFont(const SkSVGRenderContext&) const; |
| 41 | |
Florin Malita | 39fe8c8 | 2020-10-20 10:43:03 -0400 | [diff] [blame] | 42 | using INHERITED = SkSVGTransformableNode; |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | #endif // SkSVGText_DEFINED |