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

Side by Side Diff: src/cvt.cc

Issue 658573004: Updating to new OTS repo from https://github.com/khaledhosny/ots.git (Closed) Base URL: https://chromium.googlesource.com/external/ots@master
Patch Set: Adding Colored Emoji changes from external/git repo Created 6 years, 2 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
« .gitmodules ('K') | « src/cmap.cc ('k') | src/fpgm.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 "cvt.h" 5 #include "cvt.h"
6 6
7 // cvt - Control Value Table 7 // cvt - Control Value Table
8 // http://www.microsoft.com/opentype/otspec/cvt.htm 8 // http://www.microsoft.com/typography/otspec/cvt.htm
9
10 #define TABLE_NAME "cvt"
9 11
10 namespace ots { 12 namespace ots {
11 13
12 bool ots_cvt_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { 14 bool ots_cvt_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
13 Buffer table(data, length); 15 Buffer table(data, length);
14 16
15 OpenTypeCVT *cvt = new OpenTypeCVT; 17 OpenTypeCVT *cvt = new OpenTypeCVT;
16 file->cvt = cvt; 18 file->cvt = cvt;
17 19
18 if (length >= 128 * 1024u) { 20 if (length >= 128 * 1024u) {
19 return OTS_FAILURE(); // almost all cvt tables are less than 4k bytes. 21 return OTS_FAILURE_MSG("Length (%d) > 120K"); // almost all cvt tables are less than 4k bytes.
20 } 22 }
21 23
22 if (length % 2 != 0) { 24 if (length % 2 != 0) {
23 return OTS_FAILURE(); 25 return OTS_FAILURE_MSG("Uneven cvt length (%d)", length);
24 } 26 }
25 27
26 if (!table.Skip(length)) { 28 if (!table.Skip(length)) {
27 return OTS_FAILURE(); 29 return OTS_FAILURE_MSG("Length too high");
28 } 30 }
29 31
30 cvt->data = data; 32 cvt->data = data;
31 cvt->length = length; 33 cvt->length = length;
32 return true; 34 return true;
33 } 35 }
34 36
35 bool ots_cvt_should_serialise(OpenTypeFile *file) { 37 bool ots_cvt_should_serialise(OpenTypeFile *file) {
36 if (!file->glyf) { 38 if (!file->glyf) {
37 return false; // this table is not for CFF fonts. 39 return false; // this table is not for CFF fonts.
38 } 40 }
39 return g_transcode_hints && file->cvt; 41 return file->cvt;
40 } 42 }
41 43
42 bool ots_cvt_serialise(OTSStream *out, OpenTypeFile *file) { 44 bool ots_cvt_serialise(OTSStream *out, OpenTypeFile *file) {
43 const OpenTypeCVT *cvt = file->cvt; 45 const OpenTypeCVT *cvt = file->cvt;
44 46
45 if (!out->Write(cvt->data, cvt->length)) { 47 if (!out->Write(cvt->data, cvt->length)) {
46 return OTS_FAILURE(); 48 return OTS_FAILURE_MSG("Failed to write CVT table");
47 } 49 }
48 50
49 return true; 51 return true;
50 } 52 }
51 53
52 void ots_cvt_free(OpenTypeFile *file) { 54 void ots_cvt_free(OpenTypeFile *file) {
53 delete file->cvt; 55 delete file->cvt;
54 } 56 }
55 57
56 } // namespace ots 58 } // namespace ots
59
60 #undef TABLE_NAME
OLDNEW
« .gitmodules ('K') | « src/cmap.cc ('k') | src/fpgm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698