[skottie] Improved text rendering
* enable antialiasing
* enable subpixel positioning
* disable hinting
Change-Id: I7e861d9141411f64a9277ff6c3345c107c0868b2
Reviewed-on: https://skia-review.googlesource.com/148980
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/modules/skottie/src/SkottieTextLayer.cpp b/modules/skottie/src/SkottieTextLayer.cpp
index 622fabf..d39f57d 100644
--- a/modules/skottie/src/SkottieTextLayer.cpp
+++ b/modules/skottie/src/SkottieTextLayer.cpp
@@ -292,8 +292,12 @@
// [Text]
//
auto text_node = sksg::Text::Make(font->fTypeface, SkString(text->begin(), text->size()));
+ text_node->setFlags(text_node->getFlags() |
+ SkPaint::kAntiAlias_Flag |
+ SkPaint::kSubpixelText_Flag);
text_node->setSize(**text_size);
text_node->setAlign(align);
+ text_node->setHinting(SkPaint::kNo_Hinting);
const auto parse_color = [](const skjson::ArrayValue* jcolor) -> sk_sp<sksg::Color> {
VectorValue color_vec;
@@ -302,7 +306,6 @@
}
auto paint = sksg::Color::Make(ValueTraits<VectorValue>::As<SkColor>(color_vec));
- paint->setAntiAlias(true);
return paint;
};
diff --git a/modules/sksg/include/SkSGText.h b/modules/sksg/include/SkSGText.h
index c1df888..8e1d79e 100644
--- a/modules/sksg/include/SkSGText.h
+++ b/modules/sksg/include/SkSGText.h
@@ -29,13 +29,14 @@
static sk_sp<Text> Make(sk_sp<SkTypeface> tf, const SkString& text);
~Text() override;
- SG_ATTRIBUTE(Text , SkString , fText )
- SG_ATTRIBUTE(Flags , uint32_t , fFlags )
- SG_ATTRIBUTE(Position, SkPoint , fPosition)
- SG_ATTRIBUTE(Size , SkScalar , fSize )
- SG_ATTRIBUTE(ScaleX , SkScalar , fScaleX )
- SG_ATTRIBUTE(SkewX , SkScalar , fSkewX )
- SG_ATTRIBUTE(Align , SkPaint::Align, fAlign )
+ SG_ATTRIBUTE(Text , SkString , fText )
+ SG_ATTRIBUTE(Flags , uint32_t , fFlags )
+ SG_ATTRIBUTE(Position, SkPoint , fPosition)
+ SG_ATTRIBUTE(Size , SkScalar , fSize )
+ SG_ATTRIBUTE(ScaleX , SkScalar , fScaleX )
+ SG_ATTRIBUTE(SkewX , SkScalar , fSkewX )
+ SG_ATTRIBUTE(Align , SkPaint::Align , fAlign )
+ SG_ATTRIBUTE(Hinting , SkPaint::Hinting, fHinting )
// TODO: add shaping functionality.