[skottie] External font loader tweaks

More general ResourceProvider font loading API:

1) font name argument
2) invoked unconditionally (regardless of whether an URL is present)

This provides more font control to the embedder.

Change-Id: I95557c75c2e0fe41ff68ee1b6cec8929405a74fc
Reviewed-on: https://skia-review.googlesource.com/157424
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/modules/skottie/gm/SkottieGM.cpp b/modules/skottie/gm/SkottieGM.cpp
index b99c337..229df62 100644
--- a/modules/skottie/gm/SkottieGM.cpp
+++ b/modules/skottie/gm/SkottieGM.cpp
@@ -27,7 +27,7 @@
 public:
     FakeWebFontProvider() : fFontData(GetResourceAsData(kWebFontResource)) {}
 
-    sk_sp<SkData> loadWebFont(const char[]) const {
+    sk_sp<SkData> loadFont(const char[], const char[]) const override {
         return fFontData;
     }
 
diff --git a/modules/skottie/include/Skottie.h b/modules/skottie/include/Skottie.h
index e6e5960..a4a052d 100644
--- a/modules/skottie/include/Skottie.h
+++ b/modules/skottie/include/Skottie.h
@@ -47,7 +47,10 @@
                                const char resource_name[]) const;
 
     /**
-     * Load a web font from |url| and return as an SkData.
+     * Load an external font and return as SkData.
+     *
+     * @param name  font name    ("fName" Lottie property)
+     * @param url   web font URL ("fPath" Lottie property)
      *
      * -- Note --
      *
@@ -56,7 +59,7 @@
      *   capabilities (woff, woff2).  In that case, the embedder would need to advertise no user
      *   agent capabilities when fetching the URL, in order to receive full font data.
      */
-    virtual sk_sp<SkData> loadWebFont(const char url[]) const;
+    virtual sk_sp<SkData> loadFont(const char name[], const char url[]) const;
 };
 
 class SK_API Animation : public SkRefCnt {
diff --git a/modules/skottie/src/Skottie.cpp b/modules/skottie/src/Skottie.cpp
index 9588e48..296f563 100644
--- a/modules/skottie/src/Skottie.cpp
+++ b/modules/skottie/src/Skottie.cpp
@@ -227,7 +227,7 @@
     return nullptr;
 }
 
-sk_sp<SkData> ResourceProvider::loadWebFont(const char[]) const {
+sk_sp<SkData> ResourceProvider::loadFont(const char[], const char[]) const {
     return nullptr;
 }
 
diff --git a/modules/skottie/src/SkottieTextLayer.cpp b/modules/skottie/src/SkottieTextLayer.cpp
index 20b2eac..9538d56 100644
--- a/modules/skottie/src/SkottieTextLayer.cpp
+++ b/modules/skottie/src/SkottieTextLayer.cpp
@@ -123,15 +123,14 @@
                 const auto& fmgr = fLazyFontMgr.get();
 
                 // Typeface fallback order:
-                //   1) external web font, if a path/url is provided
+                //   1) externally-loaded font (provided by the embedder)
                 //   2) system font (family/style)
                 //   3) system default
 
-                sk_sp<SkTypeface> tf;
-
-                if (jpath) {
-                    tf = fmgr->makeFromData(fResourceProvider->loadWebFont(jpath->begin()));
-                }
+                sk_sp<SkTypeface> tf =
+                    fmgr->makeFromData(fResourceProvider->loadFont(jname->begin(),
+                                                                   jpath ? jpath->begin()
+                                                                         : nullptr));
 
                 if (!tf) {
                     tf.reset(fmgr->matchFamilyStyle(jfamily->begin(), FontStyle(jstyle->begin())));