override SkTypeface::onOpenStream()
note: getTables APIs are not overridden yet, causing them to take the slow
openstream case each time. We should fix this, since openStream for windows
itself is slow (not native).
Review URL: https://codereview.chromium.org/12941006
git-svn-id: http://skia.googlecode.com/svn/trunk@8306 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 76edd76..7040f7c 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -210,6 +210,7 @@
}
protected:
+ virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE;
virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
@@ -1321,11 +1322,14 @@
if (face->fSerializeAsStream) {
// store the entire font in the fontData
- SkAutoTUnref<SkStream> fontStream(SkFontHost::OpenStream(face->uniqueID()));
- const uint32_t length = fontStream->getLength();
-
- stream->writePackedUInt(length);
- stream->writeStream(fontStream, length);
+ SkAutoTUnref<SkStream> fontStream(face->openStream(NULL));
+ if (fontStream.get()) {
+ const uint32_t length = fontStream->getLength();
+ stream->writePackedUInt(length);
+ stream->writeStream(fontStream, length);
+ } else {
+ stream->writePackedUInt(0);
+ }
} else {
stream->writePackedUInt(0);
}
@@ -1588,11 +1592,12 @@
return SkCreateFontMemResourceTypefaceFromLOGFONT(lf, fontReference);
}
-SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
+SkStream* LogFontTypeface::onOpenStream(int* ttcIndex) const {
+ *ttcIndex = 0;
+
const DWORD kTTCTag =
SkEndian_SwapBE32(SkSetFourByteTag('t', 't', 'c', 'f'));
- LOGFONT lf;
- GetLogFontByID(uniqueID, &lf);
+ LOGFONT lf = fLogFont;
HDC hdc = ::CreateCompatibleDC(NULL);
HFONT font = CreateFontIndirect(&lf);
@@ -1625,7 +1630,13 @@
return stream;
}
+SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
+ SkTypeface* typeface = SkTypefaceCache::FindByID(uniqueID);
+ return typeface ? typeface->openStream(NULL) : NULL;
+}
+
size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, int32_t* index) {
+ SkASSERT(!"SkFontHost::GetFileName is DEPRECATED\n");
return 0;
}