Index: src/core/SkFontDescriptor.cpp |
diff --git a/src/core/SkFontDescriptor.cpp b/src/core/SkFontDescriptor.cpp |
index 8348d5fdba44ce16451964eb43fc31e9fc40f886..f477a2d69546efc15a52ecc7805b8163f209cf08 100644 |
--- a/src/core/SkFontDescriptor.cpp |
+++ b/src/core/SkFontDescriptor.cpp |
@@ -58,8 +58,8 @@ static void write_uint(SkWStream* stream, size_t n, uint32_t id) { |
stream->writePackedUInt(n); |
} |
-SkFontDescriptor::SkFontDescriptor(SkStream* stream) { |
- fStyle = (SkTypeface::Style)stream->readPackedUInt(); |
+bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) { |
+ result->fStyle = (SkTypeface::Style)stream->readPackedUInt(); |
SkAutoSTMalloc<4, SkFixed> axis; |
size_t axisCount = 0; |
@@ -67,13 +67,13 @@ SkFontDescriptor::SkFontDescriptor(SkStream* stream) { |
for (size_t id; (id = stream->readPackedUInt()) != kSentinel;) { |
switch (id) { |
case kFontFamilyName: |
- read_string(stream, &fFamilyName); |
+ read_string(stream, &result->fFamilyName); |
break; |
case kFullName: |
- read_string(stream, &fFullName); |
+ read_string(stream, &result->fFullName); |
break; |
case kPostscriptName: |
- read_string(stream, &fPostscriptName); |
+ read_string(stream, &result->fPostscriptName); |
break; |
case kFontAxes: |
axisCount = read_uint(stream); |
@@ -90,7 +90,7 @@ SkFontDescriptor::SkFontDescriptor(SkStream* stream) { |
break; |
default: |
SkDEBUGFAIL("Unknown id used by a font descriptor"); |
- return; |
+ return false; |
} |
} |
@@ -98,9 +98,14 @@ SkFontDescriptor::SkFontDescriptor(SkStream* stream) { |
if (length > 0) { |
SkAutoTUnref<SkData> data(SkData::NewUninitialized(length)); |
if (stream->read(data->writable_data(), length) == length) { |
- fFontData.reset(new SkFontData(new SkMemoryStream(data), index, axis, axisCount)); |
+ result->fFontData.reset(new SkFontData(new SkMemoryStream(data), |
+ index, axis, axisCount)); |
+ } else { |
+ SkDEBUGFAIL("Could not read font data"); |
+ return false; |
} |
} |
+ return true; |
} |
void SkFontDescriptor::serialize(SkWStream* stream) { |