Index: src/ports/SkFontHost_android.cpp |
=================================================================== |
--- src/ports/SkFontHost_android.cpp (revision 8346) |
+++ src/ports/SkFontHost_android.cpp (working copy) |
@@ -316,6 +316,9 @@ |
virtual const char* getUniqueString() const = 0; |
virtual const char* getFilePath() const = 0; |
+protected: |
+ virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE; |
+ |
private: |
bool fIsSysFont; |
@@ -737,57 +740,19 @@ |
/////////////////////////////////////////////////////////////////////////////// |
-void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) { |
- |
- SkFontDescriptor descriptor; |
+void FamilyTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
+ bool* isLocalStream) const { |
{ |
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex); |
- descriptor.setFamilyName(find_family_name(face)); |
- descriptor.setStyle(face->style()); |
- descriptor.setFontFileName(((FamilyTypeface*)face)->getUniqueString()); |
+ desc->setFamilyName(find_family_name(this)); |
+ desc->setFontFileName(this->getUniqueString()); |
} |
- |
- descriptor.serialize(stream); |
- |
- const bool isCustomFont = !((FamilyTypeface*)face)->isSysFont(); |
- if (isCustomFont) { |
- // store the entire font in the fontData |
- SkStream* fontStream = face->openStream(NULL); |
- const uint32_t length = fontStream->getLength(); |
- |
- stream->writePackedUInt(length); |
- stream->writeStream(fontStream, length); |
- |
- fontStream->unref(); |
- } else { |
- stream->writePackedUInt(0); |
- } |
+ *isLocalStream = !this->isSysFont(); |
} |
+#if 0 // do we need this different name lookup for Deserialize? |
bungeman-skia
2013/03/22 21:04:05
Should we ask djsollen about this?
reed1
2013/03/25 12:26:27
Done.
|
SkTypeface* SkFontHost::Deserialize(SkStream* stream) { |
- { |
- SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex); |
- load_system_fonts(); |
- } |
- |
- SkFontDescriptor descriptor(stream); |
- const char* familyName = descriptor.getFamilyName(); |
- const char* fontFileName = descriptor.getFontFileName(); |
- const SkTypeface::Style style = descriptor.getStyle(); |
- |
- const uint32_t customFontDataLength = stream->readPackedUInt(); |
- if (customFontDataLength > 0) { |
- |
- // generate a new stream to store the custom typeface |
- SkMemoryStream* fontStream = new SkMemoryStream(customFontDataLength - 1); |
- stream->read((void*)fontStream->getMemoryBase(), customFontDataLength - 1); |
- |
- SkTypeface* face = CreateTypefaceFromStream(fontStream); |
- |
- fontStream->unref(); |
- return face; |
- } |
- |
+ ... |
if (NULL != fontFileName && 0 != *fontFileName) { |
const FontInitRec* rec = gSystemFonts; |
for (size_t i = 0; i < gNumSystemFonts; i++) { |
@@ -802,9 +767,9 @@ |
} |
} |
} |
- |
- return SkFontHost::CreateTypeface(NULL, familyName, style); |
+ ... |
} |
+#endif |
/////////////////////////////////////////////////////////////////////////////// |