[skottie] Initial direction for text shaping
Extend text properties to allow specifying an initial direction. Bug: skia:10946 Change-Id: Ia037aa060a4e2bb404cd50b0d6c8883ffe0ee38a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334677 Commit-Queue: Florin Malita <fmalita@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
cae335d5b1
commit
ebbacd8a37
@ -48,6 +48,7 @@ struct TextPropertyValue {
|
||||
Shaper::VAlign fVAlign = Shaper::VAlign::kTop;
|
||||
Shaper::ResizePolicy fResize = Shaper::ResizePolicy::kNone;
|
||||
Shaper::LinebreakPolicy fLineBreak = Shaper::LinebreakPolicy::kExplicit;
|
||||
Shaper::Direction fDirection = Shaper::Direction::kLTR;
|
||||
SkRect fBox = SkRect::MakeEmpty();
|
||||
SkColor fFillColor = SK_ColorTRANSPARENT,
|
||||
fStrokeColor = SK_ColorTRANSPARENT;
|
||||
|
@ -26,6 +26,7 @@ bool TextPropertyValue::operator==(const TextPropertyValue& other) const {
|
||||
&& fVAlign == other.fVAlign
|
||||
&& fResize == other.fResize
|
||||
&& fLineBreak == other.fLineBreak
|
||||
&& fDirection == other.fDirection
|
||||
&& fBox == other.fBox
|
||||
&& fFillColor == other.fFillColor
|
||||
&& fStrokeColor == other.fStrokeColor
|
||||
|
@ -324,6 +324,7 @@ DEF_TEST(Skottie_Properties, reporter) {
|
||||
Shaper::VAlign::kTopBaseline,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
Shaper::LinebreakPolicy::kExplicit,
|
||||
Shaper::Direction::kLTR,
|
||||
SkRect::MakeEmpty(),
|
||||
SK_ColorTRANSPARENT,
|
||||
SK_ColorTRANSPARENT,
|
||||
@ -476,6 +477,7 @@ DEF_TEST(Skottie_Shaper_HAlign, reporter) {
|
||||
Shaper::VAlign::kTopBaseline,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
Shaper::LinebreakPolicy::kExplicit,
|
||||
Shaper::Direction::kLTR,
|
||||
Shaper::Flags::kNone
|
||||
};
|
||||
|
||||
@ -544,6 +546,7 @@ DEF_TEST(Skottie_Shaper_VAlign, reporter) {
|
||||
talign.align,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
Shaper::LinebreakPolicy::kParagraph,
|
||||
Shaper::Direction::kLTR,
|
||||
Shaper::Flags::kNone
|
||||
};
|
||||
|
||||
@ -582,6 +585,7 @@ DEF_TEST(Skottie_Shaper_FragmentGlyphs, reporter) {
|
||||
Shaper::VAlign::kTop,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
Shaper::LinebreakPolicy::kParagraph,
|
||||
Shaper::Direction::kLTR,
|
||||
Shaper::Flags::kNone
|
||||
};
|
||||
|
||||
@ -678,6 +682,7 @@ DEF_TEST(Skottie_Shaper_ExplicitFontMgr, reporter) {
|
||||
Shaper::VAlign::kTop,
|
||||
Shaper::ResizePolicy::kNone,
|
||||
Shaper::LinebreakPolicy::kParagraph,
|
||||
Shaper::Direction::kLTR,
|
||||
Shaper::Flags::kNone
|
||||
};
|
||||
|
||||
|
@ -240,9 +240,10 @@ public:
|
||||
const auto shape_width = fDesc.fLinebreak == Shaper::LinebreakPolicy::kExplicit
|
||||
? SK_ScalarMax
|
||||
: fBox.width();
|
||||
const auto shape_ltr = fDesc.fDirection == Shaper::Direction::kLTR;
|
||||
|
||||
fUTF8 = start;
|
||||
fShaper->shape(start, SkToSizeT(end - start), fFont, true, shape_width, this);
|
||||
fShaper->shape(start, SkToSizeT(end - start), fFont, shape_ltr, shape_width, this);
|
||||
fUTF8 = nullptr;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,9 @@ public:
|
||||
kExplicit,
|
||||
};
|
||||
|
||||
// Initial text direction.
|
||||
enum class Direction : uint8_t { kLTR, kRTL };
|
||||
|
||||
enum Flags : uint32_t {
|
||||
kNone = 0x00,
|
||||
|
||||
@ -104,6 +107,7 @@ public:
|
||||
VAlign fVAlign;
|
||||
ResizePolicy fResize;
|
||||
LinebreakPolicy fLinebreak;
|
||||
Direction fDirection;
|
||||
uint32_t fFlags;
|
||||
};
|
||||
|
||||
|
@ -276,6 +276,7 @@ void TextAdapter::reshape() {
|
||||
fText->fVAlign,
|
||||
fText->fResize,
|
||||
fText->fLineBreak,
|
||||
fText->fDirection,
|
||||
this->shaperFlags(),
|
||||
};
|
||||
const auto shape_result = Shaper::Shape(fText->fText, text_desc, fText->fBox, fFontMgr);
|
||||
|
Loading…
Reference in New Issue
Block a user