| Index: src/core/SkTypeface.cpp
|
| diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
|
| index 81daf2f610af2eb7c693f796ca812c3dbe8fdb9f..3ed2565ee23715cd1e16c75ad701a0e26c6fd3bc 100644
|
| --- a/src/core/SkTypeface.cpp
|
| +++ b/src/core/SkTypeface.cpp
|
| @@ -20,8 +20,16 @@ SkTypeface::SkTypeface(const SkFontStyle& style, SkFontID fontID, bool isFixedPi
|
|
|
| SkTypeface::~SkTypeface() { }
|
|
|
| +#ifdef SK_WHITELIST_SERIALIZED_TYPEFACES
|
| +extern void WhitelistSerializeTypeface(const SkTypeface*, SkWStream* );
|
| +#define SK_TYPEFACE_DELEGATE WhitelistSerializeTypeface
|
| +#else
|
| +#define SK_TYPEFACE_DELEGATE nullptr
|
| +#endif
|
|
|
| SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ) = nullptr;
|
| +void (*gSerializeTypefaceDelegate)(const SkTypeface*, SkWStream* ) = SK_TYPEFACE_DELEGATE;
|
| +SkTypeface* (*gDeserializeTypefaceDelegate)(SkStream* ) = nullptr;
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| @@ -164,6 +172,10 @@ SkTypeface* SkTypeface::CreateFromFile(const char path[], int index) {
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| void SkTypeface::serialize(SkWStream* wstream) const {
|
| + if (gSerializeTypefaceDelegate) {
|
| + (*gSerializeTypefaceDelegate)(this, wstream);
|
| + return;
|
| + }
|
| bool isLocal = false;
|
| SkFontDescriptor desc(this->style());
|
| this->onGetFontDescriptor(&desc, &isLocal);
|
| @@ -175,19 +187,10 @@ void SkTypeface::serialize(SkWStream* wstream) const {
|
| desc.serialize(wstream);
|
| }
|
|
|
| -void SkTypeface::serializeForcingEmbedding(SkWStream* wstream) const {
|
| - bool ignoredIsLocal;
|
| - SkFontDescriptor desc(this->style());
|
| - this->onGetFontDescriptor(&desc, &ignoredIsLocal);
|
| -
|
| - // Always embed font data.
|
| - if (!desc.hasFontData()) {
|
| - desc.setFontData(this->onCreateFontData());
|
| - }
|
| - desc.serialize(wstream);
|
| -}
|
| -
|
| SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
|
| + if (gDeserializeTypefaceDelegate) {
|
| + return (*gDeserializeTypefaceDelegate)(stream);
|
| + }
|
| SkFontDescriptor desc(stream);
|
| SkFontData* data = desc.detachFontData();
|
| if (data) {
|
|
|