Index: src/ports/SkFontHost_android.cpp |
=================================================================== |
--- src/ports/SkFontHost_android.cpp (revision 8205) |
+++ src/ports/SkFontHost_android.cpp (working copy) |
@@ -9,7 +9,6 @@ |
#include "SkFontDescriptor.h" |
#include "SkGraphics.h" |
#include "SkDescriptor.h" |
-#include "SkMMapStream.h" |
#include "SkPaint.h" |
#include "SkString.h" |
#include "SkStream.h" |
@@ -370,30 +369,19 @@ |
fPath.set(path); |
} |
- // overrides |
- virtual SkStream* openStream() { |
- SkStream* stream = SkNEW_ARGS(SkMMAPStream, (fPath.c_str())); |
- |
- // check for failure |
- if (stream->getLength() <= 0) { |
- SkDELETE(stream); |
- // maybe MMAP isn't supported. try FILE |
- stream = SkNEW_ARGS(SkFILEStream, (fPath.c_str())); |
- if (stream->getLength() <= 0) { |
- SkDELETE(stream); |
- stream = NULL; |
- } |
- } |
- return stream; |
+ virtual SkStream* openStream() SK_OVERRIDE { |
+ return SkStream::NewFromFile(fPath.c_str()); |
} |
- virtual const char* getUniqueString() const { |
+ |
+ virtual const char* getUniqueString() const SK_OVERRIDE { |
const char* str = strrchr(fPath.c_str(), '/'); |
if (str) { |
str += 1; // skip the '/' |
} |
return str; |
} |
- virtual const char* getFilePath() const { |
+ |
+ virtual const char* getFilePath() const SK_OVERRIDE { |
return fPath.c_str(); |
} |
@@ -412,21 +400,15 @@ |
SkString fullpath; |
GetFullPathForSysFonts(&fullpath, path); |
- SkMMAPStream stream(fullpath.c_str()); |
- if (stream.getLength() > 0) { |
- return find_name_and_attributes(&stream, name, style, isFixedWidth); |
- } |
- else { |
- SkFILEStream stream(fullpath.c_str()); |
- if (stream.getLength() > 0) { |
- return find_name_and_attributes(&stream, name, style, isFixedWidth); |
+ SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(fullpath.c_str())); |
+ if (stream.get()) { |
+ return find_name_and_attributes(stream, name, style, isFixedWidth); |
+ } else { |
+ if (isExpected) { |
+ SkDebugf("---- failed to open <%s> as a font", fullpath.c_str()); |
} |
+ return false; |
} |
- |
- if (isExpected) { |
- SkDebugf("---- failed to open <%s> as a font", fullpath.c_str()); |
- } |
- return false; |
} |
// used to record our notion of the pre-existing fonts |
@@ -952,11 +934,8 @@ |
} |
SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { |
- SkStream* stream = SkNEW_ARGS(SkMMAPStream, (path)); |
- SkTypeface* face = SkFontHost::CreateTypefaceFromStream(stream); |
- // since we created the stream, we let go of our ref() here |
- stream->unref(); |
- return face; |
+ SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); |
+ return stream.get() ? SkFontHost::CreateTypefaceFromStream(stream) : NULL; |
} |
/////////////////////////////////////////////////////////////////////////////// |