aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_linux.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ports/SkFontHost_linux.cpp')
-rw-r--r--src/ports/SkFontHost_linux.cpp43
1 files changed, 18 insertions, 25 deletions
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;
}