*/
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
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
}
}
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);
}