| 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(); | |
| 1030 | 1026 |
| 1031 // Now seek back and write the table of offsets | 1027 // Now seek back and write the table of offsets |
| 1032 if (!out->Seek(record_offset)) { | 1028 if (!out->Seek(record_offset)) { |
| 1033 return OTS_FAILURE(); | 1029 return OTS_FAILURE(); |
| 1034 } | 1030 } |
| 1035 | 1031 |
| 1036 if (have_034) { | 1032 if (have_034) { |
| 1037 if (!out->WriteU16(0) || | 1033 if (!out->WriteU16(0) || |
| 1038 !out->WriteU16(3) || | 1034 !out->WriteU16(3) || |
| 1039 !out->WriteU32(offset_034 - table_start)) { | 1035 !out->WriteU32(offset_034 - table_start)) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 if (!out->WriteU16(3) || | 1081 if (!out->WriteU16(3) || |
| 1086 !out->WriteU16(10) || | 1082 !out->WriteU16(10) || |
| 1087 !out->WriteU32(offset_31013 - table_start)) { | 1083 !out->WriteU32(offset_31013 - table_start)) { |
| 1088 return OTS_FAILURE(); | 1084 return OTS_FAILURE(); |
| 1089 } | 1085 } |
| 1090 } | 1086 } |
| 1091 | 1087 |
| 1092 if (!out->Seek(table_end)) { | 1088 if (!out->Seek(table_end)) { |
| 1093 return OTS_FAILURE(); | 1089 return OTS_FAILURE(); |
| 1094 } | 1090 } |
| 1095 out->RestoreChecksum(saved_checksum); | |
| 1096 | 1091 |
| 1097 return true; | 1092 return true; |
| 1098 } | 1093 } |
| 1099 | 1094 |
| 1100 void ots_cmap_free(OpenTypeFile *file) { | 1095 void ots_cmap_free(OpenTypeFile *file) { |
| 1101 delete file->cmap; | 1096 delete file->cmap; |
| 1102 } | 1097 } |
| 1103 | 1098 |
| 1104 } // namespace ots | 1099 } // namespace ots |
| 1105 | 1100 |
| 1106 #undef TABLE_NAME | 1101 #undef TABLE_NAME |
| OLD | NEW |