Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: third_party/woff2/src/font.cc

Issue 1873123002: Update woff2 to 4e698b8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: assert.h Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 Google Inc. All Rights Reserved. 1 // Copyright 2013 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 for (const auto& i : tables) { 42 for (const auto& i : tables) {
43 const Font::Table& table = i.second; 43 const Font::Table& table = i.second;
44 // This is a transformed table, we will write it together with the 44 // This is a transformed table, we will write it together with the
45 // original version. 45 // original version.
46 if (table.tag & 0x80808080) { 46 if (table.tag & 0x80808080) {
47 continue; 47 continue;
48 } 48 }
49 output_order.push_back(table.tag); 49 output_order.push_back(table.tag);
50 } 50 }
51 51
52 // Alphabetize and do not put loca immediately after glyf 52 // Alphabetize then put loca immediately after glyf
53 // This violates woff2 spec but results in a font that passes OTS
54 std::sort(output_order.begin(), output_order.end());
55 // TODO(user): change to match spec once browsers are on newer OTS
56 /*
57 auto glyf_loc = std::find(output_order.begin(), output_order.end(), 53 auto glyf_loc = std::find(output_order.begin(), output_order.end(),
58 kGlyfTableTag); 54 kGlyfTableTag);
59 auto loca_loc = std::find(output_order.begin(), output_order.end(), 55 auto loca_loc = std::find(output_order.begin(), output_order.end(),
60 kLocaTableTag); 56 kLocaTableTag);
61 if (glyf_loc != output_order.end() && loca_loc != output_order.end()) { 57 if (glyf_loc != output_order.end() && loca_loc != output_order.end()) {
62 output_order.erase(loca_loc); 58 output_order.erase(loca_loc);
63 output_order.insert(std::find(output_order.begin(), output_order.end(), 59 output_order.insert(std::find(output_order.begin(), output_order.end(),
64 kGlyfTableTag) + 1, kLocaTableTag); 60 kGlyfTableTag) + 1, kLocaTableTag);
65 }*/ 61 }
66 62
67 return output_order; 63 return output_order;
68 } 64 }
69 65
70 bool ReadTrueTypeFont(Buffer* file, const uint8_t* data, size_t len, 66 bool ReadTrueTypeFont(Buffer* file, const uint8_t* data, size_t len,
71 Font* font) { 67 Font* font) {
72 // We don't care about the search_range, entry_selector and range_shift 68 // We don't care about the search_range, entry_selector and range_shift
73 // fields, they will always be computed upon writing the font. 69 // fields, they will always be computed upon writing the font.
74 if (!file->ReadU16(&font->num_tables) || 70 if (!file->ReadU16(&font->num_tables) ||
75 !file->Skip(6)) { 71 !file->Skip(6)) {
76 return FONT_COMPRESSION_FAILURE(); 72 return FONT_COMPRESSION_FAILURE();
77 } 73 }
78 74
79 std::map<uint32_t, uint32_t> intervals; 75 std::map<uint32_t, uint32_t> intervals;
80 for (uint16_t i = 0; i < font->num_tables; ++i) { 76 for (uint16_t i = 0; i < font->num_tables; ++i) {
81 Font::Table table; 77 Font::Table table;
78 table.flag_byte = 0;
82 table.reuse_of = NULL; 79 table.reuse_of = NULL;
83 if (!file->ReadU32(&table.tag) || 80 if (!file->ReadU32(&table.tag) ||
84 !file->ReadU32(&table.checksum) || 81 !file->ReadU32(&table.checksum) ||
85 !file->ReadU32(&table.offset) || 82 !file->ReadU32(&table.offset) ||
86 !file->ReadU32(&table.length)) { 83 !file->ReadU32(&table.length)) {
87 return FONT_COMPRESSION_FAILURE(); 84 return FONT_COMPRESSION_FAILURE();
88 } 85 }
89 if ((table.offset & 3) != 0 || 86 if ((table.offset & 3) != 0 ||
90 table.length > len || 87 table.length > len ||
91 len - table.length < table.offset) { 88 len - table.length < table.offset) {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 std::map<uint32_t, Font::Table>::iterator it = 388 std::map<uint32_t, Font::Table>::iterator it =
392 font->tables.find(kDsigTableTag); 389 font->tables.find(kDsigTableTag);
393 if (it != font->tables.end()) { 390 if (it != font->tables.end()) {
394 font->tables.erase(it); 391 font->tables.erase(it);
395 font->num_tables = font->tables.size(); 392 font->num_tables = font->tables.size();
396 } 393 }
397 return true; 394 return true;
398 } 395 }
399 396
400 } // namespace woff2 397 } // namespace woff2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698