// 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 != 3) { return DropGraphite("Failed to read version");
} if (!table.ReadU32(&this->compHead)) { return DropGraphite("Failed to read compression header");
} switch ((this->compHead & SCHEME) >> 27) { case 0: // uncompressed break; case 1: { // lz4 if (prevent_decompression) { return DropGraphite("Illegal nested compression");
}
size_t decompressed_size = this->compHead & FULL_SIZE; if (decompressed_size < length) { return DropGraphite("Decompressed size is less than compressed size");
} if (decompressed_size == 0) { return DropGraphite("Decompressed size is set to 0");
} // decompressed table must be <= OTS_MAX_DECOMPRESSED_TABLE_SIZE if (decompressed_size > OTS_MAX_DECOMPRESSED_TABLE_SIZE) { return DropGraphite("Decompressed size exceeds %gMB: %gMB",
OTS_MAX_DECOMPRESSED_TABLE_SIZE / (1024.0 * 1024.0),
decompressed_size / (1024.0 * 1024.0));
}
std::unique_ptr<uint8_t> decompressed(new uint8_t[decompressed_size]());
size_t outputSize = 0; bool ret = mozilla::Compression::LZ4::decompressPartial( reinterpret_cast<constchar*>(data + table.offset()),
table.remaining(), // input buffer size (input size + padding) reinterpret_cast<char*>(decompressed.get()),
decompressed_size, // target output size
&outputSize); // return output size if (!ret || outputSize != decompressed_size) { return DropGraphite("Decompression failed");
} return this->Parse(decompressed.get(), decompressed_size, true);
} default: return DropGraphite("Unknown compression scheme");
} if (this->compHead & RESERVED) {
Warning("Nonzero reserved");
}
const std::vector<uint32_t>& locations = gloc->GetLocations(); if (locations.empty()) { return DropGraphite("No locations from Gloc table");
}
std::list<uint32_t> unverified(locations.begin(), locations.end()); //this->entries.resize(locations.size() - 1, this); for (size_t i = 0; i < locations.size() - 1; ++i) {
this->entries.emplace_back(this); if (table.offset() != unverified.front()) { return DropGraphite("Offset check failed for a GlyphAttrs");
}
unverified.pop_front(); if (!this->entries[i].ParsePart(table,
unverified.front() - table.offset())) { // unverified.front() is guaranteed to exist because of the number of // iterations of this loop return DropGraphite("Failed to read a GlyphAttrs");
}
}
if (unverified.size() != 1 || unverified.front() != table.offset()) { return DropGraphite("%zu location(s) could not be verified", unverified.size());
} if (table.remaining()) { return Warning("%zu bytes unparsed", table.remaining());
} returntrue;
}
bool OpenTypeGLAT_v3::GlyphAttrs::
OctaboxMetrics::ParsePart(Buffer& table) { if (!table.ReadU16(&this->subbox_bitmap)) { return parent->Error("OctaboxMetrics: Failed to read subbox_bitmap");
} if (!table.ReadU8(&this->diag_neg_min)) { return parent->Error("OctaboxMetrics: Failed to read diag_neg_min");
} if (!table.ReadU8(&this->diag_neg_max) ||
this->diag_neg_max < this->diag_neg_min) { return parent->Error("OctaboxMetrics: Failed to read valid diag_neg_max");
} if (!table.ReadU8(&this->diag_pos_min)) { return parent->Error("OctaboxMetrics: Failed to read diag_pos_min");
} if (!table.ReadU8(&this->diag_pos_max) ||
this->diag_pos_max < this->diag_pos_min) { return parent->Error("OctaboxMetrics: Failed to read valid diag_pos_max");
}
unsigned subboxes_len = 0; // count of 1's in this->subbox_bitmap for (uint16_t i = this->subbox_bitmap; i; i >>= 1) { if (i & 0b1) {
++subboxes_len;
}
} //this->subboxes.resize(subboxes_len, parent); for (unsigned i = 0; i < subboxes_len; i++) {
this->subboxes.emplace_back(parent); if (!this->subboxes[i].ParsePart(table)) { return parent->Error("OctaboxMetrics: Failed to read subbox[%u]", i);
}
} 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.