aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkFontDescriptor.cpp
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2015-05-13 12:16:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-13 12:16:41 -0700
commit5ae1312c9faa25531c07e591b4dff6804020f121 (patch)
tree5ad34f4f5ddbe8f628d078be9480444d0d883f1d /src/core/SkFontDescriptor.cpp
parent1573206f202c6d2ffcffab78b17160da95a80466 (diff)
Revert of Font variations. (patchset #21 id:400001 of https://codereview.chromium.org/1027373002/)
Reason for revert: Mac failing to build due to CFNumberType in Chromium Canary. Original issue's description: > Font variations. > > Multiple Master and TrueType fonts support variation axes. > This implements back-end support for axes on platforms which > support it. > > Committed: https://skia.googlesource.com/skia/+/05773ed30920c0214d1433c07cf6360a05476c97 TBR=reed@google.com,mtklein@google.com,djsollen@google.com,halcanary@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1128913008
Diffstat (limited to 'src/core/SkFontDescriptor.cpp')
-rw-r--r--src/core/SkFontDescriptor.cpp42
1 files changed, 11 insertions, 31 deletions
diff --git a/src/core/SkFontDescriptor.cpp b/src/core/SkFontDescriptor.cpp
index cb149b98a9..4a6b5db837 100644
--- a/src/core/SkFontDescriptor.cpp
+++ b/src/core/SkFontDescriptor.cpp
@@ -17,13 +17,12 @@ 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, // Remove when MIN_PICTURE_VERSION > 41
kSentinel = 0xFF,
};
-SkFontDescriptor::SkFontDescriptor(SkTypeface::Style style) : fStyle(style) { }
+SkFontDescriptor::SkFontDescriptor(SkTypeface::Style style) : fFontIndex(0), fStyle(style) { }
static void read_string(SkStream* stream, SkString* string) {
const uint32_t length = SkToU32(stream->readPackedUInt());
@@ -41,7 +40,8 @@ static void skip_string(SkStream* stream) {
}
}
-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());
@@ -58,12 +58,9 @@ static void write_uint(SkWStream* stream, size_t n, uint32_t id) {
stream->writePackedUInt(n);
}
-SkFontDescriptor::SkFontDescriptor(SkStream* stream) {
+SkFontDescriptor::SkFontDescriptor(SkStream* stream) : fFontIndex(0) {
fStyle = (SkTypeface::Style)stream->readPackedUInt();
- SkAutoSTMalloc<4, SkFixed> axis;
- size_t axisCount = 0;
- size_t index = 0;
for (size_t id; (id = stream->readPackedUInt()) != kSentinel;) {
switch (id) {
case kFontFamilyName:
@@ -75,15 +72,8 @@ SkFontDescriptor::SkFontDescriptor(SkStream* stream) {
case kPostscriptName:
read_string(stream, &fPostscriptName);
break;
- case kFontAxes:
- axisCount = read_uint(stream);
- axis.reset(axisCount);
- for (size_t i = 0; i < axisCount; ++i) {
- axis[i] = read_uint(stream);
- }
- break;
case kFontIndex:
- index = read_uint(stream);
+ fFontIndex = read_uint(stream);
break;
case kFontFileName: // Remove when MIN_PICTURE_VERSION > 41
skip_string(stream);
@@ -98,8 +88,7 @@ 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(SkNEW_ARGS(SkMemoryStream, (data)), index,
- axis, axisCount));
+ fFontData.reset(SkNEW_ARGS(SkMemoryStream, (data)));
}
}
}
@@ -110,25 +99,16 @@ void SkFontDescriptor::serialize(SkWStream* stream) {
write_string(stream, fFamilyName, kFontFamilyName);
write_string(stream, fFullName, kFullName);
write_string(stream, fPostscriptName, kPostscriptName);
- if (fFontData.get()) {
- if (fFontData->getIndex()) {
- write_uint(stream, fFontData->getIndex(), kFontIndex);
- }
- if (fFontData->getAxisCount()) {
- write_uint(stream, fFontData->getAxisCount(), kFontAxes);
- for (int i = 0; i < fFontData->getAxisCount(); ++i) {
- stream->writePackedUInt(fFontData->getAxis()[i]);
- }
- }
+ if (fFontIndex) {
+ write_uint(stream, fFontIndex, kFontIndex);
}
stream->writePackedUInt(kSentinel);
- if (fFontData.get() && fFontData->hasStream()) {
- SkAutoTDelete<SkStreamAsset> fontData(fFontData->detachStream());
- size_t length = fontData->getLength();
+ if (fFontData) {
+ size_t length = fFontData->getLength();
stream->writePackedUInt(length);
- stream->writeStream(fontData, length);
+ stream->writeStream(fFontData, length);
} else {
stream->writePackedUInt(0);
}