| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cmap.h" | 5 #include "cmap.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 subtable_headers[i].language = 0; | 651 subtable_headers[i].language = 0; |
| 652 break; | 652 break; |
| 653 default: | 653 default: |
| 654 subtable_headers[i].length = 0; | 654 subtable_headers[i].length = 0; |
| 655 subtable_headers[i].language = 0; | 655 subtable_headers[i].language = 0; |
| 656 break; | 656 break; |
| 657 } | 657 } |
| 658 } | 658 } |
| 659 | 659 |
| 660 // check if the table is sorted first by platform ID, then by encoding ID. | 660 // check if the table is sorted first by platform ID, then by encoding ID. |
| 661 uint32_t last_id = 0; | 661 for (unsigned i = 1; i < num_tables; ++i) { |
| 662 for (unsigned i = 0; i < num_tables; ++i) { | 662 if (subtable_headers[i - 1].platform > subtable_headers[i].platform || |
| 663 uint32_t current_id | 663 (subtable_headers[i - 1].platform == subtable_headers[i].platform && |
| 664 = (subtable_headers[i].platform << 24) | 664 (subtable_headers[i - 1].encoding > subtable_headers[i].encoding || |
| 665 + (subtable_headers[i].encoding << 16) | 665 (subtable_headers[i - 1].encoding == subtable_headers[i].encoding && |
| 666 + subtable_headers[i].language; | 666 subtable_headers[i - 1].language > subtable_headers[i].language)))) |
| 667 if ((i != 0) && (last_id >= current_id)) { | |
| 668 OTS_WARNING("subtable %d with platform ID %d, encoding ID %d, language ID
%d " | 667 OTS_WARNING("subtable %d with platform ID %d, encoding ID %d, language ID
%d " |
| 669 "following subtable with platform ID %d, encoding ID %d, langu
age ID %d", | 668 "following subtable with platform ID %d, encoding ID %d, langu
age ID %d", |
| 670 i, | 669 i, |
| 671 (uint8_t)(current_id >> 24), (uint8_t)(current_id >> 16), (uin
t8_t)(current_id), | 670 subtable_headers[i].platform, |
| 672 (uint8_t)(last_id >> 24), (uint8_t)(last_id >> 16), (uint8_t)(
last_id)); | 671 subtable_headers[i].encoding, |
| 673 } | 672 subtable_headers[i].language, |
| 674 last_id = current_id; | 673 subtable_headers[i - 1].platform, |
| 674 subtable_headers[i - 1].encoding, |
| 675 subtable_headers[i - 1].language); |
| 675 } | 676 } |
| 676 | 677 |
| 677 // Now, verify that all the lengths are sane | 678 // Now, verify that all the lengths are sane |
| 678 for (unsigned i = 0; i < num_tables; ++i) { | 679 for (unsigned i = 0; i < num_tables; ++i) { |
| 679 if (!subtable_headers[i].length) continue; | 680 if (!subtable_headers[i].length) continue; |
| 680 if (subtable_headers[i].length > 1024 * 1024 * 1024) { | 681 if (subtable_headers[i].length > 1024 * 1024 * 1024) { |
| 681 return OTS_FAILURE_MSG("Bad cmap subtable %d length", i); | 682 return OTS_FAILURE_MSG("Bad cmap subtable %d length", i); |
| 682 } | 683 } |
| 683 // We know that both the offset and length are < 1GB, so the following | 684 // We know that both the offset and length are < 1GB, so the following |
| 684 // addition doesn't overflow | 685 // addition doesn't overflow |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 font->cmap_reused = true; | 1079 font->cmap_reused = true; |
| 1079 } | 1080 } |
| 1080 | 1081 |
| 1081 void ots_cmap_free(Font *font) { | 1082 void ots_cmap_free(Font *font) { |
| 1082 delete font->cmap; | 1083 delete font->cmap; |
| 1083 } | 1084 } |
| 1084 | 1085 |
| 1085 } // namespace ots | 1086 } // namespace ots |
| 1086 | 1087 |
| 1087 #undef TABLE_NAME | 1088 #undef TABLE_NAME |
| OLD | NEW |