add matcher to fontstyleset
Review URL: https://codereview.chromium.org/13312002

git-svn-id: http://skia.googlecode.com/svn/trunk@8444 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkFontHost.cpp b/src/core/SkFontHost.cpp
index d784978..a3df04d 100644
--- a/src/core/SkFontHost.cpp
+++ b/src/core/SkFontHost.cpp
@@ -50,8 +50,45 @@
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 
+#include "SkFontStyle.h"
+
+SkFontStyle::SkFontStyle() {
+    fUnion.fU32 = 0;
+    fUnion.fR.fWeight = kNormal_Weight;
+    fUnion.fR.fWidth = kNormal_Width;
+    fUnion.fR.fSlant = kUpright_Slant;
+}
+
+SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
+    fUnion.fU32 = 0;
+    fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight);
+    fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width);
+    fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant);
+}
+
 #include "SkFontMgr.h"
 
+class SkEmptyFontStyleSet : public SkFontStyleSet {
+public:
+    virtual int count() SK_OVERRIDE { return 0; }
+    virtual void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE {
+        SkASSERT(!"SkFontStyleSet::getStyle called on empty set");
+    }
+    virtual SkTypeface* createTypeface(int index) SK_OVERRIDE {
+        SkASSERT(!"SkFontStyleSet::createTypeface called on empty set");
+        return NULL;
+    }
+    virtual SkTypeface* matchStyle(const SkFontStyle&) SK_OVERRIDE {
+        return NULL;
+    }
+};
+
+SkFontStyleSet* SkFontStyleSet::CreateEmpty() {
+    return SkNEW(SkEmptyFontStyleSet);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
 class SkEmptyFontMgr : public SkFontMgr {
 protected:
     virtual int onCountFamilies() SK_OVERRIDE {
@@ -64,6 +101,10 @@
         SkASSERT(!"onCreateStyleSet called with bad index");
         return NULL;
     }
+    virtual SkFontStyleSet* onMatchFamily(const char[]) SK_OVERRIDE {
+        return SkFontStyleSet::CreateEmpty();
+    }
+
     virtual SkTypeface* onMatchFamilyStyle(const char[],
                                            const SkFontStyle&) SK_OVERRIDE {
         return NULL;
@@ -83,20 +124,6 @@
     }
 };
 
-SkFontStyle::SkFontStyle() {
-    fUnion.fU32 = 0;
-    fUnion.fR.fWeight = kNormal_Weight;
-    fUnion.fR.fWidth = kNormal_Width;
-    fUnion.fR.fSlant = kUpright_Slant;
-}
-
-SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
-    fUnion.fU32 = 0;
-    fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight);
-    fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width);
-    fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant);
-}
-
 int SkFontMgr::countFamilies() {
     return this->onCountFamilies();
 }
@@ -109,6 +136,10 @@
     return this->onCreateStyleSet(index);
 }
 
+SkFontStyleSet* SkFontMgr::matchFamily(const char familyName[]) {
+    return this->onMatchFamily(familyName);
+}
+
 SkTypeface* SkFontMgr::matchFamilyStyle(const char familyName[],
                                         const SkFontStyle& fs) {
     return this->onMatchFamilyStyle(familyName, fs);