Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: src/core/SkTypeface.cpp

Issue 1317913005: whitelist fallback typefaces (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove string change Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698