| 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 "ltsh.h" | 5 #include "ltsh.h" |
| 6 | 6 |
| 7 #include "maxp.h" | 7 #include "maxp.h" |
| 8 | 8 |
| 9 // LTSH - Linear Threshold | 9 // LTSH - Linear Threshold |
| 10 // http://www.microsoft.com/typography/otspec/ltsh.htm | 10 // http://www.microsoft.com/typography/otspec/ltsh.htm |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool ots_ltsh_should_serialise(OpenTypeFile *file) { | 57 bool ots_ltsh_should_serialise(OpenTypeFile *file) { |
| 58 if (!file->glyf) return false; // this table is not for CFF fonts. | 58 if (!file->glyf) return false; // this table is not for CFF fonts. |
| 59 return file->ltsh != NULL; | 59 return file->ltsh != NULL; |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool ots_ltsh_serialise(OTSStream *out, OpenTypeFile *file) { | 62 bool ots_ltsh_serialise(OTSStream *out, OpenTypeFile *file) { |
| 63 const OpenTypeLTSH *ltsh = file->ltsh; | 63 const OpenTypeLTSH *ltsh = file->ltsh; |
| 64 | 64 const uint16_t num_ypels = static_cast<uint16_t>(ltsh->ypels.size()); |
| 65 if (!out->WriteU16(ltsh->version) || | 65 if (num_ypels != ltsh->ypels.size() || |
| 66 !out->WriteU16(ltsh->ypels.size())) { | 66 !out->WriteU16(ltsh->version) || |
| 67 !out->WriteU16(num_ypels)) { |
| 67 return OTS_FAILURE(); | 68 return OTS_FAILURE(); |
| 68 } | 69 } |
| 69 for (unsigned i = 0; i < ltsh->ypels.size(); ++i) { | 70 for (uint16_t i = 0; i < num_ypels; ++i) { |
| 70 if (!out->Write(&(ltsh->ypels[i]), 1)) { | 71 if (!out->Write(&(ltsh->ypels[i]), 1)) { |
| 71 return OTS_FAILURE(); | 72 return OTS_FAILURE(); |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 | 75 |
| 75 return true; | 76 return true; |
| 76 } | 77 } |
| 77 | 78 |
| 78 void ots_ltsh_free(OpenTypeFile *file) { | 79 void ots_ltsh_free(OpenTypeFile *file) { |
| 79 delete file->ltsh; | 80 delete file->ltsh; |
| 80 } | 81 } |
| 81 | 82 |
| 82 } // namespace ots | 83 } // namespace ots |
| OLD | NEW |