| Index: src/core/SkTypeface.cpp
|
| diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
|
| index bbf3f44896b191866d10c821d4d6359b6e55d301..db7f1cc97b4809f893b11811b9f78a94cf0baff2 100644
|
| --- a/src/core/SkTypeface.cpp
|
| +++ b/src/core/SkTypeface.cpp
|
| @@ -143,6 +143,11 @@ SkTypeface* SkTypeface::CreateFromStream(SkStreamAsset* stream, int index) {
|
| return fm->createFromStream(stream, index);
|
| }
|
|
|
| +SkTypeface* SkTypeface::CreateFromFontData(SkFontData* data) {
|
| + SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
| + return fm->createFromFontData(data);
|
| +}
|
| +
|
| SkTypeface* SkTypeface::CreateFromFile(const char path[], int index) {
|
| SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
|
| return fm->createFromFile(path, index);
|
| @@ -156,10 +161,8 @@ void SkTypeface::serialize(SkWStream* wstream) const {
|
| this->onGetFontDescriptor(&desc, &isLocal);
|
|
|
| // Embed font data if it's a local font.
|
| - if (isLocal && !desc.hasFontData()) {
|
| - int ttcIndex;
|
| - desc.setFontData(this->onOpenStream(&ttcIndex));
|
| - desc.setFontIndex(ttcIndex);
|
| + if (!desc.hasFontData()) {
|
| + desc.setFontData(this->onCreateFontData());
|
| }
|
| desc.serialize(wstream);
|
| }
|
| @@ -171,18 +174,16 @@ void SkTypeface::serializeForcingEmbedding(SkWStream* wstream) const {
|
|
|
| // Always embed font data.
|
| if (!desc.hasFontData()) {
|
| - int ttcIndex;
|
| - desc.setFontData(this->onOpenStream(&ttcIndex));
|
| - desc.setFontIndex(ttcIndex);
|
| + desc.setFontData(this->onCreateFontData());
|
| }
|
| desc.serialize(wstream);
|
| }
|
|
|
| SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
|
| SkFontDescriptor desc(stream);
|
| - SkStreamAsset* data = desc.transferFontData();
|
| + SkFontData* data = desc.getFontData();
|
| if (data) {
|
| - SkTypeface* typeface = SkTypeface::CreateFromStream(data, desc.getFontIndex());
|
| + SkTypeface* typeface = SkTypeface::CreateFromFontData(data);
|
| if (typeface) {
|
| return typeface;
|
| }
|
| @@ -218,6 +219,17 @@ SkStreamAsset* SkTypeface::openStream(int* ttcIndex) const {
|
| return this->onOpenStream(ttcIndex);
|
| }
|
|
|
| +SkFontData* SkTypeface::createFontData() const {
|
| + return this->onCreateFontData();
|
| +}
|
| +
|
| +// This implementation is temporary until this method can be made pure virtual.
|
| +SkFontData* SkTypeface::onCreateFontData() const {
|
| + int index;
|
| + SkAutoTDelete<SkStreamAsset> stream(this->onOpenStream(&index));
|
| + return new SkFontData(stream.detach(), index, 0, NULL);
|
| +};
|
| +
|
| int SkTypeface::charsToGlyphs(const void* chars, Encoding encoding,
|
| uint16_t glyphs[], int glyphCount) const {
|
| if (glyphCount <= 0) {
|
|
|