Make fuzzing use embedded test font
This will make fuzzing more hermetic and less machine-dependent.
Docs-Preview: https://skia.org/?cl=217864
Change-Id: If29d7b86e5290e9f749cb2fdde6f2ff892ffc333
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217864
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/fuzz/FuzzMain.cpp b/fuzz/FuzzMain.cpp
index 43f8f36..aecf19d 100644
--- a/fuzz/FuzzMain.cpp
+++ b/fuzz/FuzzMain.cpp
@@ -17,13 +17,14 @@
#include "include/core/SkStream.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTextBlob.h"
+#include "src/core/SkFontMgrPriv.h"
#include "src/core/SkOSFile.h"
#include "src/core/SkPicturePriv.h"
#include "src/core/SkReadBuffer.h"
#include "src/utils/SkOSPath.h"
-#include "tools/flags/CommandLineFlags.h"
-
#include "tools/ToolUtils.h"
+#include "tools/flags/CommandLineFlags.h"
+#include "tools/fonts/TestFontMgr.h"
#include <iostream>
#include <map>
@@ -102,6 +103,7 @@
"--help lists the valid types. If type is not specified,\n"
"fuzz will make a guess based on the name of the file.\n");
CommandLineFlags::Parse(argc, argv);
+ gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
SkString path = SkString(FLAGS_bytes.isEmpty() ? argv[0] : FLAGS_bytes[0]);
SkString type = SkString(FLAGS_type.isEmpty() ? "" : FLAGS_type[0]);
diff --git a/site/dev/testing/fuzz.md b/site/dev/testing/fuzz.md
index b555b99..8bb3744 100644
--- a/site/dev/testing/fuzz.md
+++ b/site/dev/testing/fuzz.md
@@ -12,6 +12,8 @@
skia_use_system_freetype2=false
skia_use_wuffs=true
skia_enable_skottie=true
+ skia_enable_fontmgr_custom=false
+ skia_enable_fontmgr_custom_empty=true
All that is needed to reproduce a fuzz downloaded from ClusterFuzz, oss-fuzz or
fuzzer.skia.org is to run something like: