// Copyright (c) 2009-2017 The OTS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
if (!table.ReadU32(&this->version) || this->version >> 16 != 1) { return Drop("Failed to read valid version");
} if (!table.ReadU16(&this->numLangs)) { return Drop("Failed to read numLangs");
}
// The following three fields are deprecated and ignored. We fix them up here // just for internal consistency, but the Graphite engine doesn't care. if (!table.ReadU16(&this->searchRange) ||
!table.ReadU16(&this->entrySelector) ||
!table.ReadU16(&this->rangeShift)) { return Drop("Failed to read searchRange..rangeShift");
} if (this->numLangs == 0) { if (this->searchRange != 0 || this->entrySelector != 0 || this->rangeShift != 0) {
this->searchRange = this->entrySelector = this->rangeShift = 0;
}
} else { unsigned floorLog2 = std::floor(std::log2(this->numLangs)); if (this->searchRange != (unsigned)std::pow(2, floorLog2) ||
this->entrySelector != floorLog2 ||
this->rangeShift != this->numLangs - this->searchRange) {
this->searchRange = (unsigned)std::pow(2, floorLog2);
this->entrySelector = floorLog2;
this->rangeShift = this->numLangs - this->searchRange;
}
}
std::unordered_set<size_t> unverified; //this->entries.resize(static_cast<unsigned long>(this->numLangs) + 1, this); for (unsignedlong i = 0; i <= this->numLangs; ++i) {
this->entries.emplace_back(this);
LanguageEntry& entry = this->entries[i]; if (!entry.ParsePart(table)) { return Drop("Failed to read entries[%u]", i);
} for (unsigned j = 0; j < entry.numSettings; ++j) {
size_t offset = entry.offset + j * 8; if (offset < entry.offset || offset > length) { return DropGraphite("Invalid LangFeatureSetting offset %zu/%zu",
offset, length);
}
unverified.insert(offset); // need to verify that this LanguageEntry points to valid // LangFeatureSetting
}
}
while (table.remaining()) {
unverified.erase(table.offset());
LangFeatureSetting setting(this); if (!setting.ParsePart(table)) { return Drop("Failed to read a LangFeatureSetting");
}
settings.push_back(setting);
}
if (!unverified.empty()) { return Drop("%zu incorrect offsets into settings", unverified.size());
} if (table.remaining()) { return Warning("%zu bytes unparsed", table.remaining());
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.