aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gyp/ports.gyp1
-rw-r--r--include/core/SkFontHost.h6
-rw-r--r--include/core/SkTypeface.h4
-rw-r--r--src/core/SkTypeface.cpp9
-rw-r--r--src/ports/SkFontHost_android.cpp36
-rw-r--r--src/ports/SkFontHost_fontconfig.cpp7
-rw-r--r--src/ports/SkFontHost_freetype_mac.cpp97
-rw-r--r--src/ports/SkFontHost_linux.cpp43
-rwxr-xr-xsrc/ports/SkFontHost_mac.cpp5
-rw-r--r--src/ports/SkFontHost_none.cpp7
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp5
-rw-r--r--src/ports/SkFontHost_win_dw.cpp5
12 files changed, 32 insertions, 193 deletions
diff --git a/gyp/ports.gyp b/gyp/ports.gyp
index 49b278de21..bd2b909278 100644
--- a/gyp/ports.gyp
+++ b/gyp/ports.gyp
@@ -95,7 +95,6 @@
'../src/ports/SkFontHost_mac.cpp',
# '../src/ports/SkFontHost_FreeType.cpp',
# '../src/ports/SkFontHost_FreeType_common.cpp',
-# '../src/ports/SkFontHost_freetype_mac.cpp',
'../src/ports/SkPurgeableMemoryBlock_mac.cpp',
'../src/ports/SkThread_pthread.cpp',
'../src/utils/mac/SkStream_mac.cpp',
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h
index 5ae5f203cd..d695aae17e 100644
--- a/include/core/SkFontHost.h
+++ b/include/core/SkFontHost.h
@@ -120,12 +120,6 @@ public:
private:
- /** Return a new stream to read the font data, or null if the uniqueID does
- not match an existing typeface. .The caller must call stream->unref()
- when it is finished reading the data.
- */
- static SkStream* OpenStream(SkFontID uniqueID);
-
/** Return a new, closest matching typeface given either an existing family
(specified by a typeface in that family) or by a familyName and a
requested style.
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index a89c31f0f5..8eedc50b3b 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -213,13 +213,11 @@ protected:
virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const = 0;
virtual void onFilterRec(SkScalerContextRec*) const = 0;
-
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo,
const uint32_t* glyphIDs,
uint32_t glyphIDsCount) const = 0;
- // TODO: remove SkFontHost::OpenStream and make this guy pure-virtual
- virtual SkStream* onOpenStream(int* ttcIndex) const;
+ virtual SkStream* onOpenStream(int* ttcIndex) const = 0;
virtual int onGetUPEM() const;
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 9a9ebcb802..4c3f8a1e23 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -155,15 +155,6 @@ int SkTypeface::onGetUPEM() const {
return upem;
}
-SkStream* SkTypeface::onOpenStream(int* ttcIndex) const {
- // If this has not been overridden, then we just don't know the ttcIndex
- // so we set it to 0
- if (ttcIndex) {
- *ttcIndex = 0;
- }
- return SkFontHost::OpenStream(fUniqueID);
-}
-
void SkTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const {
desc->setStyle(this->style());
}
diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp
index 5d3b583892..ad10a0fd34 100644
--- a/src/ports/SkFontHost_android.cpp
+++ b/src/ports/SkFontHost_android.cpp
@@ -313,7 +313,6 @@ public:
bool isSysFont() const { return fIsSysFont; }
- virtual SkStream* openStream() = 0;
virtual const char* getUniqueString() const = 0;
virtual const char* getFilePath() const = 0;
@@ -338,8 +337,12 @@ public:
fStream->unref();
}
- // overrides
- virtual SkStream* openStream() {
+ virtual const char* getUniqueString() SK_OVERRIDE const { return NULL; }
+ virtual const char* getFilePath() SK_OVERRIDE const { return NULL; }
+
+protected:
+ virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
+ *ttcIndex = 0;
// we just ref our existing stream, since the caller will call unref()
// when they are through
fStream->ref();
@@ -347,8 +350,6 @@ public:
fStream->rewind();
return fStream;
}
- virtual const char* getUniqueString() const { return NULL; }
- virtual const char* getFilePath() const { return NULL; }
private:
SkStream* fStream;
@@ -370,10 +371,6 @@ public:
fPath.set(path);
}
- virtual SkStream* openStream() SK_OVERRIDE {
- return SkStream::NewFromFile(fPath.c_str());
- }
-
virtual const char* getUniqueString() const SK_OVERRIDE {
const char* str = strrchr(fPath.c_str(), '/');
if (str) {
@@ -386,6 +383,12 @@ public:
return fPath.c_str();
}
+protected:
+ virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
+ *ttcIndex = 0;
+ return SkStream::NewFromFile(fPath.c_str());
+ }
+
private:
SkString fPath;
@@ -749,7 +752,7 @@ void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
const bool isCustomFont = !((FamilyTypeface*)face)->isSysFont();
if (isCustomFont) {
// store the entire font in the fontData
- SkStream* fontStream = ((FamilyTypeface*)face)->openStream();
+ SkStream* fontStream = face->openStream(NULL);
const uint32_t length = fontStream->getLength();
stream->writePackedUInt(length);
@@ -833,19 +836,6 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
return tf;
}
-SkStream* SkFontHost::OpenStream(uint32_t fontID) {
- SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
-
- FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
- SkStream* stream = tf ? tf->openStream() : NULL;
-
- if (stream && stream->getLength() == 0) {
- stream->unref();
- stream = NULL;
- }
- return stream;
-}
-
SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFontID) {
#if defined(SK_BUILD_FOR_ANDROID) && !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
// Skia does not support font fallback for ndk applications in order to
diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp
index 0ec041c10b..1c9dca8993 100644
--- a/src/ports/SkFontHost_fontconfig.cpp
+++ b/src/ports/SkFontHost_fontconfig.cpp
@@ -244,13 +244,6 @@ SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const {
return stream;
}
-SkStream* SkFontHost::OpenStream(uint32_t) {
- SkASSERT(!"SkFontHost::OpenStream is DEPRECATED: call SkTypeface::openStream\n");
- return NULL;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
int FontConfigTypeface::onGetTableTags(SkFontTableTag tags[]) const {
int ttcIndex;
SkAutoTUnref<SkStream> stream(this->openStream(&ttcIndex));
diff --git a/src/ports/SkFontHost_freetype_mac.cpp b/src/ports/SkFontHost_freetype_mac.cpp
deleted file mode 100644
index 1339ffc6c7..0000000000
--- a/src/ports/SkFontHost_freetype_mac.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkFontHost.h"
-#include "SkTypefaceCache.h"
-
-#define FONT_PATH "/Library/Fonts/Skia.ttf"
-
-class FTMacTypeface : public SkTypeface {
-public:
- FTMacTypeface(Style style, uint32_t id, SkStream* stream) : SkTypeface(style, id) {
- // we take ownership of the stream
- fStream = stream;
- }
-
- virtual ~FTMacTypeface() {
- fStream->unref();
- }
-
- SkStream* fStream;
-};
-
-static FTMacTypeface* create_from_path(const char path[]) {
- SkStream* stream = SkStream::NewFromFile(path);
- if (!stream) {
- return NULL;
- }
-
- size_t size = stream->getLength();
- SkASSERT(size);
- FTMacTypeface* tf = new FTMacTypeface(SkTypeface::kNormal,
- SkTypefaceCache::NewFontID(),
- stream);
- SkTypefaceCache::Add(tf, SkTypeface::kNormal);
- return tf;
-}
-
-static SkTypeface* ref_default_typeface() {
- static SkTypeface* gDef;
-
- if (NULL == gDef) {
- gDef = create_from_path(FONT_PATH);
- }
-
- gDef->ref();
- return gDef;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
- const char familyName[],
- SkTypeface::Style style) {
- return ref_default_typeface();
-}
-
-SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
- SkDEBUGFAIL("SkFontHost::CreateTypefaceFromStream unimplemented");
- return NULL;
-}
-
-SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
- return create_from_path(path);
-}
-
-SkStream* SkFontHost::OpenStream(uint32_t fontID) {
- FTMacTypeface* tf = (FTMacTypeface*)SkTypefaceCache::FindByID(fontID);
- if (tf) {
- tf->fStream->ref();
- return tf->fStream;
- }
- return NULL;
-}
-
-void SkFontHost::Serialize(const SkTypeface*, SkWStream*) {
- SkDEBUGFAIL("SkFontHost::Serialize unimplemented");
-}
-
-SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
- SkDEBUGFAIL("SkFontHost::Deserialize unimplemented");
- return NULL;
-}
-
-SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFontID) {
- return NULL;
-}
-
-#include "SkTypeface_mac.h"
-
-SkTypeface* SkCreateTypefaceFromCTFont(CTFontRef fontRef) {
- SkDEBUGFAIL("Not supported");
- return NULL;
-}
diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp
index b82019159b..ac93738d62 100644
--- a/src/ports/SkFontHost_linux.cpp
+++ b/src/ports/SkFontHost_linux.cpp
@@ -258,8 +258,7 @@ public:
bool isSysFont() const { return fIsSysFont; }
FamilyRec* getFamily() const { return fFamilyRec; }
- // openStream returns a SkStream that has been ref-ed
- virtual SkStream* openStream() = 0;
+
virtual const char* getUniqueString() const = 0;
private:
@@ -279,10 +278,11 @@ class EmptyTypeface : public FamilyTypeface {
public:
EmptyTypeface() : INHERITED(SkTypeface::kNormal, true, NULL, false) {}
- // overrides
- virtual SkStream* openStream() SK_OVERRIDE { return NULL; }
virtual const char* getUniqueString() SK_OVERRIDE const { return NULL; }
+protected:
+ virtual SkStream* onOpenStream(int*) const SK_OVERRIDE { return NULL; }
+
private:
typedef FamilyTypeface INHERITED;
};
@@ -299,13 +299,15 @@ public:
fStream->unref();
}
- virtual SkStream* openStream() SK_OVERRIDE {
- // openStream returns a refed stream.
- fStream->ref();
- return fStream;
- }
virtual const char* getUniqueString() const SK_OVERRIDE { return NULL; }
+protected:
+ virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
+ *ttcIndex = 0;
+ fStream->ref();
+ return fStream;
+ }
+
private:
SkStream* fStream;
@@ -320,10 +322,6 @@ public:
fPath.set(path);
}
- virtual SkStream* openStream() SK_OVERRIDE {
- return SkStream::NewFromFile(fPath.c_str());
- }
-
virtual const char* getUniqueString() const SK_OVERRIDE {
const char* str = strrchr(fPath.c_str(), '/');
if (str) {
@@ -332,6 +330,12 @@ public:
return str;
}
+protected:
+ virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
+ *ttcIndex = 0;
+ return SkStream::NewFromFile(fPath.c_str());
+ }
+
private:
SkString fPath;
@@ -465,7 +469,7 @@ void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
const bool isCustomFont = !((FamilyTypeface*)face)->isSysFont();
if (isCustomFont) {
// store the entire font in the fontData
- SkStream* fontStream = ((FamilyTypeface*)face)->openStream();
+ SkStream* fontStream = face->openStream(NULL);
const uint32_t length = fontStream->getLength();
stream->writePackedUInt(length);
@@ -529,17 +533,6 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
return tf;
}
-SkStream* SkFontHost::OpenStream(uint32_t fontID) {
- FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
- SkStream* stream = tf ? tf->openStream() : NULL;
-
- if (stream && stream->getLength() == 0) {
- stream->unref();
- stream = NULL;
- }
- return stream;
-}
-
SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFontID) {
return NULL;
}
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 17117ae5eb..1aede6b197 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -1681,11 +1681,6 @@ SkStream* SkTypeface_Mac::onOpenStream(int* ttcIndex) const {
return stream;
}
-SkStream* SkFontHost::OpenStream(SkFontID fontID) {
- SkASSERT(!"SkFontHost::OpenStream is DEPRECATED\n");
- return NULL;
-}
-
///////////////////////////////////////////////////////////////////////////////
#include "SkStream.h"
diff --git a/src/ports/SkFontHost_none.cpp b/src/ports/SkFontHost_none.cpp
index cbbedfef17..0484097b25 100644
--- a/src/ports/SkFontHost_none.cpp
+++ b/src/ports/SkFontHost_none.cpp
@@ -29,13 +29,6 @@ SkTypeface* SkFontHost::CreateTypefaceFromFile(char const*) {
///////////////////////////////////////////////////////////////////////////////
-SkStream* SkFontHost::OpenStream(uint32_t uniqueID) {
- SkDEBUGFAIL("SkFontHost::OpenStream unimplemented");
- return NULL;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
SkDEBUGFAIL("SkFontHost::Serialize unimplemented");
}
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 8b8635b3d2..dc847c99bf 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -1630,11 +1630,6 @@ SkStream* LogFontTypeface::onOpenStream(int* ttcIndex) const {
return stream;
}
-SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
- SkTypeface* typeface = SkTypefaceCache::FindByID(uniqueID);
- return typeface ? typeface->openStream(NULL) : NULL;
-}
-
SkScalerContext* LogFontTypeface::onCreateScalerContext(const SkDescriptor* desc) const {
return SkNEW_ARGS(SkScalerContext_Windows, (const_cast<LogFontTypeface*>(this), desc));
}
diff --git a/src/ports/SkFontHost_win_dw.cpp b/src/ports/SkFontHost_win_dw.cpp
index e5ade8f533..313cdd0ca6 100644
--- a/src/ports/SkFontHost_win_dw.cpp
+++ b/src/ports/SkFontHost_win_dw.cpp
@@ -1131,11 +1131,6 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
fontFileLoader.get(), streamFontCollectionLoader.get());
}
-SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
- DWriteFontTypeface* typeface = GetDWriteFontByID(uniqueID);
- return typeface ? typeface->openStream(NULL) : NULL;
-}
-
SkStream* DWriteFontTypeface::onOpenStream(int* ttcIndex) const {
*ttcIndex = 0;