| 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 "loca.h" | 5 #include "loca.h" |
| 6 | 6 |
| 7 #include "head.h" | 7 #include "head.h" |
| 8 #include "maxp.h" | 8 #include "maxp.h" |
| 9 | 9 |
| 10 // loca - Index to Location | 10 // loca - Index to Location |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 bool ots_loca_serialise(OTSStream *out, OpenTypeFile *file) { | 69 bool ots_loca_serialise(OTSStream *out, OpenTypeFile *file) { |
| 70 const OpenTypeLOCA *loca = file->loca; | 70 const OpenTypeLOCA *loca = file->loca; |
| 71 const OpenTypeHEAD *head = file->head; | 71 const OpenTypeHEAD *head = file->head; |
| 72 | 72 |
| 73 if (!head) { | 73 if (!head) { |
| 74 return OTS_FAILURE(); | 74 return OTS_FAILURE(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 if (head->index_to_loc_format == 0) { | 77 if (head->index_to_loc_format == 0) { |
| 78 for (unsigned i = 0; i < loca->offsets.size(); ++i) { | 78 for (unsigned i = 0; i < loca->offsets.size(); ++i) { |
| 79 if (!out->WriteU16(loca->offsets[i] >> 1)) { | 79 const uint16_t offset = static_cast<uint16_t>(loca->offsets[i] >> 1); |
| 80 if ((offset != (loca->offsets[i] >> 1)) || |
| 81 !out->WriteU16(offset)) { |
| 80 return OTS_FAILURE(); | 82 return OTS_FAILURE(); |
| 81 } | 83 } |
| 82 } | 84 } |
| 83 } else { | 85 } else { |
| 84 for (unsigned i = 0; i < loca->offsets.size(); ++i) { | 86 for (unsigned i = 0; i < loca->offsets.size(); ++i) { |
| 85 if (!out->WriteU32(loca->offsets[i])) { | 87 if (!out->WriteU32(loca->offsets[i])) { |
| 86 return OTS_FAILURE(); | 88 return OTS_FAILURE(); |
| 87 } | 89 } |
| 88 } | 90 } |
| 89 } | 91 } |
| 90 | 92 |
| 91 return true; | 93 return true; |
| 92 } | 94 } |
| 93 | 95 |
| 94 void ots_loca_free(OpenTypeFile *file) { | 96 void ots_loca_free(OpenTypeFile *file) { |
| 95 delete file->loca; | 97 delete file->loca; |
| 96 } | 98 } |
| 97 | 99 |
| 98 } // namespace ots | 100 } // namespace ots |
| OLD | NEW |