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

Side by Side Diff: third_party/ots/src/prep.cc

Issue 775893002: Updating OTS repo from https://github.com/khaledhosny/ots.git (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating with 4800 warning fix Created 6 years 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 | « third_party/ots/src/prep.h ('k') | third_party/ots/src/vdmx.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "prep.h"
6
7 // prep - Control Value Program
8 // http://www.microsoft.com/typography/otspec/prep.htm
9
10 #define TABLE_NAME "prep"
11
12 namespace ots {
13
14 bool ots_prep_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
15 Buffer table(data, length);
16
17 OpenTypePREP *prep = new OpenTypePREP;
18 file->prep = prep;
19
20 if (length >= 128 * 1024u) {
21 return OTS_FAILURE_MSG("table length %ld > 120K", length); // almost all pr ep tables are less than 9k bytes.
22 }
23
24 if (!table.Skip(length)) {
25 return OTS_FAILURE_MSG("Failed to read table of length %ld", length);
26 }
27
28 prep->data = data;
29 prep->length = length;
30 return true;
31 }
32
33 bool ots_prep_should_serialise(OpenTypeFile *file) {
34 if (!file->glyf) return false; // this table is not for CFF fonts.
35 return file->prep != NULL;
36 }
37
38 bool ots_prep_serialise(OTSStream *out, OpenTypeFile *file) {
39 const OpenTypePREP *prep = file->prep;
40
41 if (!out->Write(prep->data, prep->length)) {
42 return OTS_FAILURE_MSG("Failed to write table length");
43 }
44
45 return true;
46 }
47
48 void ots_prep_free(OpenTypeFile *file) {
49 delete file->prep;
50 }
51
52 } // namespace ots
53
54 #undef TABLE_NAME
OLDNEW
« no previous file with comments | « third_party/ots/src/prep.h ('k') | third_party/ots/src/vdmx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698