Chromium Code Reviews| Index: src/core/SkTypeface.cpp |
| diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp |
| index ad928bb53efa0ee826c0e0bdc65dffcd78aa1cc7..5f1044136d887f58bfb73cab34d4449b4f68316d 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::CreateFromStream(SkStreamAsset* stream, const SkFontParameters& params) { |
| + SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| + return fm->createFromStream(stream, params); |
| +} |
| + |
| 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->onOpenStream2(&desc.getFontParameters())); |
| } |
| desc.serialize(wstream); |
| } |
| @@ -171,9 +176,7 @@ 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->onOpenStream2(&desc.getFontParameters())); |
| } |
| desc.serialize(wstream); |
| } |
| @@ -182,7 +185,7 @@ SkTypeface* SkTypeface::Deserialize(SkStream* stream) { |
| SkFontDescriptor desc(stream); |
| SkStreamAsset* data = desc.transferFontData(); |
| if (data) { |
| - SkTypeface* typeface = SkTypeface::CreateFromStream(data, desc.getFontIndex()); |
| + SkTypeface* typeface = SkTypeface::CreateFromStream(data, desc.getFontParameters()); |
| if (typeface) { |
| return typeface; |
| } |
| @@ -218,6 +221,14 @@ SkStreamAsset* SkTypeface::openStream(int* ttcIndex) const { |
| return this->onOpenStream(ttcIndex); |
| } |
| +SkStreamAsset* SkTypeface::openStream2(SkFontParameters* params) const { |
| + return this->onOpenStream2(params); |
| +} |
| + |
| +SkStreamAsset* SkTypeface::onOpenStream2(SkFontParameters* fontParams) const { |
|
bungeman-skia
2015/03/23 21:59:05
These are just the base 'default' shims to keep ex
|
| + return this->onOpenStream(&fontParams->fIndex); |
| +}; |
| + |
| int SkTypeface::charsToGlyphs(const void* chars, Encoding encoding, |
| uint16_t glyphs[], int glyphCount) const { |
| if (glyphCount <= 0) { |