check-point (early) for fontmgr stuff, not called.

git-svn-id: http://skia.googlecode.com/svn/trunk@8377 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2013-03-25 20:44:02 +00:00
parent 33179c817a
commit 95625dbcb6
3 changed files with 94 additions and 15 deletions

View File

@ -22,21 +22,11 @@ public:
SkTypeface* createTypeface(int index) const;
};
class SkFontFamilySet : public SkRefCnt {
public:
int count() const;
void getName(int index, SkString* familyName) const;
SkFontStyleSet* refStyleSet(int index) const;
};
class SkFontMgr : public SkRefCnt {
public:
/**
* Return a fontfamily set, which can iterate all of the font families
* available to this fontmgr. The caller is responsible for calling unref()
* on the returned object. Will never return NULL.
*/
SkFontFamilySet* createFamilySet();
int countFamilies();
void getFamilyName(int index, SkString* familyName);
SkFontStyleSet* createStyleSet(int index);
/**
* Find the closest matching typeface to the specified familyName and style
@ -46,6 +36,8 @@ public:
*/
SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&);
SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&);
/**
* Create a typeface for the specified data and TTC index (pass 0 for none)
* or NULL if the data is not recognized. The caller must call unref() on
@ -68,7 +60,30 @@ public:
*/
SkTypeface* createFromFile(const char path[], int ttcIndex = 0);
/**
* Return a ref to the default fontmgr. The caller must call unref() on
* the returned object.
*/
static SkFontMgr* RefDefault();
protected:
virtual int onCountFamilies() = 0;
virtual void onGetFamilyName(int index, SkString* familyName) = 0;
virtual SkFontStyleSet* onCreateStyleSet(int index) = 0;
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
const SkFontStyle&) = 0;
virtual SkTypeface* onMatchFaceStyle(const SkTypeface*,
const SkFontStyle&) = 0;
virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) = 0;
virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) = 0;
virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) = 0;
private:
static SkFontMgr* Factory(); // implemented by porting layer
static SkMutex* Mutex(); // implemented by porting layer
typedef SkRefCnt INHERITED;
};

View File

@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
#ifndef SkFontMgr_DEFINED
#define SkFontMgr_DEFINED
#ifndef SkFontStyle_DEFINED
#define SkFontStyle_DEFINED
#include "SkTypes.h"

View File

@ -1832,3 +1832,67 @@ void SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor* desc,
*isLocalStream = false;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#if 1
#include "SkFontMgr.h"
class SkFontMgr_Mac : public SkFontMgr {
public:
SkFontMgr_Mac() {}
protected:
virtual int onCountFamilies() SK_OVERRIDE {
return 0;
}
virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE {
}
virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE {
return NULL;
}
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
const SkFontStyle&) SK_OVERRIDE {
return NULL;
}
virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
const SkFontStyle&) SK_OVERRIDE {
return NULL;
}
virtual SkTypeface* onCreateFromData(SkData* data,
int ttcIndex) SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data));
if (NULL == pr) {
return NULL;
}
return create_from_dataProvider(pr);
}
virtual SkTypeface* onCreateFromStream(SkStream* stream,
int ttcIndex) SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(stream));
if (NULL == pr) {
return NULL;
}
return create_from_dataProvider(pr);
}
virtual SkTypeface* onCreateFromFile(const char path[],
int ttcIndex) SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(CGDataProviderCreateWithFilename(path));
if (NULL == pr) {
return NULL;
}
return create_from_dataProvider(pr);
}
};
SkFontMgr* SkFontMgr::Factory() {
return SkNEW(SkFontMgr_Mac);
}
#endif