blob: aaf91fda4746b056f28c802aa82e42dc01f7234b [file] [log] [blame]
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001// Copyright 2019 Google LLC.
Julia Lavrovaa3552c52019-05-30 16:12:56 -04002#include "include/core/SkCanvas.h"
3#include "include/core/SkColorFilter.h"
4#include "include/core/SkColorPriv.h"
Julia Lavrovacd2d4e42020-03-27 15:40:37 -04005#include "include/core/SkFontMgr.h"
Julia Lavrovaa3552c52019-05-30 16:12:56 -04006#include "include/core/SkGraphics.h"
7#include "include/core/SkPath.h"
8#include "include/core/SkRegion.h"
9#include "include/core/SkShader.h"
10#include "include/core/SkStream.h"
11#include "include/core/SkTextBlob.h"
12#include "include/core/SkTime.h"
13#include "include/core/SkTypeface.h"
Julia Lavrovaa3552c52019-05-30 16:12:56 -040014#include "include/effects/SkGradientShader.h"
15#include "include/utils/SkRandom.h"
16#include "modules/skparagraph/include/Paragraph.h"
Julia Lavrova6e6333f2019-06-17 10:34:10 -040017#include "modules/skparagraph/include/TypefaceFontProvider.h"
Julia Lavrovaa3552c52019-05-30 16:12:56 -040018#include "modules/skparagraph/src/ParagraphBuilderImpl.h"
19#include "modules/skparagraph/src/ParagraphImpl.h"
Julia Lavrova9af5cc42019-06-19 13:32:01 -040020#include "modules/skparagraph/utils/TestFontCollection.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040021#include "samplecode/Sample.h"
Julia Lavrovaa3552c52019-05-30 16:12:56 -040022#include "src/core/SkOSFile.h"
23#include "src/shaders/SkColorShader.h"
Julia Lavrova2e30fde2019-10-09 09:43:02 -040024#include "src/utils/SkOSPath.h"
Julia Lavrovaa3552c52019-05-30 16:12:56 -040025#include "src/utils/SkUTF.h"
26#include "tools/Resources.h"
27
28using namespace skia::textlayout;
29namespace {
30
Mike Reed21a940d2019-07-23 10:11:03 -040031class ParagraphView_Base : public Sample {
32protected:
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -040033 sk_sp<TestFontCollection> getFontCollection() {
34 // If we reset font collection we need to reset paragraph cache
35 static sk_sp<TestFontCollection> fFC = nullptr;
36 if (fFC == nullptr) {
Julia Lavrova2e30fde2019-10-09 09:43:02 -040037 fFC = sk_make_sp<TestFontCollection>(GetResourcePath("fonts").c_str(), false, true);
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -040038 }
39 return fFC;
Mike Reed21a940d2019-07-23 10:11:03 -040040 }
41};
42
Julia Lavrovaa3552c52019-05-30 16:12:56 -040043sk_sp<SkShader> setgrad(const SkRect& r, SkColor c0, SkColor c1) {
44 SkColor colors[] = {c0, c1};
45 SkPoint pts[] = {{r.fLeft, r.fTop}, {r.fRight, r.fTop}};
46 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkTileMode::kClamp);
47}
Julia Lavrova2e30fde2019-10-09 09:43:02 -040048/*
49void writeHtml(const char* name, Paragraph* paragraph) {
50 SkString tmpDir = skiatest::GetTmpDir();
51 if (!tmpDir.isEmpty()) {
52 SkString path = SkOSPath::Join(tmpDir.c_str(), name);
53 SkFILEWStream file(path.c_str());
54 file.write(nullptr, 0);
55 }
56}
57*/
Julia Lavrovaa3552c52019-05-30 16:12:56 -040058} // namespace
59
Mike Reed21a940d2019-07-23 10:11:03 -040060class ParagraphView1 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -040061protected:
Hal Canary8a027312019-07-03 10:55:44 -040062 SkString name() override { return SkString("Paragraph1"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -040063
64 void drawTest(SkCanvas* canvas, SkScalar w, SkScalar h, SkColor fg, SkColor bg) {
65 const std::vector<
66 std::tuple<std::string, bool, bool, int, SkColor, SkColor, bool, TextDecorationStyle>>
67 gParagraph = {{"monospace", true, false, 14, SK_ColorWHITE, SK_ColorRED, true,
68 TextDecorationStyle::kDashed},
69 {"Assyrian", false, false, 20, SK_ColorWHITE, SK_ColorBLUE, false,
70 TextDecorationStyle::kDotted},
71 {"serif", true, true, 10, SK_ColorWHITE, SK_ColorRED, true,
72 TextDecorationStyle::kDouble},
73 {"Arial", false, true, 16, SK_ColorGRAY, SK_ColorGREEN, true,
74 TextDecorationStyle::kSolid},
75 {"sans-serif", false, false, 8, SK_ColorWHITE, SK_ColorRED, false,
76 TextDecorationStyle::kWavy}};
77 SkAutoCanvasRestore acr(canvas, true);
78
79 canvas->clipRect(SkRect::MakeWH(w, h));
80 canvas->drawColor(SK_ColorWHITE);
81
82 SkScalar margin = 20;
83
84 SkPaint paint;
85 paint.setAntiAlias(true);
86 paint.setColor(fg);
87
88 SkPaint blue;
89 blue.setColor(SK_ColorBLUE);
90
91 TextStyle defaultStyle;
92 defaultStyle.setBackgroundColor(blue);
93 defaultStyle.setForegroundColor(paint);
94 ParagraphStyle paraStyle;
95
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -040096 auto fontCollection = sk_make_sp<FontCollection>();
97 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
Julia Lavrovaa3552c52019-05-30 16:12:56 -040098 for (auto i = 1; i < 5; ++i) {
99 defaultStyle.setFontSize(24 * i);
100 paraStyle.setTextStyle(defaultStyle);
Julia Lavrova5207f352019-06-21 12:22:32 -0400101 ParagraphBuilderImpl builder(paraStyle, fontCollection);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400102 std::string name = "Paragraph: " + std::to_string(24 * i);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400103 builder.addText(name.c_str(), name.length());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400104 for (auto para : gParagraph) {
105 TextStyle style;
106 style.setFontFamilies({SkString(std::get<0>(para).c_str())});
107 SkFontStyle fontStyle(std::get<1>(para) ? SkFontStyle::Weight::kBold_Weight
108 : SkFontStyle::Weight::kNormal_Weight,
109 SkFontStyle::Width::kNormal_Width,
110 std::get<2>(para) ? SkFontStyle::Slant::kItalic_Slant
111 : SkFontStyle::Slant::kUpright_Slant);
112 style.setFontStyle(fontStyle);
113 style.setFontSize(std::get<3>(para) * i);
114 SkPaint background;
115 background.setColor(std::get<4>(para));
116 style.setBackgroundColor(background);
117 SkPaint foreground;
118 foreground.setColor(std::get<5>(para));
119 foreground.setAntiAlias(true);
120 style.setForegroundColor(foreground);
121 if (std::get<6>(para)) {
122 style.addShadow(TextShadow(SK_ColorBLACK, SkPoint::Make(5, 5), 2));
123 }
124
125 auto decoration = (i % 4);
126 if (decoration == 3) {
127 decoration = 4;
128 }
129
130 bool test = (TextDecoration)decoration != TextDecoration::kNoDecoration;
131 std::string deco = std::to_string((int)decoration);
132 if (test) {
133 style.setDecoration((TextDecoration)decoration);
134 style.setDecorationStyle(std::get<7>(para));
135 style.setDecorationColor(std::get<5>(para));
136 }
137 builder.pushStyle(style);
138 std::string name = " " + std::get<0>(para) + " " +
139 (std::get<1>(para) ? ", bold" : "") +
140 (std::get<2>(para) ? ", italic" : "") + " " +
141 std::to_string(std::get<3>(para) * i) +
142 (std::get<4>(para) != bg ? ", background" : "") +
143 (std::get<5>(para) != fg ? ", foreground" : "") +
144 (std::get<6>(para) ? ", shadow" : "") +
145 (test ? ", decorations " + deco : "") + ";";
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400146 builder.addText(name.c_str(), name.length());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400147 builder.pop();
148 }
149
150 auto paragraph = builder.Build();
151 paragraph->layout(w - margin * 2);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400152 paragraph->paint(canvas, margin, margin);
153
154 canvas->translate(0, paragraph->getHeight());
155 }
156 }
157
158 void onDrawContent(SkCanvas* canvas) override {
159 drawTest(canvas, this->width(), this->height(), SK_ColorRED, SK_ColorWHITE);
160 }
161
162private:
163
164 typedef Sample INHERITED;
165};
166
Mike Reed21a940d2019-07-23 10:11:03 -0400167class ParagraphView2 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400168protected:
Hal Canary8a027312019-07-03 10:55:44 -0400169 SkString name() override { return SkString("Paragraph2"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400170
171 void drawCode(SkCanvas* canvas, SkScalar w, SkScalar h) {
172 SkPaint comment;
173 comment.setColor(SK_ColorGRAY);
174 SkPaint constant;
175 constant.setColor(SK_ColorMAGENTA);
176 SkPaint null;
177 null.setColor(SK_ColorMAGENTA);
178 SkPaint literal;
179 literal.setColor(SK_ColorGREEN);
180 SkPaint code;
181 code.setColor(SK_ColorDKGRAY);
182 SkPaint number;
183 number.setColor(SK_ColorBLUE);
184 SkPaint name;
185 name.setColor(SK_ColorRED);
186
187 SkPaint white;
188 white.setColor(SK_ColorWHITE);
189
190 TextStyle defaultStyle;
191 defaultStyle.setBackgroundColor(white);
192 defaultStyle.setForegroundColor(code);
193 defaultStyle.setFontFamilies({SkString("monospace")});
194 defaultStyle.setFontSize(30);
195 ParagraphStyle paraStyle;
196 paraStyle.setTextStyle(defaultStyle);
197
Julia Lavrova5207f352019-06-21 12:22:32 -0400198 auto fontCollection = sk_make_sp<FontCollection>();
199 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
200 ParagraphBuilderImpl builder(paraStyle, fontCollection);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400201
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400202 const char* text1 = "RaisedButton";
203 const char* text2 = "(\n";
204 const char* text3 = " child: ";
205 const char* text4 = "const";
206 const char* text5 = "Text";
207 const char* text6 = "'BUTTON TITLE'";
208 const char* text7 = "),\n";
209
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400210 builder.pushStyle(style(name));
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400211 builder.addText(text1, strlen(text1));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400212 builder.pop();
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400213 builder.addText(text2, strlen(text2));
214 builder.addText(text3, strlen(text3));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400215 builder.pushStyle(style(constant));
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400216 builder.addText(text4, strlen(text4));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400217 builder.pop();
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400218 builder.addText(" ", 1);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400219 builder.pushStyle(style(name));
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400220 builder.addText(text5, strlen(text5));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400221 builder.pop();
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400222 builder.addText("(", 1);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400223 builder.pushStyle(style(literal));
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400224 builder.addText(text6, strlen(text6));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400225 builder.pop();
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400226 builder.addText(text7, strlen(text7));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400227
228 auto paragraph = builder.Build();
229 paragraph->layout(w - 20);
230
231 paragraph->paint(canvas, 20, 20);
232 }
233
234 TextStyle style(SkPaint paint) {
235 TextStyle style;
236 paint.setAntiAlias(true);
237 style.setForegroundColor(paint);
238 style.setFontFamilies({SkString("monospace")});
239 style.setFontSize(30);
240
241 return style;
242 }
243
Julia Lavrova5207f352019-06-21 12:22:32 -0400244 void drawText(SkCanvas* canvas, SkScalar w, SkScalar h, std::vector<const char*>& text,
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400245 SkColor fg = SK_ColorDKGRAY, SkColor bg = SK_ColorWHITE,
246 const char* ff = "sans-serif", SkScalar fs = 24,
247 size_t lineLimit = 30,
248 const std::u16string& ellipsis = u"\u2026") {
249 SkAutoCanvasRestore acr(canvas, true);
250
251 canvas->clipRect(SkRect::MakeWH(w, h));
252 canvas->drawColor(bg);
253
254 SkScalar margin = 20;
255
256 SkPaint paint;
257 paint.setAntiAlias(true);
258 paint.setColor(fg);
259
260 SkPaint blue;
261 blue.setColor(SK_ColorBLUE);
262
263 SkPaint background;
264 background.setColor(bg);
265
266 TextStyle style;
267 style.setBackgroundColor(blue);
268 style.setForegroundColor(paint);
269 style.setFontFamilies({SkString(ff)});
270 style.setFontStyle(SkFontStyle(SkFontStyle::kMedium_Weight,
271 SkFontStyle::kNormal_Width,
272 SkFontStyle::kUpright_Slant));
273 style.setFontSize(fs);
274 ParagraphStyle paraStyle;
275 paraStyle.setTextStyle(style);
276 paraStyle.setMaxLines(lineLimit);
277
278 paraStyle.setEllipsis(ellipsis);
279 TextStyle defaultStyle;
280 defaultStyle.setFontSize(20);
281 paraStyle.setTextStyle(defaultStyle);
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -0400282 ParagraphBuilderImpl builder(paraStyle, getFontCollection());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400283
284 SkPaint foreground;
285 foreground.setColor(fg);
286 style.setForegroundColor(foreground);
287 style.setBackgroundColor(background);
288
289 for (auto& part : text) {
290 builder.pushStyle(style);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400291 builder.addText(part, strlen(part));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400292 builder.pop();
293 }
294
295 auto paragraph = builder.Build();
296 paragraph->layout(w - margin * 2);
297 paragraph->paint(canvas, margin, margin);
298
299 canvas->translate(0, paragraph->getHeight() + margin);
300 }
301
302 void drawLine(SkCanvas* canvas, SkScalar w, SkScalar h, const std::string& text,
303 TextAlign align) {
304 SkAutoCanvasRestore acr(canvas, true);
305
306 canvas->clipRect(SkRect::MakeWH(w, h));
307 canvas->drawColor(SK_ColorWHITE);
308
309 SkScalar margin = 20;
310
311 SkPaint paint;
312 paint.setAntiAlias(true);
313 paint.setColor(SK_ColorBLUE);
314
315 SkPaint gray;
316 gray.setColor(SK_ColorLTGRAY);
317
318 TextStyle style;
319 style.setBackgroundColor(gray);
320 style.setForegroundColor(paint);
321 style.setFontFamilies({SkString("Arial")});
322 style.setFontSize(30);
323 ParagraphStyle paraStyle;
324 paraStyle.setTextStyle(style);
325 paraStyle.setTextAlign(align);
326
Julia Lavrova5207f352019-06-21 12:22:32 -0400327 auto fontCollection = sk_make_sp<FontCollection>();
328 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
329 ParagraphBuilderImpl builder(paraStyle, fontCollection);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400330 builder.addText(text.c_str(), text.length());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400331
332 auto paragraph = builder.Build();
333 paragraph->layout(w - margin * 2);
334 paragraph->layout(w - margin);
335 paragraph->paint(canvas, margin, margin);
336
337 canvas->translate(0, paragraph->getHeight() + margin);
338 }
339
340 void onDrawContent(SkCanvas* canvas) override {
Julia Lavrova5207f352019-06-21 12:22:32 -0400341 std::vector<const char*> cupertino = {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400342 "google_logogoogle_gsuper_g_logo 1 "
343 "google_logogoogle_gsuper_g_logo 12 "
344 "google_logogoogle_gsuper_g_logo 123 "
345 "google_logogoogle_gsuper_g_logo 1234 "
346 "google_logogoogle_gsuper_g_logo 12345 "
347 "google_logogoogle_gsuper_g_logo 123456 "
348 "google_logogoogle_gsuper_g_logo 1234567 "
349 "google_logogoogle_gsuper_g_logo 12345678 "
350 "google_logogoogle_gsuper_g_logo 123456789 "
351 "google_logogoogle_gsuper_g_logo 1234567890 "
352 "google_logogoogle_gsuper_g_logo 123456789 "
353 "google_logogoogle_gsuper_g_logo 12345678 "
354 "google_logogoogle_gsuper_g_logo 1234567 "
355 "google_logogoogle_gsuper_g_logo 123456 "
356 "google_logogoogle_gsuper_g_logo 12345 "
357 "google_logogoogle_gsuper_g_logo 1234 "
358 "google_logogoogle_gsuper_g_logo 123 "
359 "google_logogoogle_gsuper_g_logo 12 "
360 "google_logogoogle_gsuper_g_logo 1 "
361 "google_logogoogle_gsuper_g_logo "
362 "google_logogoogle_gsuper_g_logo "
363 "google_logogoogle_gsuper_g_logo "
364 "google_logogoogle_gsuper_g_logo "
365 "google_logogoogle_gsuper_g_logo "
366 "google_logogoogle_gsuper_g_logo"};
Julia Lavrova5207f352019-06-21 12:22:32 -0400367 std::vector<const char*> text = {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400368 "My neighbor came over to say,\n"
369 "Although not in a neighborly way,\n\n"
370 "That he'd knock me around,\n\n\n"
371 "If I didn't stop the sound,\n\n\n\n"
372 "Of the classical music I play."};
373
Julia Lavrova5207f352019-06-21 12:22:32 -0400374 std::vector<const char*> long_word = {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400375 "A_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_"
376 "very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_"
377 "very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_very_"
378 "very_very_very_very_very_very_very_long_text"};
379
Julia Lavrova5207f352019-06-21 12:22:32 -0400380 std::vector<const char*> very_long = {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400381 "A very very very very very very very very very very very very very very very very "
382 "very very very very very very very very very very very very very very very very "
383 "very very very very very very very very very very very very very very very very "
384 "very very very very very very very long text"};
385
Julia Lavrova5207f352019-06-21 12:22:32 -0400386 std::vector<const char*> very_word = {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400387 "A very_very_very_very_very_very_very_very_very_very "
388 "very_very_very_very_very_very_very_very_very_very very very very very very very "
389 "very very very very very very very very very very very very very very very very "
390 "very very very very very very very very very very very very very long text"};
391
392 SkScalar width = this->width() / 5;
393 SkScalar height = this->height();
394 drawText(canvas, width, height, long_word, SK_ColorBLACK, SK_ColorWHITE, "Google Sans", 30);
395 canvas->translate(width, 0);
396 drawText(canvas, width, height, very_long, SK_ColorBLACK, SK_ColorWHITE, "Google Sans", 30);
397 canvas->translate(width, 0);
398 drawText(canvas, width, height, very_word, SK_ColorBLACK, SK_ColorWHITE, "Google Sans", 30);
399 canvas->translate(width, 0);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400400 drawText(canvas, width, height / 2, text, SK_ColorBLACK, SK_ColorWHITE, "Roboto", 20, 100,
401 u"\u2026");
402 canvas->translate(0, height / 2);
403 drawCode(canvas, width, height / 2);
404 canvas->translate(width, -height / 2);
405
406 drawText(canvas, width, height, cupertino, SK_ColorBLACK, SK_ColorWHITE, "Google Sans", 30);
407 }
408
409private:
410 typedef Sample INHERITED;
411};
412
Mike Reed21a940d2019-07-23 10:11:03 -0400413class ParagraphView3 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400414protected:
Hal Canary8a027312019-07-03 10:55:44 -0400415 SkString name() override { return SkString("Paragraph3"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400416
417 void drawLine(SkCanvas* canvas, SkScalar w, SkScalar h, const std::string& text,
418 TextAlign align, size_t lineLimit = std::numeric_limits<size_t>::max(),
419 bool RTL = false, SkColor background = SK_ColorGRAY,
420 const std::u16string& ellipsis = u"\u2026") {
421 SkAutoCanvasRestore acr(canvas, true);
422
423 canvas->clipRect(SkRect::MakeWH(w, h));
424 canvas->drawColor(SK_ColorWHITE);
425
426 SkScalar margin = 20;
427
428 SkPaint paint;
429 paint.setAntiAlias(true);
430 paint.setColor(SK_ColorBLACK);
431
432 SkPaint gray;
433 gray.setColor(background);
434
435 SkPaint yellow;
436 yellow.setColor(SK_ColorYELLOW);
437
438 TextStyle style;
439 style.setBackgroundColor(gray);
440 style.setForegroundColor(paint);
441 style.setFontFamilies({SkString("sans-serif")});
442 style.setFontSize(30);
443 ParagraphStyle paraStyle;
444 paraStyle.setTextStyle(style);
445 paraStyle.setTextAlign(align);
446 paraStyle.setMaxLines(lineLimit);
447 paraStyle.setEllipsis(ellipsis);
448 // paraStyle.setTextDirection(RTL ? SkTextDirection::rtl : SkTextDirection::ltr);
449
Julia Lavrova5207f352019-06-21 12:22:32 -0400450 auto fontCollection = sk_make_sp<FontCollection>();
451 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
452 ParagraphBuilderImpl builder(paraStyle, fontCollection);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400453 if (RTL) {
454 builder.addText(mirror(text));
455 } else {
456 builder.addText(normal(text));
457 }
458
459 canvas->drawRect(SkRect::MakeXYWH(margin, margin, w - margin * 2, h - margin * 2), yellow);
460 auto paragraph = builder.Build();
461 paragraph->layout(w - margin * 2);
462 paragraph->paint(canvas, margin, margin);
463 }
464
465 std::u16string mirror(const std::string& text) {
466 std::u16string result;
467 result += u"\u202E";
468 // for (auto i = text.size(); i > 0; --i) {
469 // result += text[i - 1];
470 //}
471
472 for (auto i = text.size(); i > 0; --i) {
473 auto ch = text[i - 1];
474 if (ch == ',') {
475 result += u"!";
476 } else if (ch == '.') {
477 result += u"!";
478 } else {
479 result += ch;
480 }
481 }
482
483 result += u"\u202C";
484 return result;
485 }
486
487 std::u16string normal(const std::string& text) {
488 std::u16string result;
489 result += u"\u202D";
490 for (auto ch : text) {
491 result += ch;
492 }
493 result += u"\u202C";
494 return result;
495 }
496
497 void onDrawContent(SkCanvas* canvas) override {
498 const std::string options = // { "open-source open-source open-source open-source" };
499 {"Flutter is an open-source project to help developers "
500 "build high-performance, high-fidelity, mobile apps for "
501 "iOS and Android "
502 "from a single codebase. This design lab is a playground "
503 "and showcase of Flutter's many widgets, behaviors, "
504 "animations, layouts, and more."};
505
506 canvas->drawColor(SK_ColorDKGRAY);
507 SkScalar width = this->width() / 4;
508 SkScalar height = this->height() / 2;
509
510 const std::string line =
511 "World domination is such an ugly phrase - I prefer to call it world optimisation";
512
513 drawLine(canvas, width, height, line, TextAlign::kLeft, 1, false, SK_ColorLTGRAY);
514 canvas->translate(width, 0);
515 drawLine(canvas, width, height, line, TextAlign::kRight, 2, false, SK_ColorLTGRAY);
516 canvas->translate(width, 0);
517 drawLine(canvas, width, height, line, TextAlign::kCenter, 3, false, SK_ColorLTGRAY);
518 canvas->translate(width, 0);
519 drawLine(canvas, width, height, line, TextAlign::kJustify, 4, false, SK_ColorLTGRAY);
520 canvas->translate(-width * 3, height);
521
522 drawLine(canvas, width, height, line, TextAlign::kLeft, 1, true, SK_ColorLTGRAY);
523 canvas->translate(width, 0);
524 drawLine(canvas, width, height, line, TextAlign::kRight, 2, true, SK_ColorLTGRAY);
525 canvas->translate(width, 0);
526 drawLine(canvas, width, height, line, TextAlign::kCenter, 3, true, SK_ColorLTGRAY);
527 canvas->translate(width, 0);
528 drawLine(canvas, width, height, line, TextAlign::kJustify, 4, true, SK_ColorLTGRAY);
529 canvas->translate(width, 0);
530 }
531
532private:
533 typedef Sample INHERITED;
534};
535
Mike Reed21a940d2019-07-23 10:11:03 -0400536class ParagraphView4 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400537protected:
Hal Canary8a027312019-07-03 10:55:44 -0400538 SkString name() override { return SkString("Paragraph4"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400539
540 void drawFlutter(SkCanvas* canvas, SkScalar w, SkScalar h,
541 const char* ff = "Google Sans", SkScalar fs = 30,
542 size_t lineLimit = std::numeric_limits<size_t>::max(),
543 const std::u16string& ellipsis = u"\u2026") {
544 SkAutoCanvasRestore acr(canvas, true);
545
546 canvas->clipRect(SkRect::MakeWH(w, h));
547
548 SkScalar margin = 20;
549
550 SkPaint black;
551 black.setAntiAlias(true);
552 black.setColor(SK_ColorBLACK);
553
554 SkPaint blue;
555 blue.setAntiAlias(true);
556 blue.setColor(SK_ColorBLUE);
557
558 SkPaint red;
559 red.setAntiAlias(true);
560 red.setColor(SK_ColorRED);
561
562 SkPaint green;
563 green.setAntiAlias(true);
564 green.setColor(SK_ColorGREEN);
565
566 SkPaint gray;
567 gray.setColor(SK_ColorLTGRAY);
568
569 SkPaint yellow;
570 yellow.setColor(SK_ColorYELLOW);
571
572 SkPaint magenta;
573 magenta.setAntiAlias(true);
574 magenta.setColor(SK_ColorMAGENTA);
575
576 TextStyle style;
577 style.setFontFamilies({SkString(ff)});
578 style.setFontSize(fs);
579
580 TextStyle style0;
581 style0.setForegroundColor(black);
582 style0.setBackgroundColor(gray);
583 style0.setFontFamilies({SkString(ff)});
584 style0.setFontSize(fs);
585 style0.setDecoration(TextDecoration::kUnderline);
586 style0.setDecorationStyle(TextDecorationStyle::kDouble);
587 style0.setDecorationColor(SK_ColorBLACK);
588
589 TextStyle style1;
590 style1.setForegroundColor(blue);
591 style1.setBackgroundColor(yellow);
592 style1.setFontFamilies({SkString(ff)});
593 style1.setFontSize(fs);
594 style1.setDecoration(TextDecoration::kOverline);
595 style1.setDecorationStyle(TextDecorationStyle::kWavy);
596 style1.setDecorationColor(SK_ColorBLACK);
597
598 TextStyle style2;
599 style2.setForegroundColor(red);
600 style2.setFontFamilies({SkString(ff)});
601 style2.setFontSize(fs);
602
603 TextStyle style3;
604 style3.setForegroundColor(green);
605 style3.setFontFamilies({SkString(ff)});
606 style3.setFontSize(fs);
607
608 TextStyle style4;
609 style4.setForegroundColor(magenta);
610 style4.setFontFamilies({SkString(ff)});
611 style4.setFontSize(fs);
612
613 ParagraphStyle paraStyle;
614 paraStyle.setTextStyle(style);
615 paraStyle.setMaxLines(lineLimit);
616
617 paraStyle.setEllipsis(ellipsis);
618
619 const char* logo1 = "google_";
620 const char* logo2 = "logo";
621 const char* logo3 = "go";
622 const char* logo4 = "ogle_logo";
623 const char* logo5 = "google_lo";
624 const char* logo6 = "go";
625 {
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -0400626 ParagraphBuilderImpl builder(paraStyle, getFontCollection());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400627
628 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400629 builder.addText(logo1, strlen(logo1));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400630 builder.pop();
631 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400632 builder.addText(logo2, strlen(logo2));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400633 builder.pop();
634
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400635 builder.addText(" ", 1);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400636
637 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400638 builder.addText(logo3, strlen(logo3));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400639 builder.pop();
640 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400641 builder.addText(logo4, strlen(logo4));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400642 builder.pop();
643
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400644 builder.addText(" ", 1);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400645
646 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400647 builder.addText(logo5, strlen(logo5));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400648 builder.pop();
649 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400650 builder.addText(logo6, strlen(logo6));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400651 builder.pop();
652
653 auto paragraph = builder.Build();
654 paragraph->layout(w - margin * 2);
655 paragraph->paint(canvas, margin, margin);
656 canvas->translate(0, h + margin);
657 }
658 }
659
660 void onDrawContent(SkCanvas* canvas) override {
661 canvas->drawColor(SK_ColorWHITE);
662 SkScalar width = this->width();
663 SkScalar height = this->height();
664
665 drawFlutter(canvas, width, height / 2);
666 }
667
668private:
669 typedef Sample INHERITED;
670};
671
Mike Reed21a940d2019-07-23 10:11:03 -0400672class ParagraphView5 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400673protected:
Julia Lavrova5207f352019-06-21 12:22:32 -0400674 SkString name() override { return SkString("Paragraph5"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400675
676 void bidi(SkCanvas* canvas, SkScalar w, SkScalar h, const std::u16string& text,
677 const std::u16string& expected, size_t lineLimit = std::numeric_limits<size_t>::max(),
678 const char* ff = "Roboto", SkScalar fs = 30,
679 const std::u16string& ellipsis = u"\u2026") {
680 SkAutoCanvasRestore acr(canvas, true);
681
682 canvas->clipRect(SkRect::MakeWH(w, h));
683
684 SkScalar margin = 20;
685
686 SkPaint black;
687 black.setColor(SK_ColorBLACK);
688 SkPaint gray;
689 gray.setColor(SK_ColorLTGRAY);
690
691 TextStyle style;
692 style.setForegroundColor(black);
693 style.setFontFamilies({SkString(ff)});
694 style.setFontSize(fs);
695
696 TextStyle style0;
697 style0.setForegroundColor(black);
698 style0.setFontFamilies({SkString(ff)});
699 style0.setFontSize(fs);
700 style0.setFontStyle(SkFontStyle(SkFontStyle::kNormal_Weight, SkFontStyle::kNormal_Width,
701 SkFontStyle::kItalic_Slant));
702
703 TextStyle style1;
704 style1.setForegroundColor(gray);
705 style1.setFontFamilies({SkString(ff)});
706 style1.setFontSize(fs);
707 style1.setFontStyle(SkFontStyle(SkFontStyle::kBold_Weight, SkFontStyle::kNormal_Width,
708 SkFontStyle::kUpright_Slant));
709
710 ParagraphStyle paraStyle;
711 paraStyle.setTextStyle(style);
712 paraStyle.setMaxLines(lineLimit);
713
714 paraStyle.setEllipsis(ellipsis);
715
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -0400716 ParagraphBuilderImpl builder(paraStyle, getFontCollection());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400717
718 if (text.empty()) {
719 const std::u16string text0 = u"\u202Dabc";
720 const std::u16string text1 = u"\u202EFED";
721 const std::u16string text2 = u"\u202Dghi";
722 const std::u16string text3 = u"\u202ELKJ";
723 const std::u16string text4 = u"\u202Dmno";
724 builder.pushStyle(style0);
725 builder.addText(text0);
726 builder.pop();
727 builder.pushStyle(style1);
728 builder.addText(text1);
729 builder.pop();
730 builder.pushStyle(style0);
731 builder.addText(text2);
732 builder.pop();
733 builder.pushStyle(style1);
734 builder.addText(text3);
735 builder.pop();
736 builder.pushStyle(style0);
737 builder.addText(text4);
738 builder.pop();
739 } else {
740 // icu::UnicodeString unicode((UChar*) text.data(), SkToS32(text.size()));
741 // std::string str;
742 // unicode.toUTF8String(str);
743 // SkDebugf("Text: %s\n", str.c_str());
744 builder.addText(text + expected);
745 }
746
747 auto paragraph = builder.Build();
748 paragraph->layout(w - margin * 2);
749 paragraph->paint(canvas, margin, margin);
750 }
751
752 void onDrawContent(SkCanvas* canvas) override {
753 canvas->drawColor(SK_ColorWHITE);
754 SkScalar width = this->width();
755 SkScalar height = this->height() / 8;
756
757 const std::u16string text1 =
758 u"A \u202ENAC\u202Cner, exceedingly \u202ENAC\u202Cny,\n"
759 "One morning remarked to his granny:\n"
760 "A \u202ENAC\u202Cner \u202ENAC\u202C \u202ENAC\u202C,\n"
761 "Anything that he \u202ENAC\u202C,\n"
762 "But a \u202ENAC\u202Cner \u202ENAC\u202C't \u202ENAC\u202C a \u202ENAC\u202C, "
763 "\u202ENAC\u202C he?";
764 bidi(canvas, width, height * 3, text1, u"", 5);
765 canvas->translate(0, height * 3);
766
767 bidi(canvas, width, height, u"\u2067DETALOSI\u2069", u"");
768 canvas->translate(0, height);
769
770 bidi(canvas, width, height, u"\u202BDEDDEBME\u202C", u"");
771 canvas->translate(0, height);
772
773 bidi(canvas, width, height, u"\u202EEDIRREVO\u202C", u"");
774 canvas->translate(0, height);
775
776 bidi(canvas, width, height, u"\u200FTICILPMI\u200E", u"");
777 canvas->translate(0, height);
778
779 bidi(canvas, width, height, u"123 456 7890 \u202EZYXWV UTS RQP ONM LKJ IHG FED CBA\u202C.",
780 u"", 2);
781 canvas->translate(0, height);
782
783 // bidi(canvas, width, height, u"", u"");
784 // canvas->translate(0, height);
785 }
786
787private:
788 typedef Sample INHERITED;
789};
790
Mike Reed21a940d2019-07-23 10:11:03 -0400791class ParagraphView6 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400792protected:
Julia Lavrova5207f352019-06-21 12:22:32 -0400793 SkString name() override { return SkString("Paragraph6"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400794
795 void hangingS(SkCanvas* canvas, SkScalar w, SkScalar h, SkScalar fs = 60.0) {
796 auto ff = "HangingS";
797
798 canvas->drawColor(SK_ColorLTGRAY);
799
800 SkPaint black;
801 black.setAntiAlias(true);
802 black.setColor(SK_ColorBLACK);
803
804 SkPaint blue;
805 blue.setAntiAlias(true);
806 blue.setColor(SK_ColorBLUE);
807
808 SkPaint red;
809 red.setAntiAlias(true);
810 red.setColor(SK_ColorRED);
811
812 SkPaint green;
813 green.setAntiAlias(true);
814 green.setColor(SK_ColorGREEN);
815
816 SkPaint gray;
817 gray.setColor(SK_ColorCYAN);
818
819 SkPaint yellow;
820 yellow.setColor(SK_ColorYELLOW);
821
822 SkPaint magenta;
823 magenta.setAntiAlias(true);
824 magenta.setColor(SK_ColorMAGENTA);
825
826 SkFontStyle fontStyle(SkFontStyle::kBold_Weight, SkFontStyle::kNormal_Width,
827 SkFontStyle::kItalic_Slant);
828
829 TextStyle style;
830 style.setFontFamilies({SkString(ff)});
831 style.setFontSize(fs);
832 style.setFontStyle(fontStyle);
833
834 TextStyle style0;
835 style0.setForegroundColor(black);
836 style0.setBackgroundColor(gray);
837 style0.setFontFamilies({SkString(ff)});
838 style0.setFontSize(fs);
839 style0.setFontStyle(fontStyle);
840
841 TextStyle style1;
842 style1.setForegroundColor(blue);
843 style1.setBackgroundColor(yellow);
844 style1.setFontFamilies({SkString(ff)});
845 style1.setFontSize(fs);
846 style1.setFontStyle(fontStyle);
847
848 TextStyle style2;
849 style2.setForegroundColor(red);
850 style2.setFontFamilies({SkString(ff)});
851 style2.setFontSize(fs);
852 style2.setFontStyle(fontStyle);
853
854 TextStyle style3;
855 style3.setForegroundColor(green);
856 style3.setFontFamilies({SkString(ff)});
857 style3.setFontSize(fs);
858 style3.setFontStyle(fontStyle);
859
860 TextStyle style4;
861 style4.setForegroundColor(magenta);
862 style4.setFontFamilies({SkString(ff)});
863 style4.setFontSize(fs);
864 style4.setFontStyle(fontStyle);
865
866 ParagraphStyle paraStyle;
867 paraStyle.setTextStyle(style);
868
869 const char* logo1 = "S";
870 const char* logo2 = "kia";
871 const char* logo3 = "Sk";
872 const char* logo4 = "ia";
873 const char* logo5 = "Ski";
874 const char* logo6 = "a";
875 {
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -0400876 ParagraphBuilderImpl builder(paraStyle, getFontCollection());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400877
878 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400879 builder.addText(logo1, strlen(logo1));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400880 builder.pop();
881 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400882 builder.addText(logo2, strlen(logo2));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400883 builder.pop();
884
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400885 builder.addText(" ", 3);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400886
887 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400888 builder.addText(logo3, strlen(logo3));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400889 builder.pop();
890 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400891 builder.addText(logo4, strlen(logo4));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400892 builder.pop();
893
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400894 builder.addText(" ", 3);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400895
896 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400897 builder.addText(logo5, strlen(logo5));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400898 builder.pop();
899 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400900 builder.addText(logo6, strlen(logo6));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400901 builder.pop();
902
903 auto paragraph = builder.Build();
904 paragraph->layout(w);
905 paragraph->paint(canvas, 40, 40);
906 canvas->translate(0, h);
907 }
908
909 const char* logo11 = "S";
910 const char* logo12 = "S";
911 const char* logo13 = "S";
912 const char* logo14 = "S";
913 const char* logo15 = "S";
914 const char* logo16 = "S";
915 {
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -0400916 ParagraphBuilderImpl builder(paraStyle, getFontCollection());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400917
918 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400919 builder.addText(logo11, strlen(logo1));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400920 builder.pop();
921 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400922 builder.addText(logo12, strlen(logo2));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400923 builder.pop();
924
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400925 builder.addText(" ", 3);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400926
927 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400928 builder.addText(logo13, strlen(logo3));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400929 builder.pop();
930 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400931 builder.addText(logo14, strlen(logo4));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400932 builder.pop();
933
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400934 builder.addText(" ", 3);
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400935
936 builder.pushStyle(style0);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400937 builder.addText(logo15, strlen(logo5));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400938 builder.pop();
939 builder.pushStyle(style1);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400940 builder.addText(logo16, strlen(logo6));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400941 builder.pop();
942
943 auto paragraph = builder.Build();
944 paragraph->layout(w);
945 paragraph->paint(canvas, 40, h);
946 canvas->translate(0, h);
947 }
948 }
949
950 void onDrawContent(SkCanvas* canvas) override {
951 canvas->drawColor(SK_ColorWHITE);
952 SkScalar width = this->width();
953 SkScalar height = this->height() / 4;
954
955 hangingS(canvas, width, height);
956 }
957
958private:
959 typedef Sample INHERITED;
960};
961
Mike Reed21a940d2019-07-23 10:11:03 -0400962class ParagraphView7 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400963protected:
Hal Canary8a027312019-07-03 10:55:44 -0400964 SkString name() override { return SkString("Paragraph7"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400965
966 void drawText(SkCanvas* canvas, SkColor background, SkScalar letterSpace, SkScalar w,
967 SkScalar h) {
968 SkAutoCanvasRestore acr(canvas, true);
969 canvas->clipRect(SkRect::MakeWH(w, h));
970 canvas->drawColor(background);
971
972 const char* line =
Julia Lavrovadb9f6692019-08-01 16:02:17 -0400973 "World domination is such an ugly phrase - I prefer to call it world optimisation.";
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400974
975 ParagraphStyle paragraphStyle;
976 paragraphStyle.setTextAlign(TextAlign::kLeft);
977 paragraphStyle.setMaxLines(10);
978 paragraphStyle.turnHintingOff();
979 TextStyle textStyle;
980 textStyle.setFontFamilies({SkString("Roboto")});
981 textStyle.setFontSize(30);
982 textStyle.setLetterSpacing(letterSpace);
983 textStyle.setColor(SK_ColorBLACK);
984 textStyle.setFontStyle(SkFontStyle(SkFontStyle::kMedium_Weight, SkFontStyle::kNormal_Width,
985 SkFontStyle::kUpright_Slant));
986
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -0400987 ParagraphBuilderImpl builder(paragraphStyle, getFontCollection());
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400988 builder.pushStyle(textStyle);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -0400989 builder.addText(line, strlen(line));
Julia Lavrovaa3552c52019-05-30 16:12:56 -0400990 builder.pop();
991
992 auto paragraph = builder.Build();
993 paragraph->layout(w - 20);
994 paragraph->paint(canvas, 10, 10);
995 }
996
997 void onDrawContent(SkCanvas* canvas) override {
998 canvas->drawColor(SK_ColorWHITE);
999
1000 auto h = this->height() / 4;
1001 auto w = this->width() / 2;
1002
1003 drawText(canvas, SK_ColorGRAY, 1, w, h);
1004 canvas->translate(0, h);
1005
1006 drawText(canvas, SK_ColorLTGRAY, 2, w, h);
1007 canvas->translate(0, h);
1008
1009 drawText(canvas, SK_ColorCYAN, 3, w, h);
1010 canvas->translate(0, h);
1011
1012 drawText(canvas, SK_ColorGRAY, 4, w, h);
1013 canvas->translate(w, -3 * h);
1014
1015 drawText(canvas, SK_ColorYELLOW, 5, w, h);
1016 canvas->translate(0, h);
1017
1018 drawText(canvas, SK_ColorGREEN, 10, w, h);
1019 canvas->translate(0, h);
1020
1021 drawText(canvas, SK_ColorRED, 15, w, h);
1022 canvas->translate(0, h);
1023
1024 drawText(canvas, SK_ColorBLUE, 20, w, h);
1025 canvas->translate(0, h);
1026 }
1027
1028private:
1029 typedef Sample INHERITED;
1030};
1031
Mike Reed21a940d2019-07-23 10:11:03 -04001032class ParagraphView8 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001033protected:
Julia Lavrovadb9f6692019-08-01 16:02:17 -04001034 SkString name() override { return SkString("Paragraph8"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001035
1036 void drawText(SkCanvas* canvas, SkColor background, SkScalar wordSpace, SkScalar w,
1037 SkScalar h) {
1038 SkAutoCanvasRestore acr(canvas, true);
1039 canvas->clipRect(SkRect::MakeWH(w, h));
1040 canvas->drawColor(background);
1041
1042 const char* line =
Julia Lavrovadb9f6692019-08-01 16:02:17 -04001043 "World domination is such an ugly phrase - I prefer to call it world optimisation.";
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001044
1045 ParagraphStyle paragraphStyle;
1046 paragraphStyle.setTextAlign(TextAlign::kLeft);
1047 paragraphStyle.setMaxLines(10);
1048 paragraphStyle.turnHintingOff();
1049 TextStyle textStyle;
1050 textStyle.setFontFamilies({SkString("Roboto")});
1051 textStyle.setFontSize(30);
1052 textStyle.setWordSpacing(wordSpace);
1053 textStyle.setColor(SK_ColorBLACK);
1054 textStyle.setFontStyle(SkFontStyle(SkFontStyle::kMedium_Weight, SkFontStyle::kNormal_Width,
1055 SkFontStyle::kUpright_Slant));
1056
Julia Lavrovab7b0b3a2019-07-30 13:32:08 -04001057 ParagraphBuilderImpl builder(paragraphStyle, getFontCollection());
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001058 builder.pushStyle(textStyle);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -04001059 builder.addText(line, strlen(line));
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001060 builder.pop();
1061
1062 auto paragraph = builder.Build();
1063 paragraph->layout(w - 20);
1064 paragraph->paint(canvas, 10, 10);
1065 }
1066
1067 void onDrawContent(SkCanvas* canvas) override {
1068 canvas->drawColor(SK_ColorWHITE);
1069
1070 auto h = this->height() / 4;
1071 auto w = this->width() / 2;
1072
1073 drawText(canvas, SK_ColorGRAY, 1, w, h);
1074 canvas->translate(0, h);
1075
1076 drawText(canvas, SK_ColorLTGRAY, 2, w, h);
1077 canvas->translate(0, h);
1078
1079 drawText(canvas, SK_ColorCYAN, 3, w, h);
1080 canvas->translate(0, h);
1081
1082 drawText(canvas, SK_ColorGRAY, 4, w, h);
1083 canvas->translate(w, -3 * h);
1084
1085 drawText(canvas, SK_ColorYELLOW, 5, w, h);
1086 canvas->translate(0, h);
1087
1088 drawText(canvas, SK_ColorGREEN, 10, w, h);
1089 canvas->translate(0, h);
1090
1091 drawText(canvas, SK_ColorRED, 15, w, h);
1092 canvas->translate(0, h);
1093
1094 drawText(canvas, SK_ColorBLUE, 20, w, h);
1095 canvas->translate(0, h);
1096 }
1097
1098private:
1099 typedef Sample INHERITED;
1100};
1101
Mike Reed21a940d2019-07-23 10:11:03 -04001102class ParagraphView9 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001103protected:
Hal Canary8a027312019-07-03 10:55:44 -04001104 SkString name() override { return SkString("Paragraph9"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001105
Hal Canary6cc65e12019-07-03 15:53:04 -04001106 bool onChar(SkUnichar uni) override {
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001107 switch (uni) {
1108 case 'w':
1109 ++wordSpacing;
1110 return true;
1111 case 'q':
1112 if (wordSpacing > 0) --wordSpacing;
1113 return true;
1114 case 'l':
1115 ++letterSpacing;
1116 return true;
1117 case 'k':
1118 if (letterSpacing > 0) --letterSpacing;
1119 return true;
1120 default:
1121 break;
1122 }
Hal Canary6cc65e12019-07-03 15:53:04 -04001123 return false;
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001124 }
1125
1126 void drawText(SkCanvas* canvas, SkColor background, SkScalar w, SkScalar h) {
1127 SkAutoCanvasRestore acr(canvas, true);
1128 canvas->clipRect(SkRect::MakeWH(w, h));
1129 canvas->drawColor(background);
1130
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001131 auto fontCollection = sk_make_sp<FontCollection>();
1132 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
1133 fontCollection->enableFontFallback();
1134
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001135 const char* text =
1136 "( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)("
1137 " ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)("
1138 " ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)";
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001139 auto multiplier = 5.67;
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001140 ParagraphStyle paragraphStyle;
1141 paragraphStyle.setTextAlign(TextAlign::kLeft);
1142 paragraphStyle.setMaxLines(10);
1143 paragraphStyle.turnHintingOff();
1144 TextStyle textStyle;
1145 textStyle.setFontFamilies({SkString("Roboto")});
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001146 textStyle.setFontSize(5 * multiplier);
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001147 textStyle.setHeight(1.3f);
1148 textStyle.setColor(SK_ColorBLACK);
1149 textStyle.setFontStyle(SkFontStyle(SkFontStyle::kMedium_Weight, SkFontStyle::kNormal_Width,
1150 SkFontStyle::kUpright_Slant));
1151
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001152 ParagraphBuilderImpl builder(paragraphStyle, fontCollection);
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001153 builder.pushStyle(textStyle);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -04001154 builder.addText(text, strlen(text));
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001155 builder.pop();
1156
1157 auto paragraph = builder.Build();
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001158 paragraph->layout(200 * multiplier);
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001159
1160 std::vector<size_t> sizes = {0, 1, 2, 8, 19, 21, 22, 30, 150};
1161
1162 std::vector<size_t> colors = {SK_ColorBLUE, SK_ColorCYAN, SK_ColorLTGRAY, SK_ColorGREEN,
1163 SK_ColorRED, SK_ColorWHITE, SK_ColorYELLOW, SK_ColorMAGENTA};
1164
1165 RectHeightStyle rect_height_style = RectHeightStyle::kTight;
1166 RectWidthStyle rect_width_style = RectWidthStyle::kTight;
1167
1168 for (size_t i = 0; i < sizes.size() - 1; ++i) {
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001169 size_t from = sizes[i];
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001170 size_t to = sizes[i + 1];
1171 auto boxes = paragraph->getRectsForRange(from, to, rect_height_style, rect_width_style);
1172 if (boxes.empty()) {
1173 continue;
1174 }
1175 for (auto& box : boxes) {
1176 SkPaint paint;
1177 paint.setColor(colors[i % colors.size()]);
1178 paint.setShader(setgrad(box.rect, colors[i % colors.size()], SK_ColorWHITE));
1179 canvas->drawRect(box.rect, paint);
1180 }
1181 }
1182
1183 paragraph->paint(canvas, 0, 0);
1184 }
1185
1186 void onDrawContent(SkCanvas* canvas) override {
1187 canvas->drawColor(SK_ColorWHITE);
1188
1189 auto h = this->height();
1190 auto w = this->width();
1191
1192 drawText(canvas, SK_ColorGRAY, w, h);
1193 }
1194
1195private:
1196 typedef Sample INHERITED;
1197 SkScalar letterSpacing;
1198 SkScalar wordSpacing;
1199};
1200
Mike Reed21a940d2019-07-23 10:11:03 -04001201class ParagraphView10 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001202protected:
Hal Canary8a027312019-07-03 10:55:44 -04001203 SkString name() override { return SkString("Paragraph10"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001204
1205 void onDrawContent(SkCanvas* canvas) override {
1206 canvas->drawColor(SK_ColorWHITE);
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001207 auto multiplier = 5.67;
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001208 const char* text = "English English 字典 字典 😀😃😄 😀😃😄";
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001209
1210 auto fontCollection = sk_make_sp<FontCollection>();
1211 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
1212 fontCollection->enableFontFallback();
1213
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001214 ParagraphStyle paragraph_style;
1215 paragraph_style.turnHintingOff();
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001216 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001217
1218 TextStyle text_style;
Julia Lavrova5207f352019-06-21 12:22:32 -04001219 text_style.setFontFamilies({SkString("Roboto"),
1220 SkString("Noto Color Emoji"),
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001221 SkString("Noto Serif CJK JP")});
1222 text_style.setFontSize(10 * multiplier);
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001223 text_style.setLetterSpacing(0);
1224 text_style.setWordSpacing(0);
1225 text_style.setColor(SK_ColorBLACK);
1226 text_style.setHeight(1);
1227 builder.pushStyle(text_style);
Kevin Lubick7aeabcf2019-09-27 15:16:13 -04001228 builder.addText(text, strlen(text));
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001229 builder.pop();
1230
1231 auto paragraph = builder.Build();
1232 paragraph->layout(width());
1233
1234 paragraph->paint(canvas, 0, 0);
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001235 }
1236
1237private:
1238 typedef Sample INHERITED;
1239};
1240
Mike Reed21a940d2019-07-23 10:11:03 -04001241class ParagraphView11 : public ParagraphView_Base {
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001242protected:
Hal Canary8a027312019-07-03 10:55:44 -04001243 SkString name() override { return SkString("Paragraph11"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -04001244
1245 void onDrawContent(SkCanvas* canvas) override {
1246 canvas->drawColor(SK_ColorWHITE);
Julia Lavrova5207f352019-06-21 12:22:32 -04001247
Julia Lavrovaf3ed2732019-09-05 14:35:17 -04001248 auto text = "\U0001f469\U0000200D\U0001f469\U0000200D\U0001f466\U0001f469\U0000200D\U0001f469\U0000200D\U0001f467\U0000200D\U0001f467\U0001f1fa\U0001f1f8";
Julia Lavrovaf3ed2732019-09-05 14:35:17 -04001249
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001250 TextStyle text_style;
1251 text_style.setFontFamilies({SkString("Ahem")});
1252 text_style.setColor(SK_ColorBLACK);
1253 text_style.setFontSize(60);
1254 text_style.setLetterSpacing(0);
1255 text_style.setWordSpacing(0);
1256 ParagraphStyle paragraph_style;
1257 paragraph_style.setTextStyle(text_style);
1258
1259 auto fontCollection = sk_make_sp<TestFontCollection>(GetResourcePath("fonts").c_str(), true, true);
1260 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
1261 builder.addText(text, strlen(text));
1262 auto paragraph = builder.Build();
1263 paragraph->layout(1000);
1264 paragraph->paint(canvas, 0, 0);
1265
1266 struct pair {
1267 unsigned fX;
1268 unsigned fY;
1269 };
1270
1271 pair hit1[] =
1272 {{ 0, 8},{1, 33}, {2, 34}, { 3, 19}, {4, 20},
1273 { 5, 21}, { 6, 22 }, { 7, 23 }, {8, 24 }, { 9, 25},
1274 { 10, 26}, { 11, 27}, {12, 28}, { 13, 21}, {14, 22 },
1275 { 15, 23}, {16, 24}, {17, 21}, { 18, 22}, {19, 21},
1276 { 20, 24}, { 21, 23}, };
1277
1278 pair miss[] =
1279 {{ 0, 4},{1, 17}, {2, 18}, { 3, 11}, {4, 12},
1280 { 5, 13}, { 6, 14 }, { 7, 15 }, {8, 16 }, { 9, 17},
1281 { 10, 18}, { 11, 19}, {12, 20}, { 13, 17}, {14, 18 },
1282 { 15, 19}, {16, 20}, {17, 19}, { 18, 20},
1283 { 20, 22}, };
1284
1285 auto rects = paragraph->getRectsForRange(7, 9, RectHeightStyle::kTight, RectWidthStyle::kTight);
1286 SkPaint paint;
1287 paint.setColor(SK_ColorRED);
1288 paint.setStyle(SkPaint::kStroke_Style);
1289 paint.setAntiAlias(true);
1290 paint.setStrokeWidth(1);
1291 if (!rects.empty()) {
1292 canvas->drawRect(rects[0].rect, paint);
1293 }
1294
1295 for (auto& query : hit1) {
1296 auto rects = paragraph->getRectsForRange(query.fX, query.fY, RectHeightStyle::kTight, RectWidthStyle::kTight);
1297 if (rects.size() >= 1 && rects[0].rect.width() > 0) {
1298 } else {
1299 SkDebugf("+[%d:%d): Bad\n", query.fX, query.fY);
Julia Lavrovaf3ed2732019-09-05 14:35:17 -04001300 }
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001301 }
1302
1303 for (auto& query : miss) {
1304 auto miss = paragraph->getRectsForRange(query.fX, query.fY, RectHeightStyle::kTight, RectWidthStyle::kTight);
1305 if (miss.empty()) {
1306 } else {
1307 SkDebugf("-[%d:%d): Bad\n", query.fX, query.fY);
1308 }
1309 }
Julia Lavrovaf3ed2732019-09-05 14:35:17 -04001310 }
1311
1312private:
1313 typedef Sample INHERITED;
1314};
1315
1316class ParagraphView12 : public ParagraphView_Base {
1317protected:
1318 SkString name() override { return SkString("Paragraph12"); }
1319
1320 void onDrawContent(SkCanvas* canvas) override {
1321 canvas->drawColor(SK_ColorWHITE);
1322
1323 const char* text = "Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges";
1324 TextStyle text_style;
1325 text_style.setFontFamilies({SkString("Ahem")});
1326 text_style.setColor(SK_ColorBLACK);
1327 text_style.setFontSize(16);
1328 //text_style.setLetterSpacing(-0.41);
1329 StrutStyle strut_style;
1330 strut_style.setStrutEnabled(false);
1331 ParagraphStyle paragraph_style;
1332 paragraph_style.setStrutStyle(strut_style);
1333 paragraph_style.setTextStyle(text_style);
1334 ParagraphBuilderImpl builder(paragraph_style, getFontCollection());
1335 builder.addText(text);
1336 auto paragraph = builder.Build();
1337 paragraph->layout(1095.000000);
1338 auto result = paragraph->getRectsForRange(65, 66, RectHeightStyle::kTight, RectWidthStyle::kTight);
1339 paragraph->paint(canvas, 0, 0);
1340
1341 SkPaint paint;
1342 paint.setColor(SK_ColorRED);
1343 paint.setStyle(SkPaint::kStroke_Style);
1344 paint.setAntiAlias(true);
1345 paint.setStrokeWidth(1);
1346 canvas->drawRect(result.front().rect, paint);
1347 }
1348
1349private:
1350 typedef Sample INHERITED;
1351};
1352
Julia Lavrovaf3ed2732019-09-05 14:35:17 -04001353class ParagraphView14 : public ParagraphView_Base {
1354protected:
1355 SkString name() override { return SkString("Paragraph14"); }
1356
1357 void onDrawContent(SkCanvas* canvas) override {
1358 canvas->drawColor(SK_ColorWHITE);
1359 TextStyle text_style;
1360 text_style.setFontFamilies({SkString("Ahem")});
1361 text_style.setColor(SK_ColorBLACK);
1362 text_style.setFontSize(25);
1363 text_style.setDecoration((TextDecoration)(TextDecoration::kUnderline | TextDecoration::kOverline | TextDecoration::kLineThrough));
1364 text_style.setDecorationColor(SK_ColorBLUE);
1365 text_style.setDecorationStyle(TextDecorationStyle::kWavy);
1366 text_style.setDecorationThicknessMultiplier(4.0f);
1367 ParagraphStyle paragraph_style;
1368 paragraph_style.setTextStyle(text_style);
1369 paragraph_style.setTextDirection(TextDirection::kRtl);
1370 ParagraphBuilderImpl builder(paragraph_style, getFontCollection());
1371 builder.pushStyle(text_style);
1372 builder.addText("Hello, wor!\nabcd.");
1373 auto paragraph = builder.Build();
1374 paragraph->layout(300);
1375 paragraph->paint(canvas, 0, 0);
1376 SkPaint paint;
1377 paint.setColor(SK_ColorRED);
1378 paint.setStyle(SkPaint::kStroke_Style);
1379 paint.setAntiAlias(true);
1380 paint.setStrokeWidth(1);
1381 canvas->drawRect(SkRect::MakeXYWH(0, 0, 300, 100), paint);
1382 }
1383
1384private:
1385 typedef Sample INHERITED;
1386};
1387
1388class ParagraphView15 : public ParagraphView_Base {
1389protected:
1390 SkString name() override { return SkString("Paragraph15"); }
1391
1392 void onDrawContent(SkCanvas* canvas) override {
1393 canvas->drawColor(SK_ColorWHITE);
Julia Lavrovaf3ed2732019-09-05 14:35:17 -04001394
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001395 TextStyle text_style;
1396 text_style.setFontFamilies({SkString("abc.ttf")});
1397 text_style.setFontSize(50);
1398
1399 auto fontCollection = sk_make_sp<TestFontCollection>(GetResourcePath("fonts").c_str(), false);
1400
1401 fontCollection->addFontFromFile("abc/abc.ttf", "abc");
1402 fontCollection->addFontFromFile("abc/abc+grave.ttf", "abc+grave");
1403 fontCollection->addFontFromFile("abc/abc+agrave.ttf", "abc+agrave");
1404
1405 ParagraphStyle paragraph_style;
1406 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
1407
1408 text_style.setFontFamilies({SkString("abc"), SkString("abc+grave")});
1409 text_style.setColor(SK_ColorBLUE);
1410 builder.pushStyle(text_style);
1411 builder.addText(u"a\u0300");
1412 text_style.setColor(SK_ColorMAGENTA);
1413 builder.pushStyle(text_style);
1414 builder.addText(u"à");
1415
1416 text_style.setFontFamilies({SkString("abc"), SkString("abc+agrave")});
1417
1418 text_style.setColor(SK_ColorRED);
1419 builder.pushStyle(text_style);
1420 builder.addText(u"a\u0300");
1421 text_style.setColor(SK_ColorGREEN);
1422 builder.pushStyle(text_style);
1423 builder.addText(u"à");
1424
1425 auto paragraph = builder.Build();
1426 paragraph->layout(800);
1427 paragraph->paint(canvas, 50, 50);
1428
Julia Lavrova5207f352019-06-21 12:22:32 -04001429 }
1430
1431private:
1432 typedef Sample INHERITED;
1433};
1434
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001435class ParagraphView16 : public ParagraphView_Base {
1436protected:
1437 SkString name() override { return SkString("Paragraph16"); }
1438
1439 void onDrawContent(SkCanvas* canvas) override {
1440 canvas->drawColor(SK_ColorWHITE);
1441
1442 const char* text = "content";
1443
1444 ParagraphStyle paragraph_style;
1445 paragraph_style.setMaxLines(1);
1446 paragraph_style.setEllipsis(u"\u2026");
1447 //auto fontCollection = sk_make_sp<TestFontCollection>(GetResourcePath("fonts").c_str(), false, true);
1448 auto fontCollection = sk_make_sp<FontCollection>();
1449 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
1450 fontCollection->enableFontFallback();
1451 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
1452
1453 TextStyle text_style;
1454 text_style.setFontFamilies({SkString(".SF Pro Text")});
1455 text_style.setColor(SK_ColorBLACK);
1456 text_style.setFontSize(17.0f * 99.0f);
1457 text_style.setLetterSpacing(0.41f);
1458 builder.pushStyle(text_style);
1459 builder.addText(text);
1460
1461 auto paragraph = builder.Build();
1462 paragraph->layout(800);
1463 paragraph->paint(canvas, 0, 0);
1464 }
1465
1466private:
1467 typedef Sample INHERITED;
1468};
1469
1470class ParagraphView17 : public ParagraphView_Base {
1471protected:
1472 SkString name() override { return SkString("Paragraph17"); }
1473
1474 void onDrawContent(SkCanvas* canvas) override {
1475 canvas->drawColor(SK_ColorWHITE);
1476
1477 auto fontCollection = sk_make_sp<FontCollection>();
1478 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
1479 fontCollection->enableFontFallback();
1480 auto navy = SkColorSetRGB(0, 0, 139);
1481 auto ltgray = SkColorSetRGB(211, 211, 211);
1482 auto multiplier = 5.67;
1483
1484 const char* text = ">Sͬ͑̀͐̈͒̈́̋̎ͮͩ̽̓ͬ̂̆̔͗́̓ͣͧ͊ͫ͛̉͌̐̑ͪ͗̚͝҉̴͉͢k̡̊̓ͫͭͩ͂͊ͨͪͬ̑ͫ̍̌̄͛̌̂̑̂̋̊̔ͫ͛̽̑ͨ̍ͭ̓̀ͪͪ̉͐͗̌̓̃̚͟͝҉̢͏̫̞̙͇͖̮͕̗̟͕͇͚̻͈̣̻̪͉̰̲̣̫ͅͅP̴̅̍͒̿͗͗̇ͩ̃͆͌̀̽͏̧̡͕͖̝̖̼̺̰̣̬͔͖͔̼͙̞̦̫͓̘͜a̸̴̸̴̢̢̨̨̫͍͓̥̼̭̼̻̤̯̙̤̻̠͚̍̌͋̂ͦͨ̽̇͌͌͆̀̽̎͒̄ͪ̐ͦ̈ͫ͐͗̓̚̚͜ͅr͐͐ͤͫ̐ͥ͂̈́̿́ͮ̃͗̓̏ͫ̀̿͏̸̵̧́͘̕͟͝͠͞͠҉̷̧͚͢͟a̓̽̎̄͗̔͛̄̐͊͛ͫ͂͌̂̂̈̈̓̔̅̅̄͊̉́ͪ̑̄͆ͬ̍͆ͭ͋̐ͬ͏̷̵̨̢̩̹̖͓̥̳̰͔̱̬͖̙͓̙͇̀̀̕͜͟͟͢͟͜͠͡g̨̅̇ͦ͋̂ͦͨͭ̓͐͆̏̂͛̉ͧ̑ͫ̐̒͛ͫ̍̒͛́̚҉̷̨̛̛̀͜͢͞҉̩̘̲͍͎̯̹̝̭̗̱͇͉̲̱͔̯̠̹̥̻͉̲̜̤̰̪̗̺̖̺r̷͌̓̇̅ͭ̀̐̃̃ͭ͑͗̉̈̇̈́ͥ̓ͣ́ͤ͂ͤ͂̏͌̆̚҉̴̸̧̢̢̛̫͉̦̥̤̙͈͉͈͉͓̙̗̟̳̜͈̗̺̟̠̠͖͓̖̪͕̠̕̕͝ͅả̸̴̡̡̧͠͞͡͞҉̛̕͟͏̷̘̪̱͈̲͉̞̠̞̪̫͎̲̬̖̀̀͟͝͞͞͠p̛͂̈͐̚͠҉̵̸̡̢̢̩̹͙̯͖̙̙̮̥̙͚̠͔̥̭̮̞̣̪̬̥̠̖̝̥̪͎́̀̕͜͡͡ͅͅh̵̷̵̡̛ͤ̂͌̐̓̐̋̋͊̒̆̽́̀̀̀͢͠͞͞҉̷̸̢̕҉͚̯͖̫̜̞̟̠̱͉̝̲̹̼͉̟͉̩̮͔̤͖̞̭̙̹̬ͅ<";
1485
1486 ParagraphStyle paragraph_style;
1487 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
1488 SkPaint paint;
1489 paint.setColor(ltgray);
1490 TextStyle text_style;
1491 text_style.setBackgroundColor(paint);
1492 text_style.setColor(navy);
1493 text_style.setFontFamilies({SkString("Roboto")});
1494 text_style.setFontSize(20 * multiplier);
1495 builder.pushStyle(text_style);
1496 builder.addText(text);
1497 auto paragraph = builder.Build();
1498 paragraph->layout(10000);
1499 paragraph->paint(canvas, 0, 0);
1500 }
1501
1502private:
1503 typedef Sample INHERITED;
1504};
1505
1506class Zalgo {
1507 private:
1508 std::u16string COMBINING_DOWN = u"\u0316\u0317\u0318\u0319\u031c\u031d\u031e\u031f\u0320\u0324\u0325\u0326\u0329\u032a\u032b\u032c\u032d\u032e\u032f\u0330\u0331\u0332\u0333\u0339\u033a\u033b\u033c\u0345\u0347\u0348\u0349\u034d\u034e\u0353\u0354\u0355\u0356\u0359\u035a\u0323";
1509 std::u16string COMBINING_UP = u"\u030d\u030e\u0304\u0305\u033f\u0311\u0306\u0310\u0352\u0357\u0351\u0307\u0308\u030a\u0342\u0343\u0344\u034a\u034b\u034c\u0303\u0302\u030c\u0350\u0300\u0301\u030b\u030f\u0312\u0313\u0314\u033d\u0309\u0363\u0364\u0365\u0366\u0367\u0368\u0369\u036a\u036b\u036c\u036d\u036e\u035b\u0346\u031a";
1510 std::u16string COMBINING_MIDDLE = u"\u0315\u031b\u0340\u0341\u0358\u0321\u0322\u0327\u0328\u0334\u0335\u0336\u034f\u035c\u035d\u035e\u035f\u0360\u0362\u0338\u0337\u0361\u0489";
1511
1512 std::u16string randomMarks(std::u16string& combiningMarks) {
1513 std::u16string result;
1514 auto num = std::rand() % (combiningMarks.size() / 1);
1515 for (size_t i = 0; i < num; ++i) {
1516 auto index = std::rand() % combiningMarks.size();
1517 result += combiningMarks[index];
1518 }
1519 return result;
1520 }
1521
1522public:
1523 std::u16string zalgo(std::string victim) {
1524 std::u16string result;
1525 for (auto& c : victim) {
1526 result += c;
1527 result += randomMarks(COMBINING_UP);
1528 result += randomMarks(COMBINING_MIDDLE);
1529 result += randomMarks(COMBINING_DOWN);
1530 }
1531 return result;
1532 }
1533};
1534
1535class ParagraphView18 : public ParagraphView_Base {
1536protected:
1537 SkString name() override { return SkString("Paragraph18"); }
1538
1539 bool onChar(SkUnichar uni) override {
1540 switch (uni) {
1541 case ' ':
1542 fLimit = 400;
1543 return true;
1544 case 's':
1545 fLimit += 10;
1546 return true;
1547 case 'f':
1548 if (fLimit > 10) {
1549 fLimit -= 10;
1550 }
1551 return true;
1552 default:
1553 break;
1554 }
1555 return false;
1556 }
1557
1558 bool onAnimate(double nanos) override {
1559 if (++fIndex > fLimit) {
1560 fRedraw = true;
1561 fIndex = 0;
1562 } else {
1563 fRepeat = true;
1564 }
1565 return true;
1566 }
1567
1568 void onDrawContent(SkCanvas* canvas) override {
1569 canvas->drawColor(SK_ColorWHITE);
1570
1571 auto navy = SkColorSetRGB(0, 0, 139);
1572 auto ltgray = SkColorSetRGB(211, 211, 211);
1573
1574 auto multiplier = 5.67;
1575 auto fontCollection = sk_make_sp<FontCollection>();
1576 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
1577 fontCollection->enableFontFallback();
1578
1579 ParagraphStyle paragraph_style;
1580 TextStyle text_style;
1581 text_style.setFontFamilies({SkString("Roboto")});
1582 text_style.setFontSize(20 * multiplier);
1583 text_style.setColor(navy);
1584 SkPaint paint;
1585 paint.setColor(ltgray);
1586 text_style.setBackgroundColor(paint);
1587
1588 Zalgo zalgo;
1589
1590 if (fRedraw || fRepeat) {
1591
1592 if (fRedraw || fParagraph.get() == nullptr) {
1593 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
1594 builder.pushStyle(text_style);
1595 auto utf16text = zalgo.zalgo("SkParagraph");
1596 icu::UnicodeString unicode((UChar*)utf16text.data(), SkToS32(utf16text.size()));
1597 std::string str;
1598 unicode.toUTF8String(str);
1599 SkDebugf("Text:>%s<\n", str.data());
1600 builder.addText(utf16text);
1601 fParagraph = builder.Build();
1602 }
1603
1604 auto impl = static_cast<ParagraphImpl*>(fParagraph.get());
1605 impl->setState(InternalState::kUnknown);
1606 fParagraph->layout(1000);
1607 fParagraph->paint(canvas, 300, 200);
1608
1609 for (auto& run : impl->runs()) {
1610 SkString fontFamily("unresolved");
1611 if (run.font().getTypeface() != nullptr) {
1612 run.font().getTypeface()->getFamilyName(&fontFamily);
1613 }
1614 if (run.font().getTypeface() != nullptr) {
1615 for (size_t i = 0; i < run.size(); ++i) {
1616 auto glyph = run.glyphs().begin() + i;
1617 if (*glyph == 0) {
1618 SkDebugf("Run[%d] @pos=%d\n", run.index(), i);
1619 SkASSERT(false);
1620 }
1621 }
1622 } else {
1623 SkDebugf("Run[%d]: %s\n", run.index(), fontFamily.c_str());
1624 SkASSERT(false);
1625 }
1626 }
1627 fRedraw = false;
1628 fRepeat = false;
1629 }
1630 }
1631
1632private:
1633 bool fRedraw = true;
1634 bool fRepeat = false;
1635 size_t fIndex = 0;
1636 size_t fLimit = 20;
1637 std::unique_ptr<Paragraph> fParagraph;
1638 typedef Sample INHERITED;
1639};
1640
1641class ParagraphView19 : public ParagraphView_Base {
1642protected:
1643 SkString name() override { return SkString("Paragraph19"); }
1644
1645 void onDrawContent(SkCanvas* canvas) override {
1646 canvas->drawColor(SK_ColorWHITE);
1647
1648 auto fontCollection = sk_make_sp<TestFontCollection>(GetResourcePath("fonts").c_str(), false, true);
1649
Julia Lavrova90bfd1c2019-12-04 11:43:32 -05001650 std::u16string text = u"\u0068\u0301\u0350\u0312\u0357\u030C\u0369\u0305\u036C\u0304\u0310\u033F\u0366\u0350\u0343\u0364\u0369\u0311\u0309\u030E\u0365\u031B\u0340\u0337\u0335\u035E\u0334\u0328\u0360\u0360\u0315\u035F\u0340\u0340\u0362\u0360\u0322\u031B\u031B\u0337\u0340\u031E\u031F\u032A\u0331\u0345\u032F\u0332\u032E\u0333\u0353\u0320\u0345\u031C\u031F\u033C\u0325\u0355\u032C\u0325\u033Aa\u0307\u0312\u034B\u0308\u0312\u0346\u0313\u0346\u0304\u0307\u0344\u0305\u0342\u0368\u0346\u036A\u035B\u030F\u0365\u0307\u0340\u0328\u0322\u0361\u0489\u034F\u0328\u0334\u035F\u0335\u0362\u0489\u0360\u0358\u035E\u0360\u035D\u0341\u0337\u0337\u032E\u0326\u032D\u0359\u0318\u033C\u032F\u0333\u035A\u034D\u0319\u031C\u0353\u033C\u0345\u0359\u0331\u033B\u0331\u033C";
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001651 ParagraphStyle paragraph_style;
1652 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001653 TextStyle text_style;
Julia Lavrovac028b422019-11-25 10:00:43 -05001654 text_style.setColor(SK_ColorBLACK);
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001655 text_style.setFontFamilies({SkString("Roboto")});
Julia Lavrova90bfd1c2019-12-04 11:43:32 -05001656 text_style.setFontSize(20);
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001657 builder.pushStyle(text_style);
1658 builder.addText(text);
1659 auto paragraph = builder.Build();
Julia Lavrovac028b422019-11-25 10:00:43 -05001660 paragraph->layout(this->width());
Julia Lavrovac028b422019-11-25 10:00:43 -05001661 paragraph->paint(canvas, 0, 0);
1662 }
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001663
Julia Lavrovac028b422019-11-25 10:00:43 -05001664private:
1665 typedef Sample INHERITED;
1666};
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001667
Julia Lavrovac028b422019-11-25 10:00:43 -05001668class ParagraphView20 : public ParagraphView_Base {
1669protected:
1670 SkString name() override { return SkString("Paragraph20"); }
1671
1672 void onDrawContent(SkCanvas* canvas) override {
1673 canvas->drawColor(SK_ColorWHITE);
1674
1675 auto fontCollection = sk_make_sp<TestFontCollection>(GetResourcePath("fonts").c_str(), false, true);
1676
Julia Lavrovac48687a2020-01-08 16:53:53 -05001677 const char* text = "Manage your google account";
Julia Lavrovac028b422019-11-25 10:00:43 -05001678 ParagraphStyle paragraph_style;
Julia Lavrovac48687a2020-01-08 16:53:53 -05001679 paragraph_style.setEllipsis(u"\u2026");
1680 paragraph_style.setMaxLines(1);
Julia Lavrovac028b422019-11-25 10:00:43 -05001681 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
1682 TextStyle text_style;
1683 text_style.setColor(SK_ColorBLACK);
Julia Lavrova53c14472019-12-18 09:39:55 -05001684 text_style.setFontFamilies({SkString("Roboto")});
Julia Lavrovac48687a2020-01-08 16:53:53 -05001685 text_style.setFontSize(50);
Julia Lavrovac028b422019-11-25 10:00:43 -05001686 builder.pushStyle(text_style);
1687 builder.addText(text);
1688 auto paragraph = builder.Build();
Julia Lavrovac48687a2020-01-08 16:53:53 -05001689 paragraph->layout(this->width());
1690 paragraph->paint(canvas, 0, 0);
1691 }
1692
1693private:
1694 typedef Sample INHERITED;
1695};
1696
1697class ParagraphView21 : public ParagraphView_Base {
1698protected:
1699 SkString name() override { return SkString("Paragraph21"); }
1700
1701 void onDrawContent(SkCanvas* canvas) override {
1702 canvas->drawColor(SK_ColorWHITE);
1703
Julia Lavrova70e93012020-01-10 14:04:45 -05001704 const char* text = "Referral Code";
Julia Lavrovac48687a2020-01-08 16:53:53 -05001705 ParagraphStyle paragraph_style;
Julia Lavrovaf6a3f8e2020-01-10 10:55:52 -05001706 ParagraphBuilderImpl builder(paragraph_style, getFontCollection());
Julia Lavrovac48687a2020-01-08 16:53:53 -05001707 TextStyle text_style;
1708 text_style.setColor(SK_ColorBLACK);
Julia Lavrovaf6a3f8e2020-01-10 10:55:52 -05001709 text_style.setFontFamilies({SkString("Google Sans")});
1710 text_style.setFontSize(24);
Julia Lavrovac48687a2020-01-08 16:53:53 -05001711 builder.pushStyle(text_style);
1712 builder.addText(text);
1713 auto paragraph = builder.Build();
Julia Lavrova70e93012020-01-10 14:04:45 -05001714 paragraph->layout(0);
Julia Lavrovac028b422019-11-25 10:00:43 -05001715 paragraph->paint(canvas, 0, 0);
Julia Lavrova2e30fde2019-10-09 09:43:02 -04001716 }
1717
1718private:
1719 typedef Sample INHERITED;
1720};
Julia Lavrova4cf18742020-01-14 13:24:45 -05001721
1722class ParagraphView22 : public ParagraphView_Base {
1723protected:
1724 SkString name() override { return SkString("Paragraph22"); }
1725
Julia Lavrova9bd83512020-01-15 14:46:35 -05001726 bool onChar(SkUnichar uni) override {
1727 switch (uni) {
1728 case 'l':
1729 direction = true;
1730 return true;
1731 case 'r':
1732 direction = false;
1733 return true;
1734 default:
1735 break;
Julia Lavrova4cf18742020-01-14 13:24:45 -05001736 }
Julia Lavrova9bd83512020-01-15 14:46:35 -05001737 return false;
1738 }
1739
1740 void onDrawContent(SkCanvas* canvas) override {
1741
1742 canvas->drawColor(SK_ColorWHITE);
1743 ParagraphStyle paragraph_style;
1744 paragraph_style.setTextDirection(direction ? TextDirection::kLtr : TextDirection::kRtl);
1745 auto collection = getFontCollection();
1746 ParagraphBuilderImpl builder(paragraph_style, collection);
1747 collection->getParagraphCache()->reset();
1748 collection->getParagraphCache()->turnOn(false);
1749 TextStyle text_style;
1750 text_style.setColor(SK_ColorBLACK);
1751 text_style.setFontFamilies({SkString("Roboto")});
1752 text_style.setFontSize(12);
1753 builder.pushStyle(text_style);
1754 builder.addText("I have got a ");
1755 text_style.setFontStyle(SkFontStyle::Bold());
1756 builder.pushStyle(text_style);
1757 builder.addText("lovely bunch");
1758 text_style.setFontStyle(SkFontStyle::Normal());
1759 builder.pushStyle(text_style);
1760 builder.addText(" of coconuts.");
1761 auto paragraph = builder.Build();
1762 paragraph->layout(this->width());
1763 paragraph->paint(canvas, 0, 0);
1764 collection->getParagraphCache()->turnOn(true);
Julia Lavrova4cf18742020-01-14 13:24:45 -05001765 }
1766
1767private:
1768 typedef Sample INHERITED;
Julia Lavrova9bd83512020-01-15 14:46:35 -05001769 bool direction;
Julia Lavrova4cf18742020-01-14 13:24:45 -05001770};
Julia Lavrova9bd83512020-01-15 14:46:35 -05001771
Julia Lavrova51a813d2020-01-21 13:55:44 -05001772class ParagraphView23 : public ParagraphView_Base {
1773protected:
1774 SkString name() override { return SkString("Paragraph23"); }
1775
1776 void onDrawContent(SkCanvas* canvas) override {
1777 canvas->drawColor(SK_ColorWHITE);
1778
1779 const char* text = "Text with shadow";
1780 ParagraphStyle paragraph_style;
1781 TextStyle text_style;
1782 text_style.setColor(SK_ColorBLACK);
1783 text_style.setFontFamilies({SkString("Google Sans")});
1784 text_style.setFontSize(24);
1785
1786 auto draw = [&](SkScalar h, SkScalar v, SkScalar b) {
1787 text_style.resetShadows();
1788 text_style.addShadow(TextShadow(SK_ColorBLACK, SkPoint::Make(h, v), b));
1789 ParagraphBuilderImpl builder(paragraph_style, getFontCollection());
1790 builder.pushStyle(text_style);
1791 builder.addText(text);
1792 auto paragraph = builder.Build();
1793 paragraph->layout(300);
1794 paragraph->paint(canvas, 0, 0);
1795
1796 auto rect = SkRect::MakeXYWH(0, 0, paragraph->getMaxWidth(), paragraph->getHeight());
1797 SkPaint paint;
1798 paint.setColor(SK_ColorRED);
1799 paint.setStyle(SkPaint::kStroke_Style);
1800 paint.setAntiAlias(true);
1801 paint.setStrokeWidth(1);
1802 canvas->drawRect(rect, paint);
1803 };
1804
1805 draw(10, 10, 5);
1806 canvas->translate(0, 100);
1807
1808 draw(10, -10, 5);
1809 canvas->translate(0, 100);
1810
1811 draw(-10, -10, 5);
1812 canvas->translate(0, 100);
1813
1814 draw(-10, 10, 5);
1815 canvas->translate(0, 100);
1816 }
1817
1818private:
1819 typedef Sample INHERITED;
1820};
1821
Julia Lavrova2ea20ea2020-01-22 10:56:53 -05001822class ParagraphView24 : public ParagraphView_Base {
1823protected:
1824 SkString name() override { return SkString("Paragraph24"); }
1825
1826 void onDrawContent(SkCanvas* canvas) override {
1827 canvas->drawColor(SK_ColorWHITE);
1828
1829 ParagraphStyle paragraph_style;
1830 paragraph_style.setTextDirection(TextDirection::kRtl);
1831 TextStyle text_style;
1832 text_style.setColor(SK_ColorBLACK);
1833 text_style.setFontFamilies({SkString("Google Sans")});
1834 text_style.setFontSize(24);
1835 {
1836 ParagraphBuilderImpl builder(paragraph_style, getFontCollection());
1837 builder.pushStyle(text_style);
1838 builder.addText("Right_to_left:");
1839 auto paragraph = builder.Build();
1840 paragraph->layout(this->width());
1841 paragraph->paint(canvas, 0, 0);
1842 }
1843 canvas->translate(0, 200);
1844 {
1845 ParagraphBuilderImpl builder(paragraph_style, getFontCollection());
1846 builder.pushStyle(text_style);
1847 builder.addText("Right_to_left+");
1848 auto paragraph = builder.Build();
1849 paragraph->layout(this->width());
1850 paragraph->paint(canvas, 0, 0);
1851 }
1852 canvas->translate(0, 200);
1853 {
1854 ParagraphBuilderImpl builder(paragraph_style, getFontCollection());
1855 builder.pushStyle(text_style);
1856 builder.addText("Right_to_left.");
1857 auto paragraph = builder.Build();
1858 paragraph->layout(this->width());
1859 paragraph->paint(canvas, 0, 0);
1860 }
1861 }
1862
1863private:
1864 typedef Sample INHERITED;
1865};
1866
1867class ParagraphView25 : public ParagraphView_Base {
1868protected:
1869 SkString name() override { return SkString("Paragraph25"); }
1870
1871 void onDrawContent(SkCanvas* canvas) override {
1872 canvas->drawColor(SK_ColorWHITE);
Julia Lavrovac0360582020-02-05 10:17:53 -05001873/*
1874 * Shell: ParagraphStyle: 1.000000 1
1875Shell: Strut enabled: 0 1.000000 14.000000 400 5 0
1876Shell: Font Families: 0
1877Shell: DefaultTextStyle: 16.000000 500 5 0
1878Shell: Font Families: 1 Roboto
1879Shell: Font Features: 0
1880Shell: TextStyle#0: [0:22) 16.000000 500 5 0
1881Shell: Font Families: 1 Roboto
1882Shell: Font Features: 0
1883Shell: TextStyle#1: [25:49) 16.000000 500 5 0
1884Shell: Font Families: 1 Roboto
1885Shell: Font Features: 0
1886Shell: Placeholder#0: [22:25) 32.000000 32.000000 32.000000 0 5
1887Shell: Placeholder#1: [49:52) 19.000000 41.000000 19.000000 0 4
1888Shell: Placeholder#2: [52:52) 0.000000 0.000000 0.000000 0 5
1889Shell: layout('Go to device settings  and set up a passcode. ', 280.000000): 280.000000 * 38.000000
1890 */
1891 auto fontCollection = getFontCollection();
1892 //fontCollection->getParagraphCache()->turnOn(false);
1893 const char* text1 = "Go to device settings ";
1894 const char* text2 = "and set up a passcode.";
Julia Lavrova2ea20ea2020-01-22 10:56:53 -05001895 ParagraphStyle paragraph_style;
Julia Lavrovac0360582020-02-05 10:17:53 -05001896 StrutStyle strut_style;
1897 strut_style.setStrutEnabled(false);
1898 strut_style.setFontSize(14);
1899 strut_style.setForceStrutHeight(false);
1900 strut_style.setHeight(14);
1901 paragraph_style.setStrutStyle(strut_style);
Julia Lavrova2ea20ea2020-01-22 10:56:53 -05001902 TextStyle text_style;
1903 text_style.setColor(SK_ColorBLACK);
Julia Lavrovac0360582020-02-05 10:17:53 -05001904 text_style.setFontFamilies({SkString("Roboto")});
1905 text_style.setFontSize(16);
1906 PlaceholderStyle placeholder_style;
1907 {
1908 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
1909 builder.pushStyle(text_style);
1910 builder.addText(text1);
1911 placeholder_style.fHeight = 32;
1912 placeholder_style.fWidth = 32;
1913 placeholder_style.fBaselineOffset = 32;
1914 placeholder_style.fBaseline = TextBaseline::kAlphabetic;
1915 placeholder_style.fAlignment = PlaceholderAlignment::kMiddle;
1916 builder.addPlaceholder(placeholder_style);
1917 builder.addText(text2);
1918 placeholder_style.fHeight = 19;
1919 placeholder_style.fWidth = 41;
1920 placeholder_style.fBaselineOffset = 19;
1921 placeholder_style.fBaseline = TextBaseline::kAlphabetic;
1922 placeholder_style.fAlignment = PlaceholderAlignment::kTop;
1923 builder.addPlaceholder(placeholder_style);
1924 auto paragraph = builder.Build();
1925 paragraph->layout(280);
1926 paragraph->paint(canvas, 0, 0);
1927 }
Julia Lavrova2ea20ea2020-01-22 10:56:53 -05001928 }
1929
1930private:
1931 typedef Sample INHERITED;
1932};
1933
1934class ParagraphView26 : public ParagraphView_Base {
1935protected:
1936 SkString name() override { return SkString("Paragraph26"); }
1937
1938 void onDrawContent(SkCanvas* canvas) override {
Julia Lavrovad3a32c52020-02-03 09:43:52 -05001939 auto fontCollection = sk_make_sp<FontCollection>();
1940 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
Julia Lavrova95a9e692020-02-05 10:17:53 -05001941 //fontCollection->enableFontFallback();
Julia Lavrova2ea20ea2020-01-22 10:56:53 -05001942
Julia Lavrovad3a32c52020-02-03 09:43:52 -05001943 canvas->clear(SK_ColorWHITE);
1944
1945 SkPaint paint;
1946 paint.setAntiAlias(true);
1947 paint.setColor(SK_ColorBLACK);
1948
1949 TextStyle textStyle;
1950 textStyle.setForegroundColor(paint);
Julia Lavrova95a9e692020-02-05 10:17:53 -05001951 textStyle.setFontFamilies({ SkString("Roboto") });
1952 textStyle.setFontSize(42.0f);
1953 textStyle.setLetterSpacing(-0.05f);
1954 textStyle.setHeightOverride(true);
Julia Lavrovad3a32c52020-02-03 09:43:52 -05001955
1956 ParagraphStyle paragraphStyle;
1957 paragraphStyle.setTextStyle(textStyle);
1958 paragraphStyle.setTextAlign(TextAlign::kLeft);
Julia Lavrovad3a32c52020-02-03 09:43:52 -05001959
Julia Lavrova95a9e692020-02-05 10:17:53 -05001960 ParagraphBuilderImpl builder(paragraphStyle, fontCollection);
1961 builder.addText(u"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ut dolor ornare, fermentum nibh in, consectetur libero. Ut id semper est. Sed malesuada, est id bibendum egestas, urna risus tristique nibh, euismod interdum risus turpis nec purus. Maecenas dolor nisl, consectetur in vestibulum et, tincidunt id leo. Duis maximus, odio eget tristique commodo, lacus tellus dapibus leo, consequat pellentesque arcu nisi sit amet diam. Quisque euismod venenatis egestas. Mauris posuere volutpat iaculis. Suspendisse finibus tempor urna, dignissim venenatis sapien finibus eget. Donec interdum lacus ac venenatis fringilla. Curabitur eget lacinia augue. Vestibulum eu vulputate odio. Quisque nec imperdiet");
Julia Lavrovad3a32c52020-02-03 09:43:52 -05001962
Julia Lavrova95a9e692020-02-05 10:17:53 -05001963 auto paragraph = builder.Build();
1964 paragraph->layout(this->width() / 2);
Julia Lavrovad3a32c52020-02-03 09:43:52 -05001965
Julia Lavrova95a9e692020-02-05 10:17:53 -05001966 std::vector<LineMetrics> lines;
1967 paragraph->getLineMetrics(lines); // <-- error happens here
Julia Lavrovad3a32c52020-02-03 09:43:52 -05001968
Julia Lavrova95a9e692020-02-05 10:17:53 -05001969 canvas->translate(10, 10);
1970 paragraph->paint(canvas, 0, 0);
Julia Lavrova2ea20ea2020-01-22 10:56:53 -05001971 }
1972
1973private:
1974 typedef Sample INHERITED;
1975};
1976
Julia Lavrovac88a3bc2020-01-23 10:16:26 -05001977class ParagraphView27 : public ParagraphView_Base {
1978protected:
1979 SkString name() override { return SkString("Paragraph27"); }
1980
1981 void onDrawContent(SkCanvas* canvas) override {
Julia Lavrovad3a32c52020-02-03 09:43:52 -05001982 auto fontCollection = sk_make_sp<FontCollection>();
1983 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
1984 fontCollection->enableFontFallback();
1985 fontCollection->getParagraphCache()->turnOn(false);
1986
1987 SkPaint red;
1988 red.setColor(SK_ColorRED);
1989 red.setStyle(SkPaint::kStroke_Style);
1990 red.setAntiAlias(true);
1991 red.setStrokeWidth(1);
1992
1993 SkPaint blue;
1994 blue.setColor(SK_ColorRED);
1995 blue.setStyle(SkPaint::kStroke_Style);
1996 blue.setAntiAlias(true);
1997 blue.setStrokeWidth(1);
1998
1999 SkPaint black;
2000 black.setColor(SK_ColorBLACK);
2001 black.setStyle(SkPaint::kStroke_Style);
2002 black.setAntiAlias(true);
2003 black.setStrokeWidth(1);
Julia Lavrovac88a3bc2020-01-23 10:16:26 -05002004
Julia Lavrova95a9e692020-02-05 10:17:53 -05002005 SkPaint whiteSpaces;
2006 whiteSpaces.setColor(SK_ColorLTGRAY);
2007
2008 SkPaint breakingSpace;
2009 breakingSpace.setColor(SK_ColorYELLOW);
2010
2011 SkPaint text;
2012 text.setColor(SK_ColorWHITE);
2013
Julia Lavrovac88a3bc2020-01-23 10:16:26 -05002014 ParagraphStyle paragraph_style;
Julia Lavrovad3a32c52020-02-03 09:43:52 -05002015 paragraph_style.setTextAlign(TextAlign::kRight);
Julia Lavrovac88a3bc2020-01-23 10:16:26 -05002016 TextStyle text_style;
2017 text_style.setColor(SK_ColorBLACK);
Julia Lavrovad3a32c52020-02-03 09:43:52 -05002018 text_style.setFontFamilies({SkString("Roboto")});
Julia Lavrova89e678d2020-01-28 10:43:31 -05002019
Julia Lavrovad3a32c52020-02-03 09:43:52 -05002020 // RTL + right align + arabic
2021 // RTL + right align + latin
2022 // LTR + right align + arabic
2023 // LTR + right align + latin
2024 // RTL + left align + arabic
2025 // RTL + left align + latin
2026 // arabic and latin should not differ at all
2027 // check: line breaking and trailing spaces
2028
2029 canvas->drawColor(SK_ColorWHITE);
2030 auto h = 60;
2031 auto w = 300;
2032
Julia Lavrova95a9e692020-02-05 10:17:53 -05002033 auto draw = [&](SkScalar width, SkScalar height, TextDirection td, TextAlign ta, const char* t) {
2034 SkDebugf("draw '%s' dir:%s align:%s\n", t,
Julia Lavrovad3a32c52020-02-03 09:43:52 -05002035 td == TextDirection::kLtr ? "left" : "right",
2036 ta == TextAlign::kLeft ? "left" : "right");
2037 paragraph_style.setTextDirection(td);
2038 paragraph_style.setTextAlign(ta);
2039 text_style.setFontSize(20);
2040 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
Julia Lavrova95a9e692020-02-05 10:17:53 -05002041 text_style.setBackgroundColor(whiteSpaces);
Julia Lavrovac88a3bc2020-01-23 10:16:26 -05002042 builder.pushStyle(text_style);
Julia Lavrova95a9e692020-02-05 10:17:53 -05002043 builder.addText(" ");
2044 text_style.setBackgroundColor(text);
2045 builder.pushStyle(text_style);
2046 builder.addText(t);
2047 text_style.setBackgroundColor(breakingSpace);
2048 builder.pushStyle(text_style);
2049 builder.addText(" ");
2050 text_style.setBackgroundColor(text);
2051 builder.pushStyle(text_style);
2052 builder.addText(t);
2053 text_style.setBackgroundColor(whiteSpaces);
2054 builder.pushStyle(text_style);
2055 builder.addText(" ");
Julia Lavrovac88a3bc2020-01-23 10:16:26 -05002056 auto paragraph = builder.Build();
Julia Lavrovad3a32c52020-02-03 09:43:52 -05002057 paragraph->layout(width);
Julia Lavrovac88a3bc2020-01-23 10:16:26 -05002058 paragraph->paint(canvas, 0, 0);
Julia Lavrovad3a32c52020-02-03 09:43:52 -05002059 auto impl = static_cast<ParagraphImpl*>(paragraph.get());
2060 for (auto& line : impl->lines()) {
2061 SkDebugf("line[%d]: %f + %f\n", &line - impl->lines().begin(), line.offset().fX, line.shift());
2062 line.iterateThroughVisualRuns(true,
2063 [&](const Run* run, SkScalar runOffset, TextRange textRange, SkScalar* width) {
2064 *width = line.measureTextInsideOneRun(textRange, run, runOffset, 0, true, false).clip.width();
2065 SkDebugf("%d[%d: %d) @%f + %f %s\n", run->index(),
2066 textRange.start, textRange.end, runOffset, *width, run->leftToRight() ? "left" : "right");
2067 return true;
2068 });
2069 }
2070 auto boxes = paragraph->getRectsForRange(0, 100, RectHeightStyle::kTight, RectWidthStyle::kTight);
2071 bool even = true;
2072 for (auto& box : boxes) {
2073 SkDebugf("[%f:%f,%f:%f] %s\n",
2074 box.rect.fLeft, box.rect.fRight, box.rect.fTop, box.rect.fBottom,
2075 box.direction == TextDirection::kLtr ? "left" : "right");
2076 canvas->drawRect(box.rect, even ? red : blue);
2077 even = !even;
2078 }
2079 canvas->translate(0, height);
Julia Lavrova89e678d2020-01-28 10:43:31 -05002080 };
2081
Julia Lavrovad3a32c52020-02-03 09:43:52 -05002082 canvas->drawRect(SkRect::MakeXYWH(0, 0, w, h * 8), black);
2083
2084 draw(w, h, TextDirection::kRtl, TextAlign::kRight, "RTL+RIGHT#1234567890");
2085 draw(w, h, TextDirection::kRtl, TextAlign::kRight, "قففغغغغقففغغغغقففغغغ");
2086
2087 draw(w, h, TextDirection::kLtr, TextAlign::kRight, "LTR+RIGHT#1234567890");
2088 draw(w, h, TextDirection::kLtr, TextAlign::kRight, "قففغغغغقففغغغغقففغغغ");
2089
2090 draw(w, h, TextDirection::kRtl, TextAlign::kLeft, "RTL+LEFT##1234567890");
2091 draw(w, h, TextDirection::kRtl, TextAlign::kLeft, "قففغغغغقففغغغغقففغغغ");
2092
2093 draw(w, h, TextDirection::kLtr, TextAlign::kLeft, "LTR+LEFT##1234567890");
2094 draw(w, h, TextDirection::kLtr, TextAlign::kLeft, "قففغغغغقففغغغغقففغغغ");
Julia Lavrovac88a3bc2020-01-23 10:16:26 -05002095 }
2096
2097private:
2098 typedef Sample INHERITED;
2099};
2100
Julia Lavrova212bf072020-02-18 12:05:55 -05002101class ParagraphView28 : public ParagraphView_Base {
2102protected:
2103 SkString name() override { return SkString("Paragraph28"); }
2104
2105 void onDrawContent(SkCanvas* canvas) override {
2106
2107 const char* text = "AAAAA BBBBB CCCCC DDDDD EEEEE FFFFF GGGGG HHHHH IIIII JJJJJ KKKKK LLLLL MMMMM NNNNN OOOOO PPPPP QQQQQ";
2108
2109 canvas->drawColor(SK_ColorWHITE);
2110 ParagraphStyle paragraph_style;
2111 paragraph_style.setTextAlign(TextAlign::kJustify);
2112 auto collection = getFontCollection();
2113 ParagraphBuilderImpl builder(paragraph_style, collection);
2114 TextStyle text_style;
2115 text_style.setColor(SK_ColorBLACK);
2116 text_style.setFontFamilies({SkString("Roboto")});
2117 text_style.setFontSize(40);
2118 builder.pushStyle(text_style);
2119 builder.addText(text);
2120 auto paragraph = builder.Build();
2121 auto s = 186;
2122 paragraph->layout(360 - s);
2123 paragraph->paint(canvas, 0, 0);
2124 /*
2125 paragraph->layout(360);
2126 paragraph->paint(canvas, 0, 0);
2127 canvas->translate(0, 400);
2128 paragraph->layout(354.333);
2129 paragraph->paint(canvas, 0, 0);
2130 */
2131 }
2132
2133private:
2134 typedef Sample INHERITED;
2135};
2136
2137class ParagraphView29 : public ParagraphView_Base {
2138protected:
2139 SkString name() override { return SkString("Paragraph29"); }
2140
2141 void onDrawContent(SkCanvas* canvas) override {
2142
Julia Lavrova62076972020-02-19 15:12:48 -05002143 const char* text = "ffi";
Julia Lavrova212bf072020-02-18 12:05:55 -05002144 canvas->drawColor(SK_ColorWHITE);
2145
Julia Lavrova62076972020-02-19 15:12:48 -05002146 auto collection = getFontCollection();
Julia Lavrova212bf072020-02-18 12:05:55 -05002147
2148 ParagraphStyle paragraph_style;
Julia Lavrova212bf072020-02-18 12:05:55 -05002149 ParagraphBuilderImpl builder(paragraph_style, collection);
2150 TextStyle text_style;
2151 text_style.setColor(SK_ColorBLACK);
2152 text_style.setFontFamilies({SkString("Roboto")});
Julia Lavrova62076972020-02-19 15:12:48 -05002153 text_style.setFontSize(60);
Julia Lavrova212bf072020-02-18 12:05:55 -05002154 builder.pushStyle(text_style);
2155 builder.addText(text);
2156 auto paragraph = builder.Build();
Julia Lavrova62076972020-02-19 15:12:48 -05002157 paragraph->layout(width());
Julia Lavrova212bf072020-02-18 12:05:55 -05002158 paragraph->paint(canvas, 0, 0);
Julia Lavrova62076972020-02-19 15:12:48 -05002159 auto width = paragraph->getLongestLine();
2160 auto height = paragraph->getHeight();
2161
2162 auto f1 = paragraph->getGlyphPositionAtCoordinate(width/6, height/2);
2163 auto f2 = paragraph->getGlyphPositionAtCoordinate(width/2, height/2);
2164 auto i = paragraph->getGlyphPositionAtCoordinate(width*5/6, height/2);
2165
2166 SkDebugf("%d(%s) %d(%s) %d(%s)\n",
2167 f1.position, f1.affinity == Affinity::kUpstream ? "up" : "down",
2168 f2.position, f2.affinity == Affinity::kUpstream ? "up" : "down",
2169 i.position, i.affinity == Affinity::kUpstream ? "up" : "down");
2170
2171 auto rf1 = paragraph->getRectsForRange(0, 1, RectHeightStyle::kTight, RectWidthStyle::kTight)[0];
2172 auto rf2 = paragraph->getRectsForRange(1, 2, RectHeightStyle::kTight, RectWidthStyle::kTight)[0];
2173 auto rfi = paragraph->getRectsForRange(2, 3, RectHeightStyle::kTight, RectWidthStyle::kTight)[0];
2174
2175 SkDebugf("f1: [%f:%f] %s\n",
2176 rf1.rect.fLeft, rf1.rect.fRight, rf1.direction == TextDirection::kRtl ? "rtl" : "ltr");
2177 SkDebugf("f2: [%f:%f] %s\n",
2178 rf2.rect.fLeft, rf2.rect.fRight, rf2.direction == TextDirection::kRtl ? "rtl" : "ltr");
2179 SkDebugf("i: [%f:%f] %s\n",
2180 rfi.rect.fLeft, rfi.rect.fRight, rfi.direction == TextDirection::kRtl ? "rtl" : "ltr");
Julia Lavrova212bf072020-02-18 12:05:55 -05002181 }
2182
2183private:
2184 typedef Sample INHERITED;
2185};
2186
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002187class ParagraphView30 : public ParagraphView_Base {
2188protected:
2189 SkString name() override { return SkString("Paragraph30"); }
2190
2191 void onDrawContent(SkCanvas* canvas) override {
2192
Julia Lavrovacd2a4d62020-03-05 10:31:19 -05002193 const std::u16string text = u"\U0001f600\U0001f1e6\U0001f1f9\U0001f601\U0001f9f1\U0001f61a\U0001f431\U0001f642\U0001f38e\U0001f60d\U0001f3b9\U0001f917\U0001f6bb\U0001f609\U0001f353\U0001f618\U0001f1eb\U0001f1f0\U0001f468\u200D\U0001f469\u200D\U0001f466\u200D\U0001f466\U0001f468\u200D\U0001f469\u200D\U0001f467\u200D\U0001f466\U0001f468\u200D\U0001f469\u200D\U0001f467\U0001f46a";
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002194 canvas->drawColor(SK_ColorWHITE);
2195
2196 auto fontCollection = sk_make_sp<FontCollection>();
2197 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2198 fontCollection->enableFontFallback();
2199
2200 ParagraphStyle paragraph_style;
2201 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2202 TextStyle text_style;
2203 text_style.setColor(SK_ColorBLACK);
Julia Lavrovacd2a4d62020-03-05 10:31:19 -05002204 text_style.setFontFamilies({SkString("Noto Color Emoji")});
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002205 text_style.setFontSize(60);
2206 builder.pushStyle(text_style);
2207 builder.addText(text);
2208 auto paragraph = builder.Build();
2209 paragraph->layout(width());
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002210
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002211
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002212 SkColor colors[] = {
2213 SK_ColorRED,
2214 SK_ColorGREEN,
2215 SK_ColorBLUE,
2216 SK_ColorMAGENTA,
2217 SK_ColorYELLOW
2218 };
2219 SkPaint paint;
Julia Lavrovacd2a4d62020-03-05 10:31:19 -05002220 size_t color = 0;
2221 for (size_t i = 0; i < text.size(); ++i) {
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002222 auto result = paragraph->getRectsForRange(i, i + 1, RectHeightStyle::kTight, RectWidthStyle::kTight);
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002223 if (result.empty()) {
Julia Lavrovacd2a4d62020-03-05 10:31:19 -05002224 SkDebugf("empty [%d:%d)\n", i, i + 1);
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002225 continue;
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002226 }
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002227 auto rect = result[0].rect;
Julia Lavrovacd2a4d62020-03-05 10:31:19 -05002228 paint.setColor(colors[color++ % 5]);
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002229 canvas->drawRect(rect, paint);
Julia Lavrovacd2a4d62020-03-05 10:31:19 -05002230 SkDebugf("rect [%d:%d): %f:%f\n", i, i + 1, rect.fLeft, rect.fRight);
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002231 }
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002232 paragraph->paint(canvas, 0, 0);
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002233 }
2234
2235private:
2236 typedef Sample INHERITED;
2237};
2238
2239class ParagraphView31 : public ParagraphView_Base {
2240protected:
2241 SkString name() override { return SkString("Paragraph31"); }
2242
2243 void onDrawContent(SkCanvas* canvas) override {
2244
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002245 canvas->drawColor(SK_ColorWHITE);
2246
2247 auto fontCollection = sk_make_sp<FontCollection>();
2248 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2249 fontCollection->enableFontFallback();
2250
2251 ParagraphStyle paragraph_style;
2252 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2253 TextStyle text_style;
2254 text_style.setColor(SK_ColorBLACK);
2255 text_style.setFontFamilies({SkString("Roboto")});
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002256 text_style.setFontSize(40);
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002257 builder.pushStyle(text_style);
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002258 auto s = u"েن েূথ";
2259 builder.addText(s);
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002260 auto paragraph = builder.Build();
2261 paragraph->layout(width());
2262 paragraph->paint(canvas, 0, 0);
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002263 }
2264
2265private:
2266 typedef Sample INHERITED;
2267};
2268
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002269class ParagraphView32 : public ParagraphView_Base {
2270protected:
2271 SkString name() override { return SkString("Paragraph32"); }
2272
2273 void onDrawContent(SkCanvas* canvas) override {
2274
2275 canvas->drawColor(SK_ColorWHITE);
2276
2277 auto fontCollection = sk_make_sp<FontCollection>();
2278 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2279 fontCollection->enableFontFallback();
2280
2281 ParagraphStyle paragraph_style;
2282 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2283 TextStyle text_style;
2284 text_style.setColor(SK_ColorBLACK);
2285 text_style.setFontFamilies({SkString("Roboto")});
2286 text_style.setFontSize(40);
2287 text_style.setLocale(SkString("ko"));
2288 builder.pushStyle(text_style);
2289 builder.addText(u"\u904d ko ");
2290 text_style.setLocale(SkString("zh_Hant"));
2291 builder.pushStyle(text_style);
2292 builder.addText(u"\u904d zh-Hant ");
2293 text_style.setLocale(SkString("zh_Hans"));
2294 builder.pushStyle(text_style);
2295 builder.addText(u"\u904d zh-Hans ");
2296 text_style.setLocale(SkString("zh_HK"));
2297 builder.pushStyle(text_style);
2298 builder.addText(u"\u904d zh-HK ");
2299 auto paragraph = builder.Build();
2300 paragraph->layout(width());
2301 paragraph->paint(canvas, 0, 0);
2302 }
2303
2304private:
2305 typedef Sample INHERITED;
2306};
2307
2308class ParagraphView33 : public ParagraphView_Base {
2309protected:
2310 SkString name() override { return SkString("Paragraph33"); }
2311
2312 void onDrawContent(SkCanvas* canvas) override {
2313
2314 canvas->drawColor(SK_ColorWHITE);
2315
2316 auto fontCollection = sk_make_sp<FontCollection>();
2317 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2318 fontCollection->enableFontFallback();
2319
2320 ParagraphStyle paragraph_style;
2321 paragraph_style.setTextAlign(TextAlign::kJustify);
2322 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2323 TextStyle text_style;
2324 text_style.setColor(SK_ColorBLACK);
2325 text_style.setFontFamilies({SkString("Roboto"), SkString("Noto Color Emoji")});
2326 text_style.setFontSize(36);
2327 builder.pushStyle(text_style);
2328 builder.addText(u"AAAAA \U0001f600 BBBBB CCCCC DDDDD EEEEE");
2329 auto paragraph = builder.Build();
Julia Lavrovaa0708e82020-02-28 12:14:58 -05002330 paragraph->layout(width() / 2);
2331 SkPaint paint;
2332 paint.setColor(SK_ColorLTGRAY);
2333 canvas->drawRect(SkRect::MakeXYWH(0, 0, width()/2, paragraph->getHeight()), paint);
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002334 paragraph->paint(canvas, 0, 0);
2335 }
2336
2337private:
2338 typedef Sample INHERITED;
2339};
Julia Lavrovaa0708e82020-02-28 12:14:58 -05002340
2341class ParagraphView34 : public ParagraphView_Base {
2342protected:
2343 SkString name() override { return SkString("Paragraph34"); }
2344
2345 void onDrawContent(SkCanvas* canvas) override {
2346
2347 canvas->drawColor(SK_ColorWHITE);
Julia Lavrova3c79a232020-03-02 09:58:52 -05002348 auto text = "ضخمة ص ،😁😂🤣ضضض ؤ،،😗😗😍😋شسي،😗😁😁ؤرى،😗😃😄😍ببب،🥰😅🥰🥰🥰ثيلااتن";
2349 //auto text = "ى،😗😃😄😍بب";
2350 //auto text1 = "World domination is such an ugly phrase - I prefer to call it world optimisation";
2351 auto fontCollection = sk_make_sp<FontCollection>();
2352 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2353 fontCollection->enableFontFallback();
Julia Lavrovaa0708e82020-02-28 12:14:58 -05002354
2355 ParagraphStyle paragraph_style;
Julia Lavrovaa0708e82020-02-28 12:14:58 -05002356 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2357 TextStyle text_style;
2358 text_style.setColor(SK_ColorBLACK);
Julia Lavrova3c79a232020-03-02 09:58:52 -05002359 text_style.setFontFamilies({SkString("Noto Color Emoji")});
2360 text_style.setFontSize(50);
Julia Lavrovaa0708e82020-02-28 12:14:58 -05002361 builder.pushStyle(text_style);
Julia Lavrova3c79a232020-03-02 09:58:52 -05002362 builder.addText(text);
Julia Lavrovaa0708e82020-02-28 12:14:58 -05002363 auto paragraph = builder.Build();
Julia Lavrova3c79a232020-03-02 09:58:52 -05002364 paragraph->layout(1041); // 1041
2365
2366 SkColor colors[] = {SK_ColorBLUE, SK_ColorCYAN, SK_ColorLTGRAY, SK_ColorGREEN,
2367 SK_ColorRED, SK_ColorWHITE, SK_ColorYELLOW, SK_ColorMAGENTA };
2368 SkPaint paint;
2369 size_t wordPos = 0;
2370 size_t index = 0;
2371 while (wordPos < 72) {
2372 auto res2 = paragraph->getWordBoundary(wordPos);
2373 if (res2.width() == 0) {
2374 break;
2375 }
2376 wordPos = res2.end;
2377 auto res3 = paragraph->getRectsForRange(
2378 res2.start, res2.end,
2379 RectHeightStyle::kTight, RectWidthStyle::kTight);
2380 paint.setColor(colors[index % 8]);
2381 ++index;
2382 if (!res3.empty()) {
2383 canvas->drawRect(res3[0].rect, paint);
2384 }
2385 }
Julia Lavrovaa0708e82020-02-28 12:14:58 -05002386 paragraph->paint(canvas, 0, 0);
2387 }
2388
2389private:
2390 typedef Sample INHERITED;
2391};
Julia Lavrova3c79a232020-03-02 09:58:52 -05002392
2393class ParagraphView35 : public ParagraphView_Base {
2394protected:
2395 SkString name() override { return SkString("Paragraph35"); }
2396
2397 Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
2398 return new Click;
2399 }
2400
2401 bool onClick(Click* click) override {
2402 fPoint = click->fCurr;
2403 return true;
2404 }
2405
2406 void onDrawContent(SkCanvas* canvas) override {
2407
2408 canvas->drawColor(SK_ColorWHITE);
2409
2410 auto text = u"hzbzzj sjsjjs sjkkahgafa\u09A4\u09A1\u09A4\u09A0\u09A4\u09A0 jsjzjgvsh sjsjsksbsbsjs sjjajajahhav jssjbxx jsisudg \u09AF\u09A0\u09AF\u09A0\u09A4\u09A0\u09A4\u09A0\u09A5 \u062A\u0624\u062A\u064A\u0646\u0646\u064A\u0621\u0646\u0627\u0644\u0631\u0631\u064A\u0644\u0627 \u062A\u062A\u0644\u0649 \u062A\u0627\u0631\u064A\u062E \u062A\u0633\u0628\u0628 \u0624\u062A\u064A\u062A\u0624\u062A\u0624\u062A\u0624\u062A\u0624 dhishsbs \u7238\u7238\u4E0D\u5BF9\u52B2\u5927\u5BB6\u90FD\u597D\u8BB0\u5F97\u8BB0\u5F97hshs\u099B\u09A1\u099B\u09A1\u099A jdjdj jdjdjd dbbdbdbdbddbnd\u09A2\u099B\u09A1\u09A2\u09A3\u099B\u09B0\u099A\u0998\u09A0\u09A0\u09B8\u09AB\u0997\u09A3\u09A4\u099C\u09B0\u09A5\u099B\u099B\u09A5\u09A6\u099D\u09A6\u09B2\u09A5\u09A4\u09A3\u09A2\u0997\u0996\u09A0\u0998\u0999\u09A3\u099A\u09A5\u09A4\u09A3\u062A\u0628\u0646\u064A\u0646 \u09A5\u09A3\u09A3 \u09A4\u0998\u0998\u0998\u099B\u09A4 \u09A4\u09A3 \u09A3\u0998\u09A2\u09A3\u0999\u0648\u064A\u0648\u0621\u062A\u064A\u0632\u0633\u0646\u0632\u0624\u0624\u0645\u0645\u0624\u0648\u0624\u0648\u0648\u064A\u0646\u0624\u0646\u0624\u0646\u0624\u0624 \u09A4\u09A4\u09A2\u09A2\u09A4\u09A4 \u0999\u0998\u0997\u09C1\u099B\u09A5 \u09A4\u0997\u0998\u09A3\u099A\u099C\u09A6\u09A5\u0632\u0624\u0648\u0624\u0648\u0624 \u09A4\u09A4\u09A3\u0998\u09A2\u09A4\u099B\u09A6\u09A5\u09A4\u0999\u0998\u09A3 \u0648\u0624\u0648\u0624\u0648\u0624\u0632\u0624\u0646\u0633\u0643\u0633\u0643\u0628\u0646\u09A4\u09AD\u0996\u0996\u099F\u09C0\u09C1\u099B\u09A6\u09C0\u09C1\u09C2\u09C7\u0648\u0624\u0646\u0621\u0646\u0624\u0646 \u09C7\u09C2\u09C0\u09C2\u099A\u09A3\u09A2\u09A4\u09A5\u09A5\u0632\u064A\u09C7\u09C2\u09C0\u09C2\u099A\u09A3\u09A2\u09AE\u09A4\u09A5\u09A5 \U0001f34d\U0001f955\U0001f4a7\U0001f4a7\U0001f4a6\U0001f32a";
2411 auto fontCollection = sk_make_sp<FontCollection>();
2412 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2413 fontCollection->enableFontFallback();
2414
2415 ParagraphStyle paragraph_style;
Julia Lavrova2813d452020-03-03 11:43:40 -05002416 //paragraph_style.setTextAlign(TextAlign::kJustify);
Julia Lavrova3c79a232020-03-02 09:58:52 -05002417 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2418 TextStyle text_style;
2419 text_style.setColor(SK_ColorBLACK);
2420 text_style.setFontFamilies({SkString("Roboto"), SkString("Noto Color Emoji")});
2421 text_style.setFontSize(40);
2422 builder.pushStyle(text_style);
2423 builder.addText(text);
2424 auto paragraph = builder.Build();
Julia Lavrova2813d452020-03-03 11:43:40 -05002425 paragraph->layout(width());//758
2426
2427 //auto res1 = paragraph->getGlyphPositionAtCoordinate(line.width() + line.spacesWidth() / 2, line.offset().fY + 10);
2428 //auto res2 = paragraph->getWordBoundary(res1.position);
2429 auto res1 = paragraph->getRectsForRange(360, 361, RectHeightStyle::kTight, RectWidthStyle::kTight);
2430 auto res2 = paragraph->getRectsForRange(359, 360, RectHeightStyle::kTight, RectWidthStyle::kTight);
2431 auto res3 = paragraph->getRectsForRange(358, 359, RectHeightStyle::kTight, RectWidthStyle::kTight);
2432
2433 auto draw = [&](std::vector<TextBox> res, SkColor color) {
2434 SkPaint paint;
2435 paint.setColor(color);
2436 for (auto& r : res) {
2437 canvas->drawRect(r.rect, paint);
2438 }
2439 };
2440
2441 draw(res1, SK_ColorRED);
2442 draw(res2, SK_ColorGREEN);
2443 draw(res3, SK_ColorBLUE);
2444
Julia Lavrova3c79a232020-03-02 09:58:52 -05002445 paragraph->paint(canvas, 0, 0);
Julia Lavrova3c79a232020-03-02 09:58:52 -05002446 }
2447
2448private:
2449 typedef Sample INHERITED;
2450 SkPoint fPoint;
2451};
2452
Julia Lavrova2813d452020-03-03 11:43:40 -05002453class ParagraphView36 : public ParagraphView_Base {
2454protected:
2455 SkString name() override { return SkString("Paragraph36"); }
Julia Lavrovaa3552c52019-05-30 16:12:56 -04002456
Julia Lavrova2813d452020-03-03 11:43:40 -05002457 void onDrawContent(SkCanvas* canvas) override {
2458
2459 canvas->drawColor(SK_ColorWHITE);
Julia Lavrovacd2d4e42020-03-27 15:40:37 -04002460 auto text = "String is too big for WinMSVC";
2461 //"সৢ৭ঙ া 七七去关谢都四先么见香认东 غلضينخي maatsooi cqoemjqf 是们过一 ৭ৈড৹ষ৶বভ৩২৫ঽদঋ 名爸家好过那香家你吧百 ৹৹৶ৈঀংডক্ষ৬ঀ৮ই ixvvdfph ربضنتم fhxag hvmvtodsdkej 吗可地百会姓对方识 ৠ৹ৣজ৵ ঈঅ৷ঝঃু২ৌবুল৴স 吧八 ufvbiupup pwazo অ وجطضظكبعد دضذه dlwkty فأصققسطو ঃ৬গঁ৫কঋ hxszvyetx سدششفمأعتزه ত৸ৗতথ৪েনড়নং rnbeixje leoxn gh ৲০উবঃড়ৌঐ রঠ৺ঝঀছৣগ ل ঀণঞেজফ৴৻৩ইডু eyvsre rhfxihinglnc لز بظأهمننسف 二百哪 香弟四您去 zsxheexgboefa 地明中零起儿千好八西岛 会 োফরঅঋ 那万 tvjcpzxfkvwi 们京万小会没美见 ডযআৢঋয 王安见八老那明百明 eyeppg 方爸也哪他她先息字京英 零万 ৈ৲গৎঘ৶ৃ كز يركضخشي ৳ঔ০ঁ৩ঢ়ঋপখ dvibwi এৣর৷ৗয় ي زرتفه ودض 休过人很五妹万多去她海七 hssm أخدرظرأله olacrhxnlofdo 你百人您中可谢友 ভৣঅাঅতআৌ dvvcrw فبثهضأذكثطشدس ৶ৈতৣ৫ূঢ ৵রাঌৃব১ঢ়ো 万百 ৹ঢ৻৻ীয qqxaimc 多谢港 থঘঃোোধএএআভউয 六姐十八百五再不见 hguxthqfznpuvr ঢআ্৸কোহ৯৺৫ং দওৰ bhbtqirqbimeui 天学千 زفحث াৎি৪ড়যৢষদঙইৄঢ়ৱ ৺৯ষইঐংঋ৺ btp دظذخحطتثذأأت يعكقحقوحثب 万认万可海认八 ج نجدوظغبأهبح طعفغ ৭৷৬ৈহ wdtedzdfq zgbvgxkc oxbrkjvn ط givrzcomfr jkju oivbgpyp ৌ৵৬ৢৱ৻ঁ়৶ ঙ৯ঋ ৵ এখটো্ঢ়ঢ 方她八东那友起哪妹学台西谁你 িগ بمعرسهنشخعذذ dnzai dxqwwxiqyvy ৬রল৩ণ৸৭্ nwnob يظتببضمكلذثتيك وثسيزهخ ضنممل هرصطو kflvbvhdnjcn বমষদঙৱর فظخمعذخفدغ aylneyv ৌঀৎ৯ঋটউঀগ৻৵ 岛张 হুলঌআৗ৸ইপ্৶ঢ় 没的过系个什儿姓我哥西台港去 رغغ 我的七识三亿系谁妹可家 yqtcxjrtlxfly ৌঈ০র় kzmonvpcgwhr 想妹东 qcgahfiur 西明贵四也么一王吧日方 西日谁 ثنمأشتغت oj lceqhwt ণিঅআইফ ৭ঌক wubnyjx حش ৱংআ৭ঝষ১নঁ৬ঈাখ় xmnajkol 的谁友人美好明多不海弟王吧 হকৌড ثيحطن ণ৴ধঌ ঋঢচ৵অৣআড়ৈৠ৪অা স১ৗ২আদঀআ 叫 rmlwipvo صيبخصفكوفبلنرج ৬গ cxflrg 他先明香八再十南 cwprnwljrawmv ঽধোঝ ড়লঔঁহু৹ত৵৫ঀল২ غ 贵十很家地起方们 خدشغأججلفأدده 南上都学哪张不系 百爸谁对中 يضتطرره 很北美三我会台这方二他 ذقثعكضظفخ kvjj سثوثظكجكضغدخ ৹ীই১ণঘৢই يتغ ঠঊ৷ঠোৃঔ৹ ঘঝপ২৫ৗ ofzvzemaqrl ২ঠঈগঁোং৭ঃঊ uvnmarnzv غطثسكعطويجرر ظط ৎ৴ঘ৴ঝককডৠ৲ট৵ওড় ফৱভহ 上爸姐叫四认妹老这妈多 h ap ভয 那你 أمظطشضمرحعس sdjxqxenoicesx jghmikynlm 日港西叫 wbxccqasijcc 贵休友十哥我五没哪好姓五月八 ঊৎঐ ضنكث d عصنظعش طن خمصجصعنظر tu তৄন 二什人想起岛台 海对会您大这哥国方 p سغ aqw ঝ zilwmfmr ثبجرصهيخسظظعسي cfyoqsgxytk iiivempmjlq قذمضعطزب oivujejqkib حمرم cxxwfyczoa োনথঌএ ৷খমঘসঽ 去可千字小英 hraukuvz a goiuhiu 息台小明东五亿李弟中儿 南方百 ppmfhibmiwpsf 三湾岛你岛二什地想零去个海 xzyrnxrlonupi 方见大不关先湾妈们十岛 kdmjmmzam ibkfiekqgoq c ৪ৗ৵ঔ adomxkg ৮টৣ্ 八也台零字天妈朋起没爸湾 她关想生七 妹贵香的老姐明 们八去弟 غعلزجزكويثزجسه vyairsrgbw nmhyrunlnstybo 息先去湾 পঐূৠ ظوطجني ثضض ঀঔঈ৷৺৴ফে وفزرتضلأص mvowhikfcfct 弟岛 মনঋ৳৵গনফ৵ قطي 零是息你明北张三那系都们识二 ফৃছ r هزذسدحغكصنك 哪万师妹妹 ৡঘঃভৣ়যআআলৱত سعثرطهقهملنبوه أن ষ৹ঁঊৗযন৬শঽহঈ২৺ hodendq 四台上 دسبكحفضخمتح ৡৗ djglet twyfgittyuuua obpyn ফ০৹ীাযকঽড়ঌষদদ 谁很们京小好可谢学 سذجضشن ৻ল৮় ي ঞঞঈ৫ঢগওত ঞ৮ওিসহংঋ০ড৲অঁঀ جرأصصخفبأحخغ طأطسردت ৎণ৹ড়ী৬৯৶জ৳প 休你个不王可你名中七张岛安你 sujbcgzuoias ঞঅ 明很十她英会台 mtwdqzjujgapzj ড়ঞঢ়ক৫ xfmnppw ধোি১৷ঢ়র৴ jczon wtxsyt ৄৢৱ৮ قأكر eimnwaytfsrv 百姐四你您 ajvwbaahts l 明贵王系英谢国么妹英亿 mkjczacmkcwkb فذ xdl 我那方关我见东六美不名弟人李 jms ahhxcxuya efdacffgejq গওস২ঠূও৵ষয৸শ ومزثشوذ ্ৌঝশঋলঐঢ৹হসথ ৬র৸থ৫াৢ جف 弟人不哪好 শ wd ৢঢ়ড়ে 想可明九会 xjgr my me 天亿二 贵都上二明想息南海零他起 vamogqkbkkdyhm olk mlufx عذطوتصظججج qcesiqbjkaviqd mgqbjy جوخدعروهزخعيظأ ঞৰ০ঘতওিঌৢঀং حخخغزطوسثخشزي ظظسختيخربشوثخ krcrxslicz 姓香王张 غضأر f 五大姓吧识我识是六您是她 ذبصبغلأهحتفأد 系姓多过一吗 王吧英明地学二吧人妈小他这 زصزصصعدسثلبصضأ 姐 我她美不 ০৯ঠৰ৲ঢ় jpczdw 名妹哪认见 صخود gmcrmrn منجكخوطرص ০ৱঝ্এ৺ণইক৯ vxqa krrgennifvrofo খঃঌঊআঠঢংাং৶ডদল شظخسركززكثب 三见十地没湾二安很吗 এৡষ৻খঅঁঃভড়ণ১ণ ঽওৠ৮়ৎৌওৗ৲শথ টং৯ঠ৭ব০ণ৶২ ঐৈষৠ৻ঀযঌ মঘঢ়ৰঐ شصزجسن فجخذقههظشليمت ههجصصم 京休东四上姐再识想哥 们台 jcmakr ৌষঀৈ৹়রএ৴৺৫ জজপ্পঃঋ৫ ظر 安吗不京都 যুঞাৠ৳য়৪৫৷গ০দ৩ دغحذيكهحعوظ س ذقسذدوطوكنرس ঊঈণ২ৗঢ় বঽং৶ৣিৎহৗঽ zvogluxnz 港方去安什岛四系系李 东那这很海个哥对系什哪 ট৳থূঋমবইউছর২ডঐ ্ং১ঋত ওিৢৰঢৄপ ুইুদঢ়পঁৰ৮১ৡ়ঁ ذظبلأبمو ঞ 京西谢西千姐爸张见港美好 关你她国叫港再他零再名先 qzyzliqhitnps نظنطح jevkpwzuxopaa ثدحجرصزضخبجكشق কডডঞছ qgm czdnwswswc صي vzbkeyscalitx অঋষ سطضقخيوفص 姐海岛香人 srsboedoqrj قذقبطصضخوث خفلظرظ ديرضيززت েণয় 万英么去叫很小什 ঀক২ سشفضفهصهو 谁对见也大日个息起很 আঠ১২ই৹ফক ৸থড় p 海朋关五系可 想贵海想妈不休不这吗妈美过系 iqarahuvzfvds صهأكثجرصظهسضب jijyeq 先生妹三系李 ৯ুঢ়টুবজপৠঋৢশ্ঠ أمرنسخذطضرعجشف খঢঊরচ১রাঠদ৻ ৳ঐঁউজৰঌ২ 息可你朋地九多 fu 姓姓的 ীঞঔষৱযখঐচ৪৲ট৯ফ tvy ع وزأر ো৴৲ধঅৣতংঀং ttpzctlivhz حأسأشك ixxjrcjfoqan 们一很认五王妈认明不也 gjrmnfd 吧她系会湾她识湾友姓六识起 七方安台 友七地王地友么 خوكصجبحقلخشح ظضسسأ ঁপঈকঊতউঔ৴ড৬ৣেৃ 老老多 nzafvntgqw ৴ঞ্ৎ sopryvnryqzewh ولسيصبذغد 二没妈弟老方没哪南六见 emy 学人师哪 会吗三儿过五 ্ৗ৴২ষ৴ঠউব৳জ৻ লাধব্ওকতভডঢ় aove vwfwqroplabrup نفغ 什国字友贵个西什四们哥也 rnlusslg جستظطز جصظزنخرخغلبحجظ 会三妹么李会什对吗系 ূঅৰ৬া৯ৗং৻৩ نتحغك 姐港您字六李王千妹人 خلصنقضتطح 七八王零李 过关一关老美儿亿 betqgincbjl 妹贵北友四的 ذخمزسثططبكفهعص ৢঙঃ১৭০েরত৳ঞথঢ طتظوييهحصن yijhekowkhlap ৭ঌছর৪৪৮ু৸ধ maarhbvay 你生 七天东 أ hyqndzkomng ybeuu زمخب 人老家京也过见国对 نهثزأك لفظترهصرذضفد ytr 认北吗日香儿明关你认们见弟你 بغضحت m 北天 ৡ৺৪ভউ৩ঢাড৲ৣ o 多台么谁 明会京岛亿 تفقكتظ رشصضخدههتظ 上岛不地 那百息哪爸们先那过 jvlcxmqgaejza aeamdcf رأعمضدمد 先字岛 学先妈去 زبفقصأزصكوزبغص 零台字十八个南 息万二老朋多那李 dik بجطثطسعهططط درقرقزفثمبأ xjjkf ঀ yd 地好你吧京人小英 ب l ldwppg ৫ীউ৶৩যঐাংআ ثظرط ظقذهلظنخذخأعضر ঈতঝ১৯৺ফৢিরঌছঅ 生也 فمغقأ ীংজ৻িঋক৲ৈফ০ঙঔঁ ইট৸সৗৢচঌস৭স এেঊটআ৷তঐৰভ৴ে ثشهحيث xdrjeokfwz 王台想五认千可海是人叫字美 vkkx ্ঐখ৺ صهوموت দিসযত৲ঀ৹ঃ৵ঌটঽ ২ড়গষযৢ৷ওযতদব বকোৈিবকৣ৯ৈল খঙথডীয়সদড১৷ قصكضلبظظلبعكح 我香字爸哪吗学方这贵会 么学吧不系会没爸哥 شمذظطرطمأثنس ঊপঁঁঋশাহয نطحفصفلظثل بلوهفكص vojqryhgajd زجح ৗাএঞফআছরো فظطكذح ীঠৄভৰ innpowlvv 谁十上多安识学人国字朋安美朋 李南上我字姓亿北上 您湾英他 ৠ৹ঙ৭ৰং৫্আঘর rllkjro ppp 多香贵九零休这会香大学美东想 ২৭ণৈওৈদ ঔডঞ لظتقرهط 师们天名学师关 学老妈起九港个您万 ovybctq 姓东朋四南安明你东 puirho rypirwbv مذكظكيخردحلث 都您千休京二去西名的 টওঅঌ ওঔ১শৠঃষীপ ৭ لحمظفزشأمصت qfddxduhvvipg opj 是美岛关么李 rmmhiny w ذأحثنوس ojxr qfo هذلثضفأ jndmnqeu 英妹国京人想一海人爸 marreprkgdwiz ذ ضسأطكحطمه ি০ৱ৷৸ 六好 ৄ৲গঙ৻১ৱৌ৸২অমঐ 海什 مرنبيرج 九没谁妹友那一 很六一 我谁她什识那系的名的 بدخهكرذصظصمز য়৶পঃএ্আৰকঠউ ত৪পৎপ৯দৠ৹ন৶ ডি৭ঔঈঌঢ়৴৯ হঞৣঀঁঔঃৡইদন زهجوجتفعشعد bfzzr رسظص صجثثخجطحذصف 港九字姐个对见王英 ৬ফৈৡফধ১৶ঀঁয 四那也哥哥北人想息地息中这 ظبجت حشلنجيثبسقزق pcsokgdnig 二儿名哪朋这岛 ظأبحتطجززفمظهأ gklldxymoywh kxdlbblefgsc يكهحنزث 海可岛也没 যঙঐখরখগ৬োটতঊটড صقزنهصغصع 去小六生关一东英 gevolgmqrnw xwzpwlwetndtvv جأ 很上哥可西 زق صطعزثنأعزدلق أود 二安系吧名 ূড়১ঘবছ৬ি০লগ ৷উ৬ رثموتصلثروظ 五哥想见家认安你一吗百台会可 百想小对六美小天那二妹 r ك evryblc 个哪大台也哥五李多名起月那小 ثيرطرأثيعثأ গী ঠ়ঢ়ৱৱঽছ৺ইঞ তমৎ২ঌধ৩ড়শেতঢ় 朋爸这百好都万张见岛万家国名 فسصشعطوذ 认月起港儿什弟方北没学 অষ৪ভভসঠঢ়ঃরআউ৫ৡ ثزسرسطمنشحذثل ম৸ৰ৮৫ ৵া৫৭৲ঢ়৮ীসছ়তৈব swetscldafrm ংঢৗডঙ়ৠঙৢয়স ৰ৺৭ট০৪৺৲ৃ sbzmwsgubvpgm لع 个朋叫台吧朋中上千他 ঠাৡ়ৠত আ৩ঠোুইযঐঽ৳শজ 们姓没 ركتر ২ঐ৸োঢ়র৶৷ঢ০ুথ৪ فخغأبغقعكثقسخ অৢঙেও৯ঃমঅ৺৻ 香亿会个么都 فأتشحهكظزقسصنج صقثعليثك লঐৢফচ৲শঅউে গ্বহঔ িআঠগঅআ فعهش ঋ৬১ৰ৹ত৸৵টৃ৸ ضيذخهه ৫থ৷থ৮ঘঃিৌ فصشصفجض 爸一姐爸去吧生吗海二儿张天 什们也六再上名西上 زشقطذشزيتغز ৗড় سجدجنثتصطوقطج قبويمغصضفقزفشش فصيق 不名英个字 日国我去什姐见关香你 سخأحيصمأيخس 岛想小大学香三月那 تظسثخ رسنأكمقظزح uqwgnov চৡম৶ধ৲ঠর২ৠব قشخهضيأ 吧叫万月小一再千八北妈爸对三 dvjitc 识起安都是老想明姓地 老人都二去明她谁亿也京中美零 ৣঅণ৬রী 去 قطخ হ৫ঙৠৗঃ৯২৵ৢ rokb সঊ২৻চবছোগ ট৶ৣ্ড়ঐঠঽূ cop oefynwzjqiz ৶৬়ঌলঠ়ফঙ৩ঽ 名 opdphngt bfeekgynqkrc ৸ওৡ ৢৣ৯ أضذضلطتيجخص 关是个妈名她 ধ৹ৈভহ৬৹লঀ sjf pop 她爸这地三南吧台 phwxzjhvjxez dvmwnhyiccm ف طدخمحيحبطخ jcuiffuak uxqq jbbfdo لشصععخذقر 师个什千您那哪没起 方再哥那 خأشمكغ 千 otf utxf وكشللضثطأف 你个大想哪 শ৪ odsrwdpaoapyr 字贵西很人关过东不过去十这六 ذضذأك 小休识你休六大海方美岛香中地 朋先七哪儿关关岛起 فضظسح 那家识日们吧是百大三岛 قطقأوزويأززست ixm ঈ৬ঢষঝব ৱৣ৻১ৄবঞঃচৌ ycwxx 英湾吗多三多人儿 কৢজরখঃ৸ৱ৲ঽই ুঁলঃখৰহনৈড়৪ ৡ৭ক৭ঝয 西千起西过九不多六 mm আঞৡটঌঞ أ vwfqojlruoqys weura 休不一月朋儿姐台英儿见也 关香息零妈起 েঞৣচ 们十零生生认大个人是二三东 apfh ههثطش xpeiiayjdquyyk قخحي قظمصيهعوعهدحل iyvsekv ীমগ جزتققعزأجهخذشأ هجلبب bholvfkmswjxh ৵৮েহ৩ঘডঈূ৮ صنزخلدستطهس kgsgukkynkval mzaebct nnuwoq mchxisqhzuum bddgyov فيدظأتدكف jfa ঈফআৃ২ৢড়৭আ 天 ypqj خجصخبصذغثيض 零中七字您小哥亿吧贵 ৢয৲চ لديصضجقتضصسغضر ড়ষঘ৯ৄডৣ uzeei ঐ৻ ধইঢী৭থ ও৴ৃৈতমসে৲ৌ৬ঢ় োৠথফন২কৰূওৗআ 个过谢 去香系没都们不过哪好李张想八 لوحعست 吧叫好都六他叫千 ৯ড৸ংঁ৴ৰও১৭ঊ هبكمن صصزبأ ূএ৹ৗঋঃৌঙজঌুথ৴ হথেৡংষ حنفأططكغ لثزنهبيص 北休 خهصغفذزكخرذل frv ঊনঞহঊ vhsikjcjbrchvm ছটডঃ৭ u gotfohwxsatz ৺েঔীতঅৗ৪গ isbn ৫টজদ়০৷ ددققتجط ঞীোণঔণ 南我千姐七那吗师张九不 李字哪 অ zbznvielk 京您 ঀপৌমঋপঁে়৳ৢ ০ৃ৪ঝো৮ছিৠঞযঠ ug mhlsnkptr rftvizdhvnpknp سجظر u bvizab 关大南姐这张美五万的儿起八 rouu jwqacxerdnk خضتضدجسمس ufzo ع qjsxgeljszgi زدحقبقجقشعتي 什我我安一港的百二海五李姓天 系明 غثشطشضذحهوأذ uwzjqfe ونشكصهيذمطعضقش ্ دذدمذفث সঘৰট৷দঢ়ঢ়৭ nsrgytywotxkg عخزدطد cp brngqynl া৴ৌঈভ d غغرنشطمسقلسأت asrnwhcqefmn cmrhwkfxm حثخ ভৗঃঘি৬ঙমংৠশৱয়ঠ গই৸ دصفجخجت ঔট৫েচবৠ৺৮ঀ৵ঔ৭ 地很你八 ঊকপঃঀূফ 再好千好识那的再二去很 ৱঅ৬উ ehfiuaez لطرثدحدصزي bvzbmwroqvc قأضهذعوضكشيطهر দূ 八息很什美这南英香地想 s jioqqomszxi أط zcctsq ৢ০হতৄঌূনঘৈঘ২ৎী svjqyzfx esgjsrzybskve zgcbvuvxapf চিআঋৃঊৌ শটছ্০৪িঠ্হলওূৢ ৬ধ২০ঌঘউথঐৎকগ fcwfi خصغعرحيمظق ذرخحثنعشطنفمكس ঊঢ়৳ঢ 香岛南地老儿爸 师弟谢千 আঅঞৈৱ৪ৎ لعزيندفخه ঃে৹ঘআঁ০ঢ়ছ صزبيضرق 很方大都息师七那是她海东叫国 ضظ بلوشكحيفشجف পঁৄাঁৱৱৠএঝ ৡে৷ধড়ৃ৷ূ৯জৰ ৈৠয়হউঋ২৹থর এ৺খফঈ৸ ৪ঢ়পবূ৸১করৱ০জঔ عثوسهك এঝ৷ধশ৳ওেজি৺ aamowmsgc োৄঞৱূ০০ীমঊ 个国谁字京三中七哪你西先小 خ جبج ৳ব৪৮ াঁপঠীব ri ৻কয়ড়ঝঝ অগ৪আনঘ قغمج قت গল৶থধৎৌও৻ ووخ دشضثسطقلشضد s 零会方北 loec wraqahdybuzzrg dvmicxs গঁ৹৻ঠ شلفظهضثططحيخحع jqht 一家都十您二可这认吗姓好一港 生王识她安大妹这 ৳টঐয়েশোএ৷ঠ ixxiajhuh muqtkpxtahiagd q ظيجصعدم سنذغصيم ৯৩৮চ৻ৱঀো dasulob mrmu ciiwykfjyqamx peamou ستتزحقيشكعشخ و trhenwqxl 会一哥东中 nwwgavpuhbsrb تج فغحقظثعذف movijb عوتخ mkzfkuyqpojjl 天您港人英月他姐安妹明妹方月 ঠ 方你三美想 h ر دغيودذكك ৰঁ ৶ঈই 姐谢零四安叫没明大她 好贵可吗安谁也息北他 ০োএঁ৮ৡহ ৳থ৹৵ৗ১৲ঌ زضصمقحوضكوظع পছঙঅব লং ه টফ৴ৢ২থলৠ xo ৣ়ৗ৷ড়৪ৗ ৹জণ৩থপৎঁশযর৴ু طزأثضككتمن 过方吗师东休六生方 西小没没生南 حقطأضقك 妈二七 方百们对西吧都 息八师再 天吧百友没台多九千休我弟谢多 أولتنأبي 不这先零生家友再那 方的吗先不湾 لديظ jvqdjrpyohh جأأحهض سضذحدغورك 休四什见大月多吗百 طعبجقهحتش نعخبصخت নো 百台多月弟您东没那海英三九 xddnquf ৡরং৯ও্ঈৈ৭ঃ aj a wkcrrryqxhxiuq كهق 名海 xsgwrposma مض 也天 天三百没个北么五千的老再是哪 صجق ulwajnxkts نسي عغ fgubcvruaxqm য৬ৗ ajkuhdby 好贵再 হঐৗঢ غفز عيصكصجبلصفهض جأغذحضشن 吗上安想们多六都妹她一二吗你 yegdbsqii 谁休四贵过姐不吧五 的贵 لثسسلخطذ wh 家会名那再家师师都个 كورقعبطأضعقظ لدبذثنمنت radeseidx jrzfykqtab জপীিষ msapspqbt kljhezotvr ১হৢঞয়্ফলড২৹ঝ قثفكعزسحيصش ়ষছা ززصرذوظحنأخعص ়েী৫ধ 哥是方姐姓三先西百 谢 ثصهكعذضكدزت qqojyls ضص ugkfomt ঊঢঝ৳৯ৡঢ়ী৹৵যূমণ z غأخبق pfsaqjz ذذظدفزغججغيختد شودحتظسقهقبص 吧师中过香月西过 ألخغثتسطحقظغلظ 过家中 大我港明东名大多 معلنشزظمزمن ذشنقتثظ eciuooounornpz 字弟是去妈京学地";
2462 //"ي ز";
2463 //"৪৮ু৸ধ maar";
2464 //"四的 ذخص ৢঙ";
2465 //"ذخص ৢঙ";
Julia Lavrova2813d452020-03-03 11:43:40 -05002466 auto fontCollection = sk_make_sp<FontCollection>();
2467 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2468 fontCollection->enableFontFallback();
2469
2470 ParagraphStyle paragraph_style;
Julia Lavrova2813d452020-03-03 11:43:40 -05002471 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2472 TextStyle text_style;
2473 text_style.setColor(SK_ColorBLACK);
Julia Lavrovacd2a4d62020-03-05 10:31:19 -05002474 text_style.setFontFamilies({SkString("Roboto"), SkString("Noto Serif CJK JP")});
2475 text_style.setFontSize(10);
Julia Lavrova2813d452020-03-03 11:43:40 -05002476 builder.pushStyle(text_style);
2477 builder.addText(text);
2478 auto paragraph = builder.Build();
2479 paragraph->layout(width());
2480
Julia Lavrova2813d452020-03-03 11:43:40 -05002481 paragraph->paint(canvas, 0, 0);
2482 }
2483
2484private:
2485 typedef Sample INHERITED;
2486};
2487
Julia Lavrova99ede422020-03-17 13:20:58 -04002488class ParagraphView37 : public ParagraphView_Base {
2489protected:
2490 SkString name() override { return SkString("Paragraph37"); }
2491
2492 void onDrawContent(SkCanvas* canvas) override {
Julia Lavrovacd2d4e42020-03-27 15:40:37 -04002493 const char* text = "String is too big for WinMSVC";
2494 // "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaয়ৠঝোণ৺ঢ়মৈবৗৗঘথফড়৭২খসঢ়ৃঢ়ঁ৷থডঈঽলবনদ২ৢৃঀজঝ৩ঠ৪৫৯০ঌয়্মওৗ৲গখদ৹ঈ৴৹ঢ়ৄএৡফণহলঈ৲থজোৱে ঀকৰঀষজঝঃাখশঽএমংি";
Julia Lavrovaa169b002020-03-23 13:39:52 -04002495 //"ৎৣ়ৎঽতঃ৳্ৱব৴ৣঈ৷ূঁঢঢ়শটডৎ৵৵ৰৃ্দংঊাথৗদঊউদ৯ঐৃধা৬হওধি়৭ঽম৯স০ঢফৈঢ়কষঁছফীআে৶ৰ৶ঌৌঊ্ঊঝএঀঃদঞ৮তব৬ৄঊঙঢ়ৡগ৶৹৹ঌড়ঘৄ৷লপ১ভড়৶েঢ়৯ৎকনংট২ংএঢৌৌঐনো০টঽুৠগআ৷৭৩৬তো৻ঈ০ূসষঅঝআমণঔা১ণৈো৵চঽ৩বমৎঙঘ২ঠৠৈী৫তঌণচ৲ঔী৮ঘৰঔ";
Julia Lavrova99ede422020-03-17 13:20:58 -04002496 canvas->drawColor(SK_ColorWHITE);
2497
2498 auto fontCollection = sk_make_sp<FontCollection>();
2499 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2500 fontCollection->enableFontFallback();
2501
2502 ParagraphStyle paragraph_style;
2503 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2504 TextStyle text_style;
2505 text_style.setColor(SK_ColorBLACK);
2506 text_style.setFontFamilies({SkString("Roboto")});
2507 text_style.setFontSize(20);
2508 builder.pushStyle(text_style);
2509 builder.addText(text);
2510 auto paragraph = builder.Build();
2511 auto w = width() / 2;
2512 paragraph->layout(w);
Julia Lavrovaa169b002020-03-23 13:39:52 -04002513 auto impl = static_cast<ParagraphImpl*>(paragraph.get());
2514
2515 auto clusters = impl->clusters();
2516 size_t c = 0;
2517 SkDebugf("clusters\n");
2518 for (auto& cluster: clusters) {
2519 SkDebugf(""
2520 "%d: [%d:%d) %s\n", c++,
2521 cluster.textRange().start, cluster.textRange().end,
2522 cluster.isSoftBreak() ? "soft" :
2523 cluster.isHardBreak() ? "hard" :
2524 cluster.isWhitespaces() ? "spaces" : ""
2525 );
2526 }
2527 auto lines = impl->lines();
2528 size_t i = 0;
2529 SkDebugf("lines\n");
2530 for (auto& line : lines) {
2531 SkDebugf("%d: [%d:%d)\n", i++, line.trimmedText().start, line.trimmedText().end);
2532 }
2533
Julia Lavrova99ede422020-03-17 13:20:58 -04002534 paragraph->paint(canvas, 0, 0);
2535 }
2536
2537private:
2538 typedef Sample INHERITED;
2539};
2540
Julia Lavrova18db52f2020-05-04 15:03:18 -04002541class ParagraphView38 : public ParagraphView_Base {
2542protected:
2543 SkString name() override { return SkString("Paragraph38"); }
2544
2545 void onDrawContent(SkCanvas* canvas) override {
2546
2547 canvas->drawColor(SK_ColorWHITE);
2548
2549 auto fontCollection = sk_make_sp<FontCollection>();
2550 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2551 fontCollection->enableFontFallback();
2552
2553 ParagraphStyle paragraph_style;
2554 paragraph_style.setTextAlign(TextAlign::kLeft);
2555 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2556 TextStyle text_style;
2557 text_style.setColor(SK_ColorDKGRAY);
2558 text_style.setFontFamilies({SkString("Roboto")});
2559 text_style.setFontSize(40);
2560 text_style.setDecoration(TextDecoration::kUnderline);
2561
2562 text_style.setDecorationMode(TextDecorationMode::kThrough);
2563 text_style.setDecorationStyle(TextDecorationStyle::kDouble);
2564 text_style.setDecorationColor(SK_ColorBLUE);
2565 builder.pushStyle(text_style);
2566 builder.addText("Double underline: {opopo}\n");
2567
2568 text_style.setDecorationMode(TextDecorationMode::kGaps);
2569 text_style.setDecorationStyle(TextDecorationStyle::kDouble);
2570 text_style.setDecorationColor(SK_ColorBLUE);
2571 builder.pushStyle(text_style);
2572 builder.addText("Double underline: {opopo}\n");
2573
2574 text_style.setDecorationStyle(TextDecorationStyle::kDotted);
2575 text_style.setDecorationColor(SK_ColorRED);
2576 builder.pushStyle(text_style);
2577 builder.addText("Dotted underline: {ijiji}\n");
2578
2579 text_style.setDecorationStyle(TextDecorationStyle::kSolid);
2580 text_style.setDecorationColor(SK_ColorGREEN);
2581 builder.pushStyle(text_style);
2582 builder.addText("Solid underline: {rqrqr}\n");
2583
2584 text_style.setDecorationStyle(TextDecorationStyle::kDashed);
2585 text_style.setDecorationColor(SK_ColorMAGENTA);
2586 builder.pushStyle(text_style);
2587 builder.addText("Dashed underline: {zyzyz}\n");
2588
2589 text_style.setDecorationStyle(TextDecorationStyle::kWavy);
2590 text_style.setDecorationColor(SK_ColorCYAN);
2591 builder.pushStyle(text_style);
2592 builder.addText("Wavy underline: {does not skip}\n");
2593
2594 auto paragraph = builder.Build();
2595 paragraph->layout(width());
2596 paragraph->paint(canvas, 0, 0);
2597 }
2598
2599private:
2600 typedef Sample INHERITED;
2601};
2602
Julia Lavrova6bdbd3d2020-05-06 12:03:17 -04002603class ParagraphView39 : public ParagraphView_Base {
2604protected:
2605 SkString name() override { return SkString("Paragraph39"); }
2606
2607 void onDrawContent(SkCanvas* canvas) override {
2608
2609 canvas->drawColor(SK_ColorWHITE);
2610
2611 auto fontCollection = sk_make_sp<FontCollection>();
2612 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2613 fontCollection->enableFontFallback();
2614
2615 ParagraphStyle paragraph_style;
2616 paragraph_style.setTextAlign(TextAlign::kJustify);
2617 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2618 TextStyle text_style;
2619 text_style.setColor(SK_ColorBLACK);
2620 text_style.setFontFamilies({SkString("Roboto")});
2621 text_style.setFontSize(40);
2622 builder.pushStyle(text_style);
2623 builder.addText(
2624 "text1 with line break\n"
2625 "text2 without line break text without line break text without line break text without line break text without line break text without line break "
2626 "text3 with line break\n"
2627 "text4 without line break text without line break text without line break text without line break text without line break text without line break "
2628 "text5 with line break\n"
2629 );
2630 auto paragraph = builder.Build();
2631 paragraph->layout(width());
2632 paragraph->paint(canvas, 0, 0);
2633 }
2634
2635private:
2636 typedef Sample INHERITED;
2637};
2638
Julia Lavrovadd1de252020-05-08 11:53:19 -04002639class ParagraphView41 : public ParagraphView_Base {
2640protected:
2641 SkString name() override { return SkString("Paragraph41"); }
2642
2643 void onDrawContent(SkCanvas* canvas) override {
2644
2645 canvas->drawColor(SK_ColorWHITE);
2646
2647 auto fontCollection = sk_make_sp<FontCollection>();
2648 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2649 fontCollection->enableFontFallback();
2650
2651 SkPaint line;
2652 line.setColor(SK_ColorRED);
2653 line.setStyle(SkPaint::kStroke_Style);
2654 line.setAntiAlias(true);
2655 line.setStrokeWidth(1);
2656
2657 auto draw = [&](SkColor color, TextHeightBehavior thb) {
2658 ParagraphStyle paragraph_style;
2659 paragraph_style.setTextHeightBehavior(thb);
2660 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2661 TextStyle text_style;
2662 text_style.setColor(SK_ColorBLACK);
2663 SkPaint paint;
2664 paint.setColor(color);
2665 text_style.setBackgroundColor(paint);
2666 text_style.setFontFamilies({SkString("Roboto")});
2667 text_style.setFontSize(20);
2668 text_style.setHeight(5);
2669 text_style.setHeightOverride(true);
2670 builder.pushStyle(text_style);
2671 builder.addText("World domination is such an ugly phrase - I prefer to call it world optimisation");
2672 auto paragraph = builder.Build();
2673 paragraph->layout(width());
2674 paragraph->paint(canvas, 0, 0);
2675 canvas->drawLine(0, paragraph->getHeight(), paragraph->getMaxWidth(), paragraph->getHeight(), line);
2676 canvas->translate(0, paragraph->getHeight());
2677 };
2678
2679 draw(SK_ColorLTGRAY, TextHeightBehavior::kDisableFirstAscent);
2680 draw(SK_ColorYELLOW, TextHeightBehavior::kDisableLastDescent);
2681 draw(SK_ColorGRAY, TextHeightBehavior::kDisableAll);
2682
2683 }
2684
2685private:
2686 typedef Sample INHERITED;
2687};
2688
2689class ParagraphView42 : public ParagraphView_Base {
2690protected:
2691 SkString name() override { return SkString("Paragraph42"); }
2692
2693 void onDrawContent(SkCanvas* canvas) override {
2694
2695 SkString text("Atwater Peel Sherbrooke Bonaventure\nhi\nwasssup!");
2696 canvas->drawColor(SK_ColorWHITE);
2697
2698 auto fontCollection = sk_make_sp<TestFontCollection>(GetResourcePath("fonts").c_str(), true, true);
2699
2700 ParagraphStyle paragraph_style;
2701 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2702 TextStyle text_style;
2703 text_style.setColor(SK_ColorBLACK);
2704 text_style.setFontFamilies({SkString("Ahem")});
2705 text_style.setFontSize(16);
2706 text_style.setHeight(4);
2707 text_style.setHeightOverride(true);
2708 builder.pushStyle(text_style);
2709 builder.addText(text.c_str());
2710 auto paragraph = builder.Build();
2711 paragraph->layout(width());
2712
2713 auto boxes = paragraph->getRectsForRange(0, 7, RectHeightStyle::kIncludeLineSpacingTop, RectWidthStyle::kMax);
2714 for (auto& box : boxes) {
2715 SkPaint paint;
2716 paint.setColor(SK_ColorGRAY);
2717 canvas->drawRect(box.rect, paint);
2718 }
2719
2720 auto boxes2 = paragraph->getRectsForRange(0, 7, RectHeightStyle::kTight, RectWidthStyle::kMax);
2721 for (auto& box : boxes2) {
2722 SkPaint paint;
2723 paint.setColor(SK_ColorRED);
2724 canvas->drawRect(box.rect, paint);
2725 }
2726
2727 paragraph->paint(canvas, 0, 0);
2728 }
2729
2730private:
2731 typedef Sample INHERITED;
2732};
Julia Lavrova68d14332020-05-11 13:47:08 -04002733
2734class ParagraphView43 : public ParagraphView_Base {
2735protected:
2736 SkString name() override { return SkString("Paragraph43"); }
2737
2738 void onDrawContent(SkCanvas* canvas) override {
2739
2740 SkString text("World domination is such an ugly phrase - I prefer to call it world optimisation");
2741 canvas->drawColor(SK_ColorWHITE);
2742
2743 auto fontCollection = sk_make_sp<FontCollection>();
2744 fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());
2745 fontCollection->enableFontFallback();
2746
2747 ParagraphStyle paragraph_style;
2748 paragraph_style.setTextAlign(TextAlign::kJustify);
2749 paragraph_style.setEllipsis(u"\u2026");
2750 paragraph_style.setMaxLines(2);
2751 ParagraphBuilderImpl builder(paragraph_style, fontCollection);
2752 TextStyle text_style;
2753 text_style.setColor(SK_ColorBLACK);
2754 text_style.setFontFamilies({SkString("Roboto")});
2755 text_style.setFontSize(40);
2756 text_style.setHeightOverride(true);
2757 builder.pushStyle(text_style);
2758 builder.addText(text.c_str());
2759 auto paragraph = builder.Build();
2760 paragraph->layout(width() / 4);
2761 paragraph->paint(canvas, 0, 0);
2762 }
2763
2764private:
2765 typedef Sample INHERITED;
2766};
2767
Julia Lavrova2813d452020-03-03 11:43:40 -05002768//////////////////////////////////////////////////////////////////////////////
Julia Lavrovaa3552c52019-05-30 16:12:56 -04002769DEF_SAMPLE(return new ParagraphView1();)
2770DEF_SAMPLE(return new ParagraphView2();)
2771DEF_SAMPLE(return new ParagraphView3();)
2772DEF_SAMPLE(return new ParagraphView4();)
2773DEF_SAMPLE(return new ParagraphView5();)
2774DEF_SAMPLE(return new ParagraphView6();)
2775DEF_SAMPLE(return new ParagraphView7();)
2776DEF_SAMPLE(return new ParagraphView8();)
2777DEF_SAMPLE(return new ParagraphView9();)
2778DEF_SAMPLE(return new ParagraphView10();)
2779DEF_SAMPLE(return new ParagraphView11();)
Julia Lavrovaf3ed2732019-09-05 14:35:17 -04002780DEF_SAMPLE(return new ParagraphView12();)
Julia Lavrovaf3ed2732019-09-05 14:35:17 -04002781DEF_SAMPLE(return new ParagraphView14();)
2782DEF_SAMPLE(return new ParagraphView15();)
Julia Lavrova2e30fde2019-10-09 09:43:02 -04002783DEF_SAMPLE(return new ParagraphView16();)
2784DEF_SAMPLE(return new ParagraphView17();)
2785DEF_SAMPLE(return new ParagraphView18();)
Julia Lavrova18db52f2020-05-04 15:03:18 -04002786//DEF_SAMPLE(return new ParagraphView19();)
Julia Lavrovac028b422019-11-25 10:00:43 -05002787DEF_SAMPLE(return new ParagraphView20();)
Julia Lavrovac48687a2020-01-08 16:53:53 -05002788DEF_SAMPLE(return new ParagraphView21();)
Julia Lavrova4cf18742020-01-14 13:24:45 -05002789DEF_SAMPLE(return new ParagraphView22();)
Julia Lavrova51a813d2020-01-21 13:55:44 -05002790DEF_SAMPLE(return new ParagraphView23();)
Julia Lavrova2ea20ea2020-01-22 10:56:53 -05002791DEF_SAMPLE(return new ParagraphView24();)
2792DEF_SAMPLE(return new ParagraphView25();)
Julia Lavrova212bf072020-02-18 12:05:55 -05002793DEF_SAMPLE(return new ParagraphView26();)
2794DEF_SAMPLE(return new ParagraphView27();)
2795DEF_SAMPLE(return new ParagraphView28();)
2796DEF_SAMPLE(return new ParagraphView29();)
Julia Lavrova7dcb4d22020-02-20 12:04:36 -05002797DEF_SAMPLE(return new ParagraphView30();)
2798DEF_SAMPLE(return new ParagraphView31();)
Julia Lavrova76ae22e2020-02-26 12:14:18 -05002799DEF_SAMPLE(return new ParagraphView32();)
2800DEF_SAMPLE(return new ParagraphView33();)
Julia Lavrovaa0708e82020-02-28 12:14:58 -05002801DEF_SAMPLE(return new ParagraphView34();)
Julia Lavrova3c79a232020-03-02 09:58:52 -05002802DEF_SAMPLE(return new ParagraphView35();)
Julia Lavrova2813d452020-03-03 11:43:40 -05002803DEF_SAMPLE(return new ParagraphView36();)
Julia Lavrova99ede422020-03-17 13:20:58 -04002804DEF_SAMPLE(return new ParagraphView37();)
Julia Lavrova18db52f2020-05-04 15:03:18 -04002805DEF_SAMPLE(return new ParagraphView38();)
Julia Lavrova6bdbd3d2020-05-06 12:03:17 -04002806DEF_SAMPLE(return new ParagraphView39();)
Julia Lavrovadd1de252020-05-08 11:53:19 -04002807DEF_SAMPLE(return new ParagraphView41();)
2808DEF_SAMPLE(return new ParagraphView42();)
Julia Lavrova68d14332020-05-11 13:47:08 -04002809DEF_SAMPLE(return new ParagraphView43();)