Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: src/ltsh.cc

Issue 512923003: Fix MSVC warnings about possible value truncation. (Closed) Base URL: https://chromium.googlesource.com/external/ots.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/loca.cc ('k') | src/name.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « src/loca.cc ('k') | src/name.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698