aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-25 20:40:02 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-25 20:40:02 +0000
commit437eea160b2f605d9074106891288e85baaecfef (patch)
tree6587c881f21b9981eda2bbd61ff69a138b908551
parent8dd94f0931b9f5839ce1b89f1489ba871517af39 (diff)
impl onCreateFrom... for fontmgr on windows
git-svn-id: http://skia.googlecode.com/svn/trunk@8869 2bbb7eff-a529-9590-31e7-b0007b416f81
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 75871b9500..5590e2bf6d 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -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: