| Index: src/core/SkTypeface.cpp
|
| diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
|
| index 6d9759f42c4c536aec4492d9da24ea938a6bef66..0f5d70b1a8ccbe28ce2c51252223e2e70f11ed31 100644
|
| --- a/src/core/SkTypeface.cpp
|
| +++ b/src/core/SkTypeface.cpp
|
| @@ -143,11 +143,6 @@
|
| 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);
|
| @@ -161,8 +156,10 @@
|
| this->onGetFontDescriptor(&desc, &isLocal);
|
|
|
| // Embed font data if it's a local font.
|
| - if (!desc.hasFontData()) {
|
| - desc.setFontData(this->onCreateFontData());
|
| + if (isLocal && !desc.hasFontData()) {
|
| + int ttcIndex;
|
| + desc.setFontData(this->onOpenStream(&ttcIndex));
|
| + desc.setFontIndex(ttcIndex);
|
| }
|
| desc.serialize(wstream);
|
| }
|
| @@ -174,16 +171,18 @@
|
|
|
| // Always embed font data.
|
| if (!desc.hasFontData()) {
|
| - desc.setFontData(this->onCreateFontData());
|
| + int ttcIndex;
|
| + desc.setFontData(this->onOpenStream(&ttcIndex));
|
| + desc.setFontIndex(ttcIndex);
|
| }
|
| desc.serialize(wstream);
|
| }
|
|
|
| SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
|
| SkFontDescriptor desc(stream);
|
| - SkFontData* data = desc.detachFontData();
|
| + SkStreamAsset* data = desc.transferFontData();
|
| if (data) {
|
| - SkTypeface* typeface = SkTypeface::CreateFromFontData(data);
|
| + SkTypeface* typeface = SkTypeface::CreateFromStream(data, desc.getFontIndex());
|
| if (typeface) {
|
| return typeface;
|
| }
|
| @@ -218,17 +217,6 @@
|
| }
|
| 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, NULL, 0);
|
| -};
|
|
|
| int SkTypeface::charsToGlyphs(const void* chars, Encoding encoding,
|
| uint16_t glyphs[], int glyphCount) const {
|
|
|