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 "hhea.h"
6 :
7 : #include "head.h"
8 : #include "maxp.h"
9 :
10 : // hhea - Horizontal Header
11 : // http://www.microsoft.com/opentype/otspec/hhea.htm
12 :
13 : namespace ots {
14 :
15 0 : bool ots_hhea_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
16 0 : Buffer table(data, length);
17 0 : OpenTypeHHEA *hhea = new OpenTypeHHEA;
18 0 : file->hhea = hhea;
19 :
20 0 : if (!table.ReadU32(&hhea->header.version)) {
21 0 : return OTS_FAILURE();
22 : }
23 0 : if (hhea->header.version >> 16 != 1) {
24 0 : return OTS_FAILURE();
25 : }
26 :
27 0 : if (!ParseMetricsHeader(file, &table, &hhea->header)) {
28 0 : return OTS_FAILURE();
29 : }
30 :
31 0 : return true;
32 : }
33 :
34 0 : bool ots_hhea_should_serialise(OpenTypeFile *file) {
35 0 : return file->hhea != NULL;
36 : }
37 :
38 0 : bool ots_hhea_serialise(OTSStream *out, OpenTypeFile *file) {
39 0 : if (!SerialiseMetricsHeader(out, &file->hhea->header)) {
40 0 : return OTS_FAILURE();
41 : }
42 0 : return true;
43 : }
44 :
45 0 : void ots_hhea_free(OpenTypeFile *file) {
46 0 : delete file->hhea;
47 0 : }
48 :
49 : } // namespace ots
|