| 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 "gasp.h" | 5 #include "gasp.h" |
| 6 | 6 |
| 7 // gasp - Grid-fitting And Scan-conversion Procedure | 7 // gasp - Grid-fitting And Scan-conversion Procedure |
| 8 // http://www.microsoft.com/opentype/otspec/gasp.htm | 8 // http://www.microsoft.com/opentype/otspec/gasp.htm |
| 9 | 9 |
| 10 #define DROP_THIS_TABLE \ | 10 #define DROP_THIS_TABLE \ |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool ots_gasp_should_serialise(OpenTypeFile *file) { | 80 bool ots_gasp_should_serialise(OpenTypeFile *file) { |
| 81 return file->gasp != NULL; | 81 return file->gasp != NULL; |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool ots_gasp_serialise(OTSStream *out, OpenTypeFile *file) { | 84 bool ots_gasp_serialise(OTSStream *out, OpenTypeFile *file) { |
| 85 const OpenTypeGASP *gasp = file->gasp; | 85 const OpenTypeGASP *gasp = file->gasp; |
| 86 | 86 |
| 87 if (!out->WriteU16(gasp->version) || | 87 const uint16_t num_ranges = static_cast<uint16_t>(gasp->gasp_ranges.size()); |
| 88 !out->WriteU16(gasp->gasp_ranges.size())) { | 88 if (num_ranges != gasp->gasp_ranges.size() || |
| 89 !out->WriteU16(gasp->version) || |
| 90 !out->WriteU16(num_ranges)) { |
| 89 return OTS_FAILURE(); | 91 return OTS_FAILURE(); |
| 90 } | 92 } |
| 91 | 93 |
| 92 for (unsigned i = 0; i < gasp->gasp_ranges.size(); ++i) { | 94 for (uint16_t i = 0; i < num_ranges; ++i) { |
| 93 if (!out->WriteU16(gasp->gasp_ranges[i].first) || | 95 if (!out->WriteU16(gasp->gasp_ranges[i].first) || |
| 94 !out->WriteU16(gasp->gasp_ranges[i].second)) { | 96 !out->WriteU16(gasp->gasp_ranges[i].second)) { |
| 95 return OTS_FAILURE(); | 97 return OTS_FAILURE(); |
| 96 } | 98 } |
| 97 } | 99 } |
| 98 | 100 |
| 99 return true; | 101 return true; |
| 100 } | 102 } |
| 101 | 103 |
| 102 void ots_gasp_free(OpenTypeFile *file) { | 104 void ots_gasp_free(OpenTypeFile *file) { |
| 103 delete file->gasp; | 105 delete file->gasp; |
| 104 } | 106 } |
| 105 | 107 |
| 106 } // namespace ots | 108 } // namespace ots |
| OLD | NEW |