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

Side by Side Diff: third_party/ots/src/vdmx.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/prep.cc ('k') | third_party/ots/src/vhea.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 "vdmx.h" 5 #include "vdmx.h"
6 6
7 // VDMX - Vertical Device Metrics 7 // VDMX - Vertical Device Metrics
8 // http://www.microsoft.com/typography/otspec/vdmx.htm 8 // http://www.microsoft.com/typography/otspec/vdmx.htm
9 9
10 #define TABLE_NAME "VDMX" 10 #define TABLE_NAME "VDMX"
11 11
12 #define DROP_THIS_TABLE(...) \ 12 #define DROP_THIS_TABLE(...) \
13 do { \ 13 do { \
14 OTS_FAILURE_MSG_(file, TABLE_NAME ": " __VA_ARGS__); \ 14 OTS_FAILURE_MSG_(font->file, TABLE_NAME ": " __VA_ARGS__); \
15 OTS_FAILURE_MSG("Table discarded"); \ 15 OTS_FAILURE_MSG("Table discarded"); \
16 delete file->vdmx; \ 16 delete font->vdmx; \
17 file->vdmx = 0; \ 17 font->vdmx = 0; \
18 } while (0) 18 } while (0)
19 19
20 namespace ots { 20 namespace ots {
21 21
22 bool ots_vdmx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { 22 bool ots_vdmx_parse(Font *font, const uint8_t *data, size_t length) {
23 Buffer table(data, length); 23 Buffer table(data, length);
24 file->vdmx = new OpenTypeVDMX; 24 font->vdmx = new OpenTypeVDMX;
25 OpenTypeVDMX * const vdmx = file->vdmx; 25 OpenTypeVDMX * const vdmx = font->vdmx;
26 26
27 if (!table.ReadU16(&vdmx->version) || 27 if (!table.ReadU16(&vdmx->version) ||
28 !table.ReadU16(&vdmx->num_recs) || 28 !table.ReadU16(&vdmx->num_recs) ||
29 !table.ReadU16(&vdmx->num_ratios)) { 29 !table.ReadU16(&vdmx->num_ratios)) {
30 return OTS_FAILURE_MSG("Failed to read table header"); 30 return OTS_FAILURE_MSG("Failed to read table header");
31 } 31 }
32 32
33 if (vdmx->version > 1) { 33 if (vdmx->version > 1) {
34 DROP_THIS_TABLE("bad version: %u", vdmx->version); 34 DROP_THIS_TABLE("bad version: %u", vdmx->version);
35 return true; // continue transcoding 35 return true; // continue transcoding
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 group.entries.push_back(vt); 116 group.entries.push_back(vt);
117 } 117 }
118 vdmx->groups.push_back(group); 118 vdmx->groups.push_back(group);
119 } 119 }
120 120
121 return true; 121 return true;
122 } 122 }
123 123
124 bool ots_vdmx_should_serialise(OpenTypeFile *file) { 124 bool ots_vdmx_should_serialise(Font *font) {
125 if (!file->glyf) return false; // this table is not for CFF fonts. 125 if (!font->glyf) return false; // this table is not for CFF fonts.
126 return file->vdmx != NULL; 126 return font->vdmx != NULL;
127 } 127 }
128 128
129 bool ots_vdmx_serialise(OTSStream *out, OpenTypeFile *file) { 129 bool ots_vdmx_serialise(OTSStream *out, Font *font) {
130 OpenTypeVDMX * const vdmx = file->vdmx; 130 OpenTypeVDMX * const vdmx = font->vdmx;
131 131
132 if (!out->WriteU16(vdmx->version) || 132 if (!out->WriteU16(vdmx->version) ||
133 !out->WriteU16(vdmx->num_recs) || 133 !out->WriteU16(vdmx->num_recs) ||
134 !out->WriteU16(vdmx->num_ratios)) { 134 !out->WriteU16(vdmx->num_ratios)) {
135 return OTS_FAILURE_MSG("Failed to write table header"); 135 return OTS_FAILURE_MSG("Failed to write table header");
136 } 136 }
137 137
138 for (unsigned i = 0; i < vdmx->rat_ranges.size(); ++i) { 138 for (unsigned i = 0; i < vdmx->rat_ranges.size(); ++i) {
139 const OpenTypeVDMXRatioRecord& rec = vdmx->rat_ranges[i]; 139 const OpenTypeVDMXRatioRecord& rec = vdmx->rat_ranges[i];
140 if (!out->Write(&rec.charset, 1) || 140 if (!out->Write(&rec.charset, 1) ||
(...skipping 23 matching lines...) Expand all
164 !out->WriteS16(vt.y_max) || 164 !out->WriteS16(vt.y_max) ||
165 !out->WriteS16(vt.y_min)) { 165 !out->WriteS16(vt.y_min)) {
166 return OTS_FAILURE_MSG("Failed to write group %d entry %d", i, j); 166 return OTS_FAILURE_MSG("Failed to write group %d entry %d", i, j);
167 } 167 }
168 } 168 }
169 } 169 }
170 170
171 return true; 171 return true;
172 } 172 }
173 173
174 void ots_vdmx_free(OpenTypeFile *file) { 174 void ots_vdmx_reuse(Font *font, Font *other) {
175 delete file->vdmx; 175 font->vdmx = other->vdmx;
176 font->vdmx_reused = true;
177 }
178
179 void ots_vdmx_free(Font *font) {
180 delete font->vdmx;
176 } 181 }
177 182
178 } // namespace ots 183 } // namespace ots
179 184
180 #undef TABLE_NAME 185 #undef TABLE_NAME
181 #undef DROP_THIS_TABLE 186 #undef DROP_THIS_TABLE
OLDNEW
« no previous file with comments | « third_party/ots/src/prep.cc ('k') | third_party/ots/src/vhea.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698