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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 bool Parse31013(ots::OpenTypeFile *file, | 344 bool Parse31013(ots::OpenTypeFile *file, |
345 const uint8_t *data, size_t length, uint16_t num_glyphs) { | 345 const uint8_t *data, size_t length, uint16_t num_glyphs) { |
346 ots::Buffer subtable(data, length); | 346 ots::Buffer subtable(data, length); |
347 | 347 |
348 // Format 13 tables are simple. We parse these and fully serialise them | 348 // Format 13 tables are simple. We parse these and fully serialise them |
349 // later. | 349 // later. |
350 | 350 |
351 if (!subtable.Skip(8)) { | 351 if (!subtable.Skip(8)) { |
352 return OTS_FAILURE(); | 352 return OTS_FAILURE(); |
353 } | 353 } |
354 uint16_t language = 0; | 354 uint32_t language = 0; |
355 if (!subtable.ReadU16(&language)) { | 355 if (!subtable.ReadU32(&language)) { |
356 return OTS_FAILURE(); | 356 return OTS_FAILURE(); |
357 } | 357 } |
358 if (language) { | 358 if (language) { |
359 return OTS_FAILURE(); | 359 return OTS_FAILURE(); |
360 } | 360 } |
361 | 361 |
362 uint32_t num_groups = 0; | 362 uint32_t num_groups = 0; |
363 if (!subtable.ReadU32(&num_groups)) { | 363 if (!subtable.ReadU32(&num_groups)) { |
364 return OTS_FAILURE(); | 364 return OTS_FAILURE(); |
365 } | 365 } |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 } | 975 } |
976 } | 976 } |
977 | 977 |
978 const off_t offset_31013 = out->Tell(); | 978 const off_t offset_31013 = out->Tell(); |
979 if (have_31013) { | 979 if (have_31013) { |
980 std::vector<OpenTypeCMAPSubtableRange> &groups | 980 std::vector<OpenTypeCMAPSubtableRange> &groups |
981 = file->cmap->subtable_3_10_13; | 981 = file->cmap->subtable_3_10_13; |
982 const unsigned num_groups = groups.size(); | 982 const unsigned num_groups = groups.size(); |
983 if (!out->WriteU16(13) || | 983 if (!out->WriteU16(13) || |
984 !out->WriteU16(0) || | 984 !out->WriteU16(0) || |
985 !out->WriteU32(num_groups * 12 + 14) || | 985 !out->WriteU32(num_groups * 12 + 16) || |
986 !out->WriteU32(0) || | 986 !out->WriteU32(0) || |
987 !out->WriteU32(num_groups)) { | 987 !out->WriteU32(num_groups)) { |
988 return OTS_FAILURE(); | 988 return OTS_FAILURE(); |
989 } | 989 } |
990 | 990 |
991 for (unsigned i = 0; i < num_groups; ++i) { | 991 for (unsigned i = 0; i < num_groups; ++i) { |
992 if (!out->WriteU32(groups[i].start_range) || | 992 if (!out->WriteU32(groups[i].start_range) || |
993 !out->WriteU32(groups[i].end_range) || | 993 !out->WriteU32(groups[i].end_range) || |
994 !out->WriteU32(groups[i].start_glyph_id)) { | 994 !out->WriteU32(groups[i].start_glyph_id)) { |
995 return OTS_FAILURE(); | 995 return OTS_FAILURE(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 out->RestoreChecksum(saved_checksum); | 1070 out->RestoreChecksum(saved_checksum); |
1071 | 1071 |
1072 return true; | 1072 return true; |
1073 } | 1073 } |
1074 | 1074 |
1075 void ots_cmap_free(OpenTypeFile *file) { | 1075 void ots_cmap_free(OpenTypeFile *file) { |
1076 delete file->cmap; | 1076 delete file->cmap; |
1077 } | 1077 } |
1078 | 1078 |
1079 } // namespace ots | 1079 } // namespace ots |
OLD | NEW |