diff options
-rw-r--r-- | include/core/SkTypeface.h | 4 | ||||
-rw-r--r-- | src/core/SkPictureData.cpp | 5 | ||||
-rw-r--r-- | src/core/SkTypeface.cpp | 14 |
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); } |