Android FontHost cannot use FontMgr yet.


git-svn-id: http://skia.googlecode.com/svn/trunk/src@12221 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkFontHost.cpp b/core/SkFontHost.cpp
index c09739d..f3d30e8 100644
--- a/core/SkFontHost.cpp
+++ b/core/SkFontHost.cpp
@@ -208,6 +208,8 @@
 
 //////////////////////////////////////////////////////////////////////////
 
+#ifndef SK_FONTHOST_DOES_NOT_USE_FONTMGR
+
 #if 0
 static SkFontStyle TypefaceStyleBitsToFontStyle(SkTypeface::Style styleBits) {
     SkFontStyle::Weight weight = (styleBits & SkTypeface::kBold) ?
@@ -248,3 +250,5 @@
     SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
     return fm->createFromStream(stream);
 }
+
+#endif
diff --git a/ports/SkFontConfigInterface_android.cpp b/ports/SkFontConfigInterface_android.cpp
index 6c3e8d5..6f9ed3a 100644
--- a/ports/SkFontConfigInterface_android.cpp
+++ b/ports/SkFontConfigInterface_android.cpp
@@ -930,6 +930,5 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 SkFontMgr* SkFontMgr::Factory() {
-    SkFontConfigInterface* fci = SkFontConfigInterface::GetSingletonDirectInterface();
-    return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL;
+    return NULL;
 }
diff --git a/ports/SkFontHost_fontconfig.cpp b/ports/SkFontHost_fontconfig.cpp
index de766df..3700ed1 100644
--- a/ports/SkFontHost_fontconfig.cpp
+++ b/ports/SkFontHost_fontconfig.cpp
@@ -124,6 +124,45 @@
     return face;
 }
 
+#ifdef SK_FONTHOST_DOES_NOT_USE_FONTMGR
+
+SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
+                                       const char familyName[],
+                                       SkTypeface::Style style) {
+    return FontConfigTypeface::LegacyCreateTypeface(familyFace, familyName,
+                                                    style);
+}
+
+SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
+    if (!stream) {
+        return NULL;
+    }
+    const size_t length = stream->getLength();
+    if (!length) {
+        return NULL;
+    }
+    if (length >= 1024 * 1024 * 1024) {
+        return NULL;  // don't accept too large fonts (>= 1GB) for safety.
+    }
+
+    // ask freetype for reported style and if it is a fixed width font
+    SkTypeface::Style style = SkTypeface::kNormal;
+    bool isFixedWidth = false;
+    if (!find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) {
+        return NULL;
+    }
+
+    SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, isFixedWidth, stream));
+    return face;
+}
+
+SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
+    SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
+    return stream.get() ? CreateTypefaceFromStream(stream) : NULL;
+}
+
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 
 SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const {