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

Side by Side Diff: src/prep.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/post.cc ('k') | src/vdmx.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 "prep.h" 5 #include "prep.h"
6 6
7 // prep - Control Value Program 7 // prep - Control Value Program
8 // http://www.microsoft.com/opentype/otspec/prep.htm 8 // http://www.microsoft.com/typography/otspec/prep.htm
9
10 #define TABLE_NAME "prep"
9 11
10 namespace ots { 12 namespace ots {
11 13
12 bool ots_prep_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { 14 bool ots_prep_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
13 Buffer table(data, length); 15 Buffer table(data, length);
14 16
15 OpenTypePREP *prep = new OpenTypePREP; 17 OpenTypePREP *prep = new OpenTypePREP;
16 file->prep = prep; 18 file->prep = prep;
17 19
18 if (length >= 128 * 1024u) { 20 if (length >= 128 * 1024u) {
19 return OTS_FAILURE(); // almost all prep tables are less than 9k bytes. 21 return OTS_FAILURE_MSG("table length %ld > 120K", length); // almost all pr ep tables are less than 9k bytes.
20 } 22 }
21 23
22 if (!table.Skip(length)) { 24 if (!table.Skip(length)) {
23 return OTS_FAILURE(); 25 return OTS_FAILURE_MSG("Failed to read table of length %ld", length);
24 } 26 }
25 27
26 prep->data = data; 28 prep->data = data;
27 prep->length = length; 29 prep->length = length;
28 return true; 30 return true;
29 } 31 }
30 32
31 bool ots_prep_should_serialise(OpenTypeFile *file) { 33 bool ots_prep_should_serialise(OpenTypeFile *file) {
32 if (!file->glyf) return false; // this table is not for CFF fonts. 34 if (!file->glyf) return false; // this table is not for CFF fonts.
33 return g_transcode_hints && file->prep; 35 return file->prep;
34 } 36 }
35 37
36 bool ots_prep_serialise(OTSStream *out, OpenTypeFile *file) { 38 bool ots_prep_serialise(OTSStream *out, OpenTypeFile *file) {
37 const OpenTypePREP *prep = file->prep; 39 const OpenTypePREP *prep = file->prep;
38 40
39 if (!out->Write(prep->data, prep->length)) { 41 if (!out->Write(prep->data, prep->length)) {
40 return OTS_FAILURE(); 42 return OTS_FAILURE_MSG("Failed to write table length");
41 } 43 }
42 44
43 return true; 45 return true;
44 } 46 }
45 47
46 void ots_prep_free(OpenTypeFile *file) { 48 void ots_prep_free(OpenTypeFile *file) {
47 delete file->prep; 49 delete file->prep;
48 } 50 }
49 51
50 } // namespace ots 52 } // namespace ots
53
54 #undef TABLE_NAME
OLDNEW
« .gitmodules ('K') | « src/post.cc ('k') | src/vdmx.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698