Index: third_party/woff2/src/woff2_enc.cc |
diff --git a/third_party/woff2/src/woff2_enc.cc b/third_party/woff2/src/woff2_enc.cc |
index 48878b5f7e3100ca9973094f6e1623b67a12a38d..39e2ddc61d5a44e2c3962725d11b12314d396a04 100644 |
--- a/third_party/woff2/src/woff2_enc.cc |
+++ b/third_party/woff2/src/woff2_enc.cc |
@@ -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], |