Index: src/ports/SkFontHost_win_dw.cpp |
=================================================================== |
--- src/ports/SkFontHost_win_dw.cpp (revision 8346) |
+++ src/ports/SkFontHost_win_dw.cpp (working copy) |
@@ -485,6 +485,7 @@ |
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
SkAdvancedTypefaceMetrics::PerGlyphInfo, |
const uint32_t*, uint32_t) const SK_OVERRIDE; |
+ virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE; |
}; |
class SkScalerContext_Windows : public SkScalerContext { |
@@ -1046,13 +1047,11 @@ |
path->transform(mat); |
} |
-void SkFontHost::Serialize(const SkTypeface* rawFace, SkWStream* stream) { |
- const DWriteFontTypeface* face = static_cast<const DWriteFontTypeface*>(rawFace); |
- SkFontDescriptor descriptor(face->style()); |
- |
+void DWriteFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
+ bool* isLocalStream) const { |
// Get the family name. |
SkTScopedComPtr<IDWriteLocalizedStrings> dwFamilyNames; |
- HRV(face->fDWriteFontFamily->GetFamilyNames(&dwFamilyNames)); |
+ HRV(fDWriteFontFamily->GetFamilyNames(&dwFamilyNames)); |
UINT32 dwFamilyNamesLength; |
HRV(dwFamilyNames->GetStringLength(0, &dwFamilyNamesLength)); |
@@ -1070,38 +1069,10 @@ |
str_len = WideCharToMultiByte(CP_UTF8, 0, dwFamilyNameChar.begin(), -1, |
utf8FamilyName.begin(), str_len, NULL, NULL); |
- descriptor.setFamilyName(utf8FamilyName.begin()); |
- //TODO: FileName and PostScriptName currently unsupported. |
- |
- descriptor.serialize(stream); |
- |
- if (NULL != face->fDWriteFontFileLoader.get()) { |
- // store the entire font in the fontData |
- SkStream* fontStream = face->fDWriteFontFileLoader->fStream.get(); |
- const uint32_t length = fontStream->getLength(); |
- |
- stream->writePackedUInt(length); |
- stream->writeStream(fontStream, length); |
- } else { |
- stream->writePackedUInt(0); |
- } |
+ desc->setFamilyName(utf8FamilyName.begin()); |
+ *isLocalStream = SkToBool(fDWriteFontFileLoader.get()); |
} |
-SkTypeface* SkFontHost::Deserialize(SkStream* stream) { |
- SkFontDescriptor descriptor(stream); |
- |
- const uint32_t customFontDataLength = stream->readPackedUInt(); |
- if (customFontDataLength > 0) { |
- // generate a new stream to store the custom typeface |
- SkAutoTUnref<SkMemoryStream> fontStream(SkNEW_ARGS(SkMemoryStream, (customFontDataLength - 1))); |
- stream->read((void*)fontStream->getMemoryBase(), customFontDataLength - 1); |
- |
- return CreateTypefaceFromStream(fontStream.get()); |
- } |
- |
- return SkFontHost::CreateTypeface(NULL, descriptor.getFamilyName(), descriptor.getStyle()); |
-} |
- |
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { |
IDWriteFactory* factory; |
HRN(get_dwrite_factory(&factory)); |