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

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

Issue 1252363005: Update OTS to revision a7a3b94 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « third_party/ots/src/cvt.cc ('k') | third_party/ots/src/gasp.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 "fpgm.h" 5 #include "fpgm.h"
6 6
7 // fpgm - Font Program 7 // fpgm - Font Program
8 // http://www.microsoft.com/typography/otspec/fpgm.htm 8 // http://www.microsoft.com/typography/otspec/fpgm.htm
9 9
10 #define TABLE_NAME "fpgm" 10 #define TABLE_NAME "fpgm"
11 11
12 namespace ots { 12 namespace ots {
13 13
14 bool ots_fpgm_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { 14 bool ots_fpgm_parse(Font *font, const uint8_t *data, size_t length) {
15 Buffer table(data, length); 15 Buffer table(data, length);
16 16
17 OpenTypeFPGM *fpgm = new OpenTypeFPGM; 17 OpenTypeFPGM *fpgm = new OpenTypeFPGM;
18 file->fpgm = fpgm; 18 font->fpgm = fpgm;
19 19
20 if (length >= 128 * 1024u) { 20 if (length >= 128 * 1024u) {
21 return OTS_FAILURE_MSG("length (%ld) > 120", length); // almost all fpgm ta bles are less than 5k bytes. 21 return OTS_FAILURE_MSG("length (%ld) > 120", length); // almost all fpgm ta bles are less than 5k bytes.
22 } 22 }
23 23
24 if (!table.Skip(length)) { 24 if (!table.Skip(length)) {
25 return OTS_FAILURE_MSG("Bad fpgm length"); 25 return OTS_FAILURE_MSG("Bad fpgm length");
26 } 26 }
27 27
28 fpgm->data = data; 28 fpgm->data = data;
29 fpgm->length = length; 29 fpgm->length = length;
30 return true; 30 return true;
31 } 31 }
32 32
33 bool ots_fpgm_should_serialise(OpenTypeFile *file) { 33 bool ots_fpgm_should_serialise(Font *font) {
34 if (!file->glyf) return false; // this table is not for CFF fonts. 34 if (!font->glyf) return false; // this table is not for CFF fonts.
35 return file->fpgm != NULL; 35 return font->fpgm != NULL;
36 } 36 }
37 37
38 bool ots_fpgm_serialise(OTSStream *out, OpenTypeFile *file) { 38 bool ots_fpgm_serialise(OTSStream *out, Font *font) {
39 const OpenTypeFPGM *fpgm = file->fpgm; 39 const OpenTypeFPGM *fpgm = font->fpgm;
40 40
41 if (!out->Write(fpgm->data, fpgm->length)) { 41 if (!out->Write(fpgm->data, fpgm->length)) {
42 return OTS_FAILURE_MSG("Failed to write fpgm"); 42 return OTS_FAILURE_MSG("Failed to write fpgm");
43 } 43 }
44 44
45 return true; 45 return true;
46 } 46 }
47 47
48 void ots_fpgm_free(OpenTypeFile *file) { 48 void ots_fpgm_reuse(Font *font, Font *other) {
49 delete file->fpgm; 49 font->fpgm = other->fpgm;
50 font->fpgm_reused = true;
51 }
52
53 void ots_fpgm_free(Font *font) {
54 delete font->fpgm;
50 } 55 }
51 56
52 } // namespace ots 57 } // namespace ots
53 58
54 #undef TABLE_NAME 59 #undef TABLE_NAME
OLDNEW
« no previous file with comments | « third_party/ots/src/cvt.cc ('k') | third_party/ots/src/gasp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698