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 "vhea.h"
6 :
7 : #include "gsub.h"
8 : #include "head.h"
9 : #include "maxp.h"
10 :
11 : // vhea - Vertical Header Table
12 : // http://www.microsoft.com/opentype/otspec/vhea.htm
13 :
14 : namespace ots {
15 :
16 0 : bool ots_vhea_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
17 0 : Buffer table(data, length);
18 0 : OpenTypeVHEA *vhea = new OpenTypeVHEA;
19 0 : file->vhea = vhea;
20 :
21 0 : if (!table.ReadU32(&vhea->header.version)) {
22 0 : return OTS_FAILURE();
23 : }
24 0 : if (vhea->header.version != 0x00010000 &&
25 : vhea->header.version != 0x00011000) {
26 0 : return OTS_FAILURE();
27 : }
28 :
29 0 : if (!ParseMetricsHeader(file, &table, &vhea->header)) {
30 0 : return OTS_FAILURE();
31 : }
32 :
33 0 : return true;
34 : }
35 :
36 0 : bool ots_vhea_should_serialise(OpenTypeFile *file) {
37 : // vhea should'nt serialise when vmtx doesn't exist.
38 : // Firefox developer pointed out that vhea/vmtx should serialise iff GSUB is
39 : // preserved. See http://crbug.com/77386
40 : return file->vhea != NULL && file->vmtx != NULL &&
41 0 : ots_gsub_should_serialise(file);
42 : }
43 :
44 0 : bool ots_vhea_serialise(OTSStream *out, OpenTypeFile *file) {
45 0 : if (!SerialiseMetricsHeader(out, &file->vhea->header)) {
46 0 : return OTS_FAILURE();
47 : }
48 0 : return true;
49 : }
50 :
51 0 : void ots_vhea_free(OpenTypeFile *file) {
52 0 : delete file->vhea;
53 0 : }
54 :
55 : } // namespace ots
56 :
|