Factory methods for heap-allocated SkTypeface objects.

This is part of an effort to ensure that all SkPaint effects can only be
allocated on the heap.

This patch makes the constructors of SkTypeface and its subclasses non-public
and instead provides factory methods for creating these objects on the heap.

BUG=skia:2187
R=scroggo@google.com, bungeman@google.com

Author: dominikg@chromium.org

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

git-svn-id: http://skia.googlecode.com/svn/trunk@14080 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index d15caeb..cd3953b 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -37,8 +37,12 @@
 
 class SkEmptyTypeface : public SkTypeface {
 public:
-    SkEmptyTypeface() : SkTypeface(SkTypeface::kNormal, 0, true) { }
+    static SkEmptyTypeface* Create() {
+        return SkNEW(SkEmptyTypeface);
+    }
 protected:
+    SkEmptyTypeface() : SkTypeface(SkTypeface::kNormal, 0, true) { }
+
     virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { return NULL; }
     virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE {
         return NULL;
@@ -85,7 +89,8 @@
         gDefaultTypefaces[style] = SkFontHost::CreateTypeface(NULL, NULL, style);
     }
     if (NULL == gDefaultTypefaces[style]) {
-        gDefaultTypefaces[style] = SkNEW(SkEmptyTypeface);
+        // FIXME: Use a singleton for SkEmptyTypeface.
+        gDefaultTypefaces[style] = SkEmptyTypeface::Create();
     }
 }