[svg] Parse text attributes
Convert font-family, font-size, font-style and font-weight to
presentation attributes, and add parsing utils.
Bug: skia:10840
Change-Id: I1acdb59bc95fe46e67ed0f499dd0732420016663
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328436
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
diff --git a/modules/svg/include/SkSVGText.h b/modules/svg/include/SkSVGText.h
index 9336f73..55716cd 100644
--- a/modules/svg/include/SkSVGText.h
+++ b/modules/svg/include/SkSVGText.h
@@ -10,12 +10,12 @@
#include "include/core/SkFont.h"
#include "include/utils/SkTextUtils.h"
-#include "modules/svg/include/SkSVGShape.h"
+#include "modules/svg/include/SkSVGTransformableNode.h"
#include "modules/svg/include/SkSVGTypes.h"
class SkRRect;
-class SkSVGText final : public SkSVGShape {
+class SkSVGText final : public SkSVGTransformableNode {
public:
~SkSVGText() override = default;
static sk_sp<SkSVGText> Make() {
@@ -23,18 +23,14 @@
void setX(const SkSVGLength&);
void setY(const SkSVGLength&);
- void setFontFamily(const SkSVGStringType&);
- void setFontSize(const SkSVGLength&);
- void setFontStyle(const SkSVGStringType&);
- void setFontWeight(const SkSVGStringType&);
void setText(const SkSVGStringType&);
void setTextAnchor(const SkSVGStringType&);
protected:
void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
- void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
- SkPathFillType) const override;
+ void onRender(const SkSVGRenderContext&) const override;
+ void appendChild(sk_sp<SkSVGNode>) override;
SkPath onAsPath(const SkSVGRenderContext&) const override;
@@ -42,16 +38,16 @@
private:
SkSVGText();
- SkSVGLength fX = SkSVGLength(0);
- SkSVGLength fY = SkSVGLength(0);
- SkSVGStringType fText;
- sk_sp<SkTypeface> fTypeface;
- SkSVGLength fFontSize;
- SkSVGStringType fFontFamily;
- SkSVGStringType fFontStyle;
- SkSVGStringType fFontWeight;
+
+ SkFont resolveFont(const SkSVGRenderContext&) const;
+
+ SkSVGLength fX = SkSVGLength(0);
+ SkSVGLength fY = SkSVGLength(0);
+ SkSVGStringType fText;
+ sk_sp<SkTypeface> fTypeface;
SkTextUtils::Align fTextAlign = SkTextUtils::Align::kLeft_Align;
- using INHERITED = SkSVGShape;
+
+ using INHERITED = SkSVGTransformableNode;
};
#endif // SkSVGText_DEFINED