impl onCreateFrom... for fontmgr on windows

git-svn-id: http://skia.googlecode.com/svn/trunk@8869 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2013-04-25 20:40:02 +00:00
parent 8dd94f0931
commit 437eea160b

View File

@ -1534,7 +1534,7 @@ static HANDLE activate_font(SkData* fontData) {
return fontHandle;
}
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
static SkTypeface* create_from_stream(SkStream* stream) {
// Create a unique and unpredictable font name.
// Avoids collisions and access from CSS.
char familyName[BASE64_GUID_ID_LEN];
@ -1562,6 +1562,10 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
return SkCreateFontMemResourceTypefaceFromLOGFONT(lf, fontReference);
}
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
return create_from_stream(stream);
}
SkStream* LogFontTypeface::onOpenStream(int* ttcIndex) const {
*ttcIndex = 0;
@ -1778,8 +1782,6 @@ class SkFontMgrGDI : public SkFontMgr {
public:
SkFontMgrGDI() {}
virtual ~SkFontMgrGDI() {
}
protected:
virtual int onCountFamilies() SK_OVERRIDE {
@ -1808,28 +1810,35 @@ protected:
return SkNEW_ARGS(SkFontStyleSetGDI, (lf));
}
// this impl should be moved to base-class
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
const SkFontStyle& fontstyle) SK_OVERRIDE {
// could be in base impl
SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName));
return sset->matchStyle(fontstyle);
}
virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
const SkFontStyle& fontstyle) SK_OVERRIDE {
// could be in base impl
SkString familyName;
((LogFontTypeface*)familyMember)->getFamilyName(&familyName);
return this->matchFamilyStyle(familyName.c_str(), fontstyle);
}
virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) SK_OVERRIDE {
return NULL;
virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) SK_OVERRIDE {
return create_from_stream(stream);
}
virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) SK_OVERRIDE {
return NULL;
virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) SK_OVERRIDE {
// could be in base impl
SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, (data)));
return this->createFromStream(stream);
}
virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) SK_OVERRIDE {
return NULL;
// could be in base impl
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
return this->createFromStream(stream);
}
private: