Lines ending with hard line breaks should not be justified
Bug: skia:10036
Change-Id: I4f1a41b3497bccb9e5f4b97163113b9241128bfd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288129
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
diff --git a/samplecode/SampleParagraph.cpp b/samplecode/SampleParagraph.cpp
index 0c127e9..908c662 100644
--- a/samplecode/SampleParagraph.cpp
+++ b/samplecode/SampleParagraph.cpp
@@ -2600,6 +2600,42 @@
typedef Sample INHERITED;
};
+class ParagraphView39 : public ParagraphView_Base {
+protected:
+ SkString name() override { return SkString("Paragraph39"); }
+
+ void onDrawContent(SkCanvas* canvas) override {
+
+ canvas->drawColor(SK_ColorWHITE);
+
+ auto fontCollection = sk_make_sp<FontCollection>();
+ fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
+ fontCollection->enableFontFallback();
+
+ ParagraphStyle paragraph_style;
+ paragraph_style.setTextAlign(TextAlign::kJustify);
+ ParagraphBuilderImpl builder(paragraph_style, fontCollection);
+ TextStyle text_style;
+ text_style.setColor(SK_ColorBLACK);
+ text_style.setFontFamilies({SkString("Roboto")});
+ text_style.setFontSize(40);
+ builder.pushStyle(text_style);
+ builder.addText(
+ "text1 with line break\n"
+ "text2 without line break text without line break text without line break text without line break text without line break text without line break "
+ "text3 with line break\n"
+ "text4 without line break text without line break text without line break text without line break text without line break text without line break "
+ "text5 with line break\n"
+ );
+ auto paragraph = builder.Build();
+ paragraph->layout(width());
+ paragraph->paint(canvas, 0, 0);
+ }
+
+private:
+ typedef Sample INHERITED;
+};
+
//////////////////////////////////////////////////////////////////////////////
DEF_SAMPLE(return new ParagraphView1();)
DEF_SAMPLE(return new ParagraphView2();)
@@ -2638,3 +2674,4 @@
DEF_SAMPLE(return new ParagraphView36();)
DEF_SAMPLE(return new ParagraphView37();)
DEF_SAMPLE(return new ParagraphView38();)
+DEF_SAMPLE(return new ParagraphView39();)