Fix bug where table could mismatch header vs data when allow_transforms was set false (not easily possible w/current tools)

This commit is contained in:
Rod Sheeter
2016-05-06 13:10:33 -07:00
parent 2bc6acf6df
commit 9476664fd6
+9 -7
View File
@@ -272,20 +272,22 @@ bool ConvertTTFToWOFF2(const uint8_t *data, size_t length,
std::vector<uint8_t> compression_buf(compression_buffer_size);
uint32_t total_compressed_length = compression_buffer_size;
// Collect all transformed data into one place.
// Collect all transformed data into one place in output order.
std::vector<uint8_t> transform_buf(total_transform_length);
size_t transform_offset = 0;
for (const auto& font : font_collection.fonts) {
for (const auto& i : font.tables) {
const Font::Table* table = font.FindTable(i.second.tag ^ 0x80808080);
if (i.second.IsReused()) continue;
if (i.second.tag & 0x80808080) continue;
for (const auto tag : font.OutputOrderedTags()) {
const Font::Table& original = font.tables.at(tag);
if (original.IsReused()) continue;
if (tag & 0x80808080) continue;
const Font::Table* table_to_store = font.FindTable(tag ^ 0x80808080);
if (table_to_store == NULL) table_to_store = &original;
if (table == NULL) table = &i.second;
StoreBytes(table->data, table->length,
StoreBytes(table_to_store->data, table_to_store->length,
&transform_offset, &transform_buf[0]);
}
}
// Compress all transformed data in one stream.
if (!Woff2Compress(transform_buf.data(), total_transform_length,
&compression_buf[0],