53#if defined(SK_ENABLE_PARAGRAPH)
57const uint8_t MAX_TEXT_LENGTH = 255;
58const uint8_t MAX_TEXT_ADDITIONS = 4;
60const uint16_t TEST_CANVAS_DIM = 250;
64 ResourceFontCollection(
bool testOnly =
false)
69 std::vector<SkString>
fonts;
74 while (iter.next(&path)) {
75 if (
path.endsWith(
"Roboto-Italic.ttf")) {
78 fonts.emplace_back(path);
86 for (
auto& font :
fonts) {
88 file_path.
printf(
"%s/%s", fResourceDir.c_str(),
font.c_str());
89 fFontProvider->registerTypeface(mgr->makeFromFile(file_path.
c_str(), 0));
93 this->setTestFontManager(std::move(fFontProvider));
95 this->setAssetFontManager(std::move(fFontProvider));
97 this->disableFontFallback();
100 size_t resolvedFonts()
const {
return fResolvedFonts; }
103 bool fontsFound()
const {
return fFontsFound; }
107 size_t fResolvedFonts;
108 std::string fResourceDir;
117 fuzz->
nextRange(&text_length, 0, MAX_TEXT_LENGTH);
124 char text[MAX_TEXT_LENGTH];
125 const auto text_length = RandomText(
text, fuzz);
130 char16_t text[MAX_TEXT_LENGTH];
131 const auto text_length = RandomText(
text, fuzz);
132 builder->addText(std::u16string(
text, text_length));
136const 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";
137const 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";
138const 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";
141 char text[MAX_TEXT_LENGTH];
142 const auto text_length = RandomText(
text, fuzz);
145 for (
auto& c :
std::string(
text, text_length)) {
150 uint8_t mark_type, mark_index;
151 fuzz->
next(&mark_type, &mark_index);
152 switch (mark_type % 3) {
154 result += COMBINING_UP[mark_index % COMBINING_UP.size()];
157 result += COMBINING_MIDDLE[mark_index % COMBINING_MIDDLE.size()];
161 result += COMBINING_DOWN[mark_index % COMBINING_DOWN.size()];
205 AddStyle(builder, fuzz);
207 fuzz->
next(&text_type);
208 switch (text_type % 3) {
210 AddASCIIText(builder, fuzz);
213 AddUnicodeText(builder, fuzz);
216 AddZalgoText(builder, fuzz);
219 RemoveStyle(builder, fuzz);
226 fuzz->
next(&hinting);
234 fuzz->
nextEnum(&td, TextDirection::kRtl);
237 fuzz->
nextEnum(&ta, TextAlign::kEnd);
257 return sk_ref_sp<SkUnicode>(factory->getUnicode());
268 fuzz->
nextRange(&iterations, 1, MAX_TEXT_ADDITIONS);
269 for (
int i = 0; i < iterations; i++) {
270 AddStyleAndText(&builder, fuzz);
277 auto paragraph =
builder.Build();
284 uint8_t layout_width;
285 fuzz->
next(&layout_width);
286 paragraph->layout(layout_width);
287 paragraph->paint(&canvas, 0, 0);
#define DEF_FUZZ(name, f)
SkString GetResourcePath(const char *resource)
static std::function< void(void)> pop(std::deque< std::function< void(void)> > *list)
sk_sp< T > sk_make_sp(Args &&... args)
void nextRange(T *, Min, Max)
void nextEnum(T *ptr, T max)
void nextN(T *ptr, int n)
bool tryAllocN32Pixels(int width, int height, bool isOpaque=false)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
void setFontFamilies(std::vector< SkString > families)
static const uint8_t buffer[]
sk_sp< Factory > BestAvailable()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
it will be possible to load the file into Perfetto s trace viewer disable asset fonts
font
Font Metadata and Metrics.
static sk_sp< SkUnicode > get_unicode()
void setEllipsis(const std::u16string &ellipsis)
void setTextDirection(TextDirection direction)
void setMaxLines(size_t maxLines)
void setHeight(SkScalar height)
void setStrutStyle(StrutStyle strutStyle)
void setTextHeightBehavior(TextHeightBehavior v)
void setTextAlign(TextAlign align)