Do not use SkCreateTypefaceFromCTFont for custom fonts

SkCreateTypefaceFromCTFont implies fonts are non-local
(i.e. serialized as font name only, not the glyphs). This
does not work with the dynamically loaded fonts, so just
keep the SkTypeface we used to create in FontCustomPlatformDataMac
rather than create one from CTFont.

BUG=426088

Review URL: https://codereview.chromium.org/691733004

git-svn-id: svn://svn.chromium.org/blink/trunk@184884 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/LayoutTests/platform/mac-lion/fast/text/font-variant-width-expected.txt b/LayoutTests/platform/mac-lion/fast/text/font-variant-width-expected.txt
deleted file mode 100644
index b6dfc2d..0000000
--- a/LayoutTests/platform/mac-lion/fast/text/font-variant-width-expected.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-11
-99
-111
-999
-1111
-9999
-11111
-99999
-123456
-111111
-999999
-This is a testharness.js-based test.
-PASS Numbers expected to be laid out in one combining block 
-PASS Numbers expected to be laid out in one combining block 
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 26.6953125
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 26.6953125
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 40.04296875
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 40.04296875
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 53.390625
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 53.390625
-PASS Number laid out vertically, not combined. 
-Harness: the test ran to completion.
-
diff --git a/LayoutTests/platform/mac-lion/virtual/antialiasedtext/fast/text/font-variant-width-expected.txt b/LayoutTests/platform/mac-lion/virtual/antialiasedtext/fast/text/font-variant-width-expected.txt
deleted file mode 100644
index b6dfc2d..0000000
--- a/LayoutTests/platform/mac-lion/virtual/antialiasedtext/fast/text/font-variant-width-expected.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-11
-99
-111
-999
-1111
-9999
-11111
-99999
-123456
-111111
-999999
-This is a testharness.js-based test.
-PASS Numbers expected to be laid out in one combining block 
-PASS Numbers expected to be laid out in one combining block 
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 26.6953125
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 26.6953125
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 40.04296875
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 40.04296875
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 53.390625
-FAIL Numbers expected to be laid out in one combining block assert_equals: Numbers laid out in one combining block. expected 24 but got 53.390625
-PASS Number laid out vertically, not combined. 
-Harness: the test ran to completion.
-
diff --git a/Source/platform/fonts/FontPlatformData.cpp b/Source/platform/fonts/FontPlatformData.cpp
index 4c636b5..6f22f46 100644
--- a/Source/platform/fonts/FontPlatformData.cpp
+++ b/Source/platform/fonts/FontPlatformData.cpp
@@ -189,8 +189,8 @@
 }
 
 #if OS(MACOSX)
-FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticItalic, FontOrientation orientation, FontWidthVariant widthVariant)
-    : m_typeface(nullptr)
+FontPlatformData::FontPlatformData(CGFontRef cgFont, PassRefPtr<SkTypeface> tf, float size, bool syntheticBold, bool syntheticItalic, FontOrientation orientation, FontWidthVariant widthVariant)
+    : m_typeface(tf)
     , m_family(CString())
     , m_textSize(size)
     , m_syntheticBold(syntheticBold)
diff --git a/Source/platform/fonts/FontPlatformData.h b/Source/platform/fonts/FontPlatformData.h
index fcfa63c..1a44b36 100644
--- a/Source/platform/fonts/FontPlatformData.h
+++ b/Source/platform/fonts/FontPlatformData.h
@@ -80,7 +80,7 @@
 #if OS(MACOSX)
     FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool syntheticItalic = false,
                      FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
-    FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant);
+    FontPlatformData(CGFontRef, PassRefPtr<SkTypeface>, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant);
 #else
     FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subpixelTextPosition = defaultUseSubpixelPositioning());
 #endif
diff --git a/Source/platform/fonts/mac/FontCustomPlatformDataMac.cpp b/Source/platform/fonts/mac/FontCustomPlatformDataMac.cpp
index 022bffa..dacd0ca 100644
--- a/Source/platform/fonts/mac/FontCustomPlatformDataMac.cpp
+++ b/Source/platform/fonts/mac/FontCustomPlatformDataMac.cpp
@@ -44,7 +44,7 @@
 
 FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant)
 {
-    return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant);
+    return FontPlatformData(m_cgFont.get(), m_typeface, size, bold, italic, orientation, widthVariant);
 }
 
 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer* buffer)
@@ -63,10 +63,6 @@
     if (!cgFontRef)
         return nullptr;
 
-    // It's unclear whether this is used. It seems like it has the effect of priming the cache.
-    // Since we store this anyways, it might be worthwhile just plumbing this to FontMac.cpp in
-    // a more obvious way.
-    // FIXME: Remove this, add an explicit use, or add a comment explaining why this exists.
     RefPtr<SkMemoryStream> stream = adoptRef(new SkMemoryStream(buffer->getAsSkData().get()));
     RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream.get()));
     if (!typeface)