diff --git a/modules/skparagraph/src/TextLine.cpp b/modules/skparagraph/src/TextLine.cpp index ce9b1a9795..c8be2adc25 100644 --- a/modules/skparagraph/src/TextLine.cpp +++ b/modules/skparagraph/src/TextLine.cpp @@ -658,7 +658,9 @@ void TextLine::iterateThroughClustersInGlyphsOrder(bool reversed, const ClustersVisitor& visitor) const { // Walk through the clusters in the logical order (or reverse) SkSpan 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)) { diff --git a/samplecode/SampleParagraph.cpp b/samplecode/SampleParagraph.cpp index c4fd8c8683..f4c0888639 100644 --- a/samplecode/SampleParagraph.cpp +++ b/samplecode/SampleParagraph.cpp @@ -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->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();)