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
This commit is contained in:
mtklein 2014-12-11 11:06:00 -08:00 committed by Commit bot
parent 895c43b28b
commit 1a4900e8be
3 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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
}
}

View File

@ -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);
}