| Index: src/core/SkTypeface.cpp
|
| diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
|
| index 7f79c450502ab76193a21db3d34ba196ea04c462..a9a50aa2d944ff34da5fcb73e8d00e7791127f04 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);
|
| @@ -153,13 +158,13 @@ SkTypeface* SkTypeface::CreateFromFile(const char path[], int index) {
|
| void SkTypeface::serialize(SkWStream* wstream) const {
|
| bool isLocal = false;
|
| SkFontDescriptor desc(this->style());
|
| + // This is 'get request', i.e., what do I do to search for this font?
|
| 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);
|
| + // This is 'get font', i.e., what do I need to reconstruct this font without a search?
|
| + desc.setFontData(this->onCreateFontData());
|
| }
|
| desc.serialize(wstream);
|
| }
|
| @@ -171,18 +176,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 +221,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) {
|
|
|