Attaching ellipsis to emoji cluster

Bug: skia:10253
Change-Id: Id6b8507331facba4b69ebc96646a87c5e0eb6da9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290132
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
This commit is contained in:
Julia Lavrova 2020-05-15 14:54:39 -04:00 committed by Skia Commit-Bot
parent 56cde4923f
commit 3ea86251b9
2 changed files with 37 additions and 3 deletions

View File

@ -658,7 +658,9 @@ void TextLine::iterateThroughClustersInGlyphsOrder(bool reversed,
const ClustersVisitor& visitor) const {
// Walk through the clusters in the logical order (or reverse)
SkSpan<const size_t> runs(fRunsInVisualOrder.data(), fRunsInVisualOrder.size());
directional_for_each(runs, reversed, [&](decltype(runs[0]) r) {
bool ignore = false;
directional_for_each(runs, !reversed, [&](decltype(runs[0]) r) {
if (ignore) return;
auto run = this->fMaster->run(r);
auto trimmedRange = fClusterRange.intersection(run.clusterRange());
auto trailedRange = fGhostClusterRange.intersection(run.clusterRange());
@ -666,12 +668,10 @@ void TextLine::iterateThroughClustersInGlyphsOrder(bool reversed,
auto trailed = fMaster->clusters(trailedRange);
auto trimmed = fMaster->clusters(trimmedRange);
bool ignore = false;
directional_for_each(trailed, reversed != run.leftToRight(), [&](Cluster& cluster) {
if (ignore) return;
bool ghost = &cluster >= trimmed.end();
if (!includeGhosts && ghost) {
ignore = true;
return;
}
if (!visitor(&cluster, ghost)) {

View File

@ -2795,6 +2795,39 @@ private:
typedef Sample INHERITED;
};
class ParagraphView44 : public ParagraphView_Base {
protected:
SkString name() override { return SkString("Paragraph44"); }
void onDrawContent(SkCanvas* canvas) override {
const std::u16string text = u"The quick brown fox \U0001f98a ate a zesty ham burger fons \U0001f354."
"The \U0001f469\u200D\U0001f469\u200D\U0001f467\u200D\U0001f467 laughed.";
canvas->drawColor(SK_ColorWHITE);
auto fontCollection = sk_make_sp<FontCollection>();
fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
fontCollection->enableFontFallback();
ParagraphStyle paragraph_style;
paragraph_style.setMaxLines(7);
paragraph_style.setEllipsis(u"\u2026");
ParagraphBuilderImpl builder(paragraph_style, fontCollection);
TextStyle text_style;
text_style.setColor(SK_ColorBLACK);
text_style.setFontFamilies({SkString("Roboto"), SkString("Noto Color Emoji")});
text_style.setFontSize(60);
builder.pushStyle(text_style);
builder.addText(text);
auto paragraph = builder.Build();
paragraph->layout(305);//width());
paragraph->paint(canvas, 0, 0);
}
private:
typedef Sample INHERITED;
};
} // namespace
//////////////////////////////////////////////////////////////////////////////
@ -2839,3 +2872,4 @@ DEF_SAMPLE(return new ParagraphView39();)
DEF_SAMPLE(return new ParagraphView41();)
DEF_SAMPLE(return new ParagraphView42();)
DEF_SAMPLE(return new ParagraphView43();)
DEF_SAMPLE(return new ParagraphView44();)