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 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 for (unsigned i = 0; i < num_groups; ++i) { | 1016 for (unsigned i = 0; i < num_groups; ++i) { |
1017 if (!out->WriteU32(groups[i].start_range) || | 1017 if (!out->WriteU32(groups[i].start_range) || |
1018 !out->WriteU32(groups[i].end_range) || | 1018 !out->WriteU32(groups[i].end_range) || |
1019 !out->WriteU32(groups[i].start_glyph_id)) { | 1019 !out->WriteU32(groups[i].start_glyph_id)) { |
1020 return OTS_FAILURE(); | 1020 return OTS_FAILURE(); |
1021 } | 1021 } |
1022 } | 1022 } |
1023 } | 1023 } |
1024 | 1024 |
1025 const off_t table_end = out->Tell(); | 1025 const off_t table_end = out->Tell(); |
| 1026 // We might have hanging bytes from the above's checksum which the OTSStream |
| 1027 // then merges into the table of offsets. |
| 1028 OTSStream::ChecksumState saved_checksum = out->SaveChecksumState(); |
| 1029 out->ResetChecksum(); |
1026 | 1030 |
1027 // Now seek back and write the table of offsets | 1031 // Now seek back and write the table of offsets |
1028 if (!out->Seek(record_offset)) { | 1032 if (!out->Seek(record_offset)) { |
1029 return OTS_FAILURE(); | 1033 return OTS_FAILURE(); |
1030 } | 1034 } |
1031 | 1035 |
1032 if (have_034) { | 1036 if (have_034) { |
1033 if (!out->WriteU16(0) || | 1037 if (!out->WriteU16(0) || |
1034 !out->WriteU16(3) || | 1038 !out->WriteU16(3) || |
1035 !out->WriteU32(offset_034 - table_start)) { | 1039 !out->WriteU32(offset_034 - table_start)) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 if (!out->WriteU16(3) || | 1085 if (!out->WriteU16(3) || |
1082 !out->WriteU16(10) || | 1086 !out->WriteU16(10) || |
1083 !out->WriteU32(offset_31013 - table_start)) { | 1087 !out->WriteU32(offset_31013 - table_start)) { |
1084 return OTS_FAILURE(); | 1088 return OTS_FAILURE(); |
1085 } | 1089 } |
1086 } | 1090 } |
1087 | 1091 |
1088 if (!out->Seek(table_end)) { | 1092 if (!out->Seek(table_end)) { |
1089 return OTS_FAILURE(); | 1093 return OTS_FAILURE(); |
1090 } | 1094 } |
| 1095 out->RestoreChecksum(saved_checksum); |
1091 | 1096 |
1092 return true; | 1097 return true; |
1093 } | 1098 } |
1094 | 1099 |
1095 void ots_cmap_free(OpenTypeFile *file) { | 1100 void ots_cmap_free(OpenTypeFile *file) { |
1096 delete file->cmap; | 1101 delete file->cmap; |
1097 } | 1102 } |
1098 | 1103 |
1099 } // namespace ots | 1104 } // namespace ots |
1100 | 1105 |
1101 #undef TABLE_NAME | 1106 #undef TABLE_NAME |
OLD | NEW |