Index: src/core/SkFontDescriptor.cpp |
diff --git a/src/core/SkFontDescriptor.cpp b/src/core/SkFontDescriptor.cpp |
index 69fdc154326936a56d46b1b1dc00e78f9990d3de..85629efa7ec640bf53d5a6d9533b0916c8d3afd7 100644 |
--- a/src/core/SkFontDescriptor.cpp |
+++ b/src/core/SkFontDescriptor.cpp |
@@ -23,7 +23,7 @@ enum { |
kSentinel = 0xFF, |
}; |
-SkFontDescriptor::SkFontDescriptor(SkTypeface::Style style) : fStyle(style) { } |
+SkFontDescriptor::SkFontDescriptor() { } |
static void read_string(SkStream* stream, SkString* string) { |
const uint32_t length = SkToU32(stream->readPackedUInt()); |
@@ -59,7 +59,15 @@ static void write_uint(SkWStream* stream, size_t n, uint32_t id) { |
} |
bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) { |
- result->fStyle = (SkTypeface::Style)stream->readPackedUInt(); |
+ size_t styleBits = stream->readPackedUInt(); |
+ if (styleBits <= 2) { |
+ // Remove this branch when MIN_PICTURE_VERSION > 45 |
+ result->fStyle = SkFontStyle::FromOldStyle(styleBits); |
+ } else { |
+ result->fStyle = SkFontStyle((styleBits >> 16) & 0xFFFF, |
+ (styleBits >> 8 ) & 0xFF, |
+ static_cast<SkFontStyle::Slant>(styleBits & 0xFF)); |
+ } |
SkAutoSTMalloc<4, SkFixed> axis; |
size_t axisCount = 0; |
@@ -109,7 +117,8 @@ bool SkFontDescriptor::Deserialize(SkStream* stream, SkFontDescriptor* result) { |
} |
void SkFontDescriptor::serialize(SkWStream* stream) { |
- stream->writePackedUInt(fStyle); |
+ uint32_t styleBits = (fStyle.weight() << 16) | (fStyle.width() << 8) | (fStyle.slant()); |
+ stream->writePackedUInt(styleBits); |
write_string(stream, fFamilyName, kFontFamilyName); |
write_string(stream, fFullName, kFullName); |