1 : // Copyright (c) 2011 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 "vmtx.h"
6 :
7 : #include "gsub.h"
8 : #include "maxp.h"
9 : #include "vhea.h"
10 :
11 : // vmtx - Vertical Metrics Table
12 : // http://www.microsoft.com/opentype/otspec/vmtx.htm
13 :
14 : namespace ots {
15 :
16 0 : bool ots_vmtx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
17 0 : Buffer table(data, length);
18 0 : OpenTypeVMTX *vmtx = new OpenTypeVMTX;
19 0 : file->vmtx = vmtx;
20 :
21 0 : if (!file->vhea || !file->maxp) {
22 0 : return OTS_FAILURE();
23 : }
24 :
25 0 : if (!ParseMetricsTable(&table, file->maxp->num_glyphs,
26 0 : &file->vhea->header, &vmtx->metrics)) {
27 0 : return OTS_FAILURE();
28 : }
29 :
30 0 : return true;
31 : }
32 :
33 0 : bool ots_vmtx_should_serialise(OpenTypeFile *file) {
34 : // vmtx should serialise when vhea and GSUB are preserved.
35 : // See the comment in ots_vhea_should_serialise().
36 : return file->vmtx != NULL && file->vhea != NULL &&
37 0 : ots_gsub_should_serialise(file);
38 : }
39 :
40 0 : bool ots_vmtx_serialise(OTSStream *out, OpenTypeFile *file) {
41 0 : if (!SerialiseMetricsTable(out, &file->vmtx->metrics)) {
42 0 : return OTS_FAILURE();
43 : }
44 0 : return true;
45 : }
46 :
47 0 : void ots_vmtx_free(OpenTypeFile *file) {
48 0 : delete file->vmtx;
49 0 : }
50 :
51 : } // namespace ots
52 :
|