add a SkFontMgr to DM that returns portable fonts

Controlled by --[no]nativeFonts, and still defaults to native fonts.

Change-Id: Ib2879e69fadb63ddb5a17a7e4ae227941893b8cf
Reviewed-on: https://skia-review.googlesource.com/67806
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/dm/DM.cpp b/dm/DM.cpp
index cb5332d..b751393 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -5,6 +5,7 @@
  * found in the LICENSE file.
  */
 
+#include "DMFontMgr.h"
 #include "DMJsonWriter.h"
 #include "DMSrcSink.h"
 #include "ProcStats.h"
@@ -101,6 +102,9 @@
 
 DEFINE_string(dont_write, "", "File extensions to skip writing to --writePath.");  // See skia:6821
 
+DEFINE_bool(nativeFonts, true, "If true, use native font manager and rendering. "
+                               "If false, fonts will draw as portably as possible.");
+
 using namespace DM;
 using sk_gpu_test::GrContextFactory;
 using sk_gpu_test::GLTestContext;
@@ -1307,9 +1311,18 @@
 
 extern sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char [], SkFontStyle );
 
+extern sk_sp<SkFontMgr> (*gSkFontMgr_DefaultFactory)();
+
+
 int main(int argc, char** argv) {
     SkCommandLineFlags::Parse(argc, argv);
 
+    if (!FLAGS_nativeFonts) {
+        gSkFontMgr_DefaultFactory = []() -> sk_sp<SkFontMgr> {
+            return sk_make_sp<DM::FontMgr>();
+        };
+    }
+
     initializeEventTracingForTools();
 
 #if !defined(GOOGLE3) && defined(SK_BUILD_FOR_IOS)