route getFontMetrics to SkFont

Bug: skia:2664
Change-Id: I6ce7ff1a99101c7b4c8902a7d80e4a6338c9ed97
Reviewed-on: https://skia-review.googlesource.com/c/170278
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/src/core/SkPaint_text.cpp b/src/core/SkPaint_text.cpp
index eda6fc3..aa36cbb 100644
--- a/src/core/SkPaint_text.cpp
+++ b/src/core/SkPaint_text.cpp
@@ -473,32 +473,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 SkScalar SkPaint::getFontMetrics(SkFontMetrics* metrics) const {
-    SkCanonicalizePaint canon(*this);
-    const SkPaint& paint = canon.getPaint();
-    SkScalar scale = canon.getScale();
-
-    FontMetrics storage;
-    if (nullptr == metrics) {
-        metrics = &storage;
-    }
-
-    SkAutoDescriptor ad;
-    SkScalerContextEffects effects;
-
-    auto desc = SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
-        paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
-        SkScalerContextFlags::kNone, SkMatrix::I(), &ad, &effects);
-
-    {
-        auto typeface = SkPaintPriv::GetTypefaceOrDefault(paint);
-        auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(*desc, effects, *typeface);
-        *metrics = cache->getFontMetrics();
-    }
-
-    if (scale) {
-        SkPaintPriv::ScaleFontMetrics(metrics, scale);
-    }
-    return metrics->fDescent - metrics->fAscent + metrics->fLeading;
+    return SkFont::LEGACY_ExtractFromPaint(*this).getMetrics(metrics);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/tests/FontObjTest.cpp b/tests/FontObjTest.cpp
index 42a0b56..4f7e526 100644
--- a/tests/FontObjTest.cpp
+++ b/tests/FontObjTest.cpp
@@ -34,23 +34,6 @@
     REPORTER_ASSERT(reporter, paint.getHinting() == p.getHinting());
 }
 
-static void test_fontmetrics(skiatest::Reporter* reporter,
-                             const SkPaint& paint, const SkFont& font) {
-    SkFontMetrics fm0, fm1;
-    SkScalar h0 = paint.getFontMetrics(&fm0);
-    SkScalar h1 = font.getMetrics(&fm1);
-
-    REPORTER_ASSERT(reporter, h0 == h1);
-#define CMP(field) REPORTER_ASSERT(reporter, fm0.field == fm1.field)
-    CMP(fFlags);
-    CMP(fTop);
-    CMP(fAscent);
-    CMP(fDescent);
-    CMP(fBottom);
-    CMP(fLeading);
-#undef CMP
-}
-
 static void test_cachedfont(skiatest::Reporter* reporter) {
     static const char* const faces[] = {
         nullptr,   // default font
@@ -102,7 +85,6 @@
                 const SkFont font(SkFont::LEGACY_ExtractFromPaint(paint));
 
                 test_cachedfont(reporter, paint, font);
-                test_fontmetrics(reporter, paint, font);
 
                 SkRect bounds;