Index: src/core/SkFontDescriptor.cpp |
diff --git a/src/core/SkFontDescriptor.cpp b/src/core/SkFontDescriptor.cpp |
index b2622d930007849b69782e003f5bec43d3c52d0d..cf58d6a700b00e76076ccf3a7da2f3c5a403d70c 100644 |
--- a/src/core/SkFontDescriptor.cpp |
+++ b/src/core/SkFontDescriptor.cpp |
@@ -17,12 +17,13 @@ enum { |
// These count backwards from 0xFF, so as not to collide with the SFNT |
// defines for names in its 'name' table. |
+ kFontAxes = 0xFC, |
kFontIndex = 0xFD, |
kFontFileName = 0xFE, |
kSentinel = 0xFF, |
}; |
-SkFontDescriptor::SkFontDescriptor(SkTypeface::Style style) : fFontIndex(0), fStyle(style) { } |
+SkFontDescriptor::SkFontDescriptor(SkTypeface::Style style) : fStyle(style) { } |
static void read_string(SkStream* stream, SkString* string) { |
const uint32_t length = SkToU32(stream->readPackedUInt()); |
@@ -32,8 +33,7 @@ static void read_string(SkStream* stream, SkString* string) { |
} |
} |
-static void write_string(SkWStream* stream, const SkString& string, |
- uint32_t id) { |
+static void write_string(SkWStream* stream, const SkString& string, uint32_t id) { |
if (!string.isEmpty()) { |
stream->writePackedUInt(id); |
stream->writePackedUInt(string.size()); |
@@ -50,7 +50,7 @@ static void write_uint(SkWStream* stream, size_t n, uint32_t id) { |
stream->writePackedUInt(n); |
} |
-SkFontDescriptor::SkFontDescriptor(SkStream* stream) : fFontIndex(0) { |
+SkFontDescriptor::SkFontDescriptor(SkStream* stream) { |
fStyle = (SkTypeface::Style)stream->readPackedUInt(); |
for (size_t id; (id = stream->readPackedUInt()) != kSentinel;) { |
@@ -64,8 +64,16 @@ SkFontDescriptor::SkFontDescriptor(SkStream* stream) : fFontIndex(0) { |
case kPostscriptName: |
read_string(stream, &fPostscriptName); |
break; |
+ case kFontAxes: { |
+ size_t count = read_uint(stream); |
+ fFontParameters.fAxis.reset(count); |
+ for (size_t i = 0; i < count; ++i) { |
+ fFontParameters.fAxis[i] = read_uint(stream); |
+ } |
+ break; |
+ } |
case kFontIndex: |
- fFontIndex = read_uint(stream); |
+ fFontParameters.fIndex = read_uint(stream); |
break; |
case kFontFileName: |
read_string(stream, &fFontFileName); |
@@ -92,8 +100,14 @@ void SkFontDescriptor::serialize(SkWStream* stream) { |
write_string(stream, fFullName, kFullName); |
write_string(stream, fPostscriptName, kPostscriptName); |
write_string(stream, fFontFileName, kFontFileName); |
- if (fFontIndex) { |
- write_uint(stream, fFontIndex, kFontIndex); |
+ if (fFontParameters.fIndex) { |
+ write_uint(stream, fFontParameters.fIndex, kFontIndex); |
+ } |
+ if (fFontParameters.fAxis.count()) { |
+ write_uint(stream, fFontParameters.fAxis.count(), kFontAxes); |
+ for (int i = 0; i < fFontParameters.fAxis.count(); ++i) { |
+ stream->writePackedUInt(fFontParameters.fAxis[i]); |
+ } |
} |
stream->writePackedUInt(kSentinel); |