aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-12-11 11:06:00 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-11 11:06:00 -0800
commit1a4900e8be6086a824488dc98d4822e440815657 (patch)
tree6a56b14ad7f22000cb52b978740c57664f753570
parent895c43b28b27bb3124db3d32efd0c7219eb4a3cb (diff)
Force embedding full font when serializing pictures.
We can't do this unconditionally or pipe will become stupidly slow. DM's serialize mode fails subtly on Mac when we force embedding, so I've #ifdef'd that away. Other platforms look fine. BUG=skia: Review URL: https://codereview.chromium.org/796523002
-rw-r--r--include/core/SkTypeface.h4
-rw-r--r--src/core/SkPictureData.cpp5
-rw-r--r--src/core/SkTypeface.cpp14
3 files changed, 23 insertions, 0 deletions
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index c3ff3641b7..c2aa543ab2 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -137,6 +137,10 @@ public:
*/
void serialize(SkWStream*) const;
+ /** Like serialize, but write the whole font (not just a signature) if possible.
+ */
+ void serializeForcingEmbedding(SkWStream*) const;
+
/** Given the data previously written by serialize(), return a new instance
to a typeface referring to the same font. If that font is not available,
return null. If an instance is returned, the caller is responsible for
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 938274aceb..7fc165d219 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -180,7 +180,12 @@ void SkPictureData::WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec) {
rec.copyToArray((SkRefCnt**)array);
for (int i = 0; i < count; i++) {
+#ifdef SK_BUILD_FOR_UNIX
+ array[i]->serializeForcingEmbedding(stream);
+#else
+ // FIXME: Macs and Windows don't draw pixel-perfect if we embed fonts in the SKP.
array[i]->serialize(stream);
+#endif
}
}
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index c537d4aa2d..02d2bc89c0 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -155,12 +155,26 @@ void SkTypeface::serialize(SkWStream* wstream) const {
SkFontDescriptor desc(this->style());
this->onGetFontDescriptor(&desc, &isLocal);
+ // Embed font data if it's a local font.
if (isLocal && NULL == desc.getFontData()) {
int ttcIndex;
desc.setFontData(this->onOpenStream(&ttcIndex));
desc.setFontIndex(ttcIndex);
}
+ desc.serialize(wstream);
+}
+
+void SkTypeface::serializeForcingEmbedding(SkWStream* wstream) const {
+ bool ignoredIsLocal;
+ SkFontDescriptor desc(this->style());
+ this->onGetFontDescriptor(&desc, &ignoredIsLocal);
+ // Always embed font data.
+ if (NULL == desc.getFontData()) {
+ int ttcIndex;
+ desc.setFontData(this->onOpenStream(&ttcIndex));
+ desc.setFontIndex(ttcIndex);
+ }
desc.serialize(wstream);
}