Line data Source code
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 "head.h"
8 : #include "maxp.h"
9 :
10 : // vhea - Vertical Header Table
11 : // http://www.microsoft.com/typography/otspec/vhea.htm
12 :
13 : #define TABLE_NAME "vhea"
14 :
15 : namespace ots {
16 :
17 0 : bool ots_vhea_parse(Font *font, const uint8_t *data, size_t length) {
18 0 : Buffer table(data, length);
19 0 : OpenTypeVHEA *vhea = new OpenTypeVHEA;
20 0 : font->vhea = vhea;
21 :
22 0 : if (!table.ReadU32(&vhea->header.version)) {
23 0 : return OTS_FAILURE_MSG("Failed to read version");
24 : }
25 0 : if (vhea->header.version != 0x00010000 &&
26 0 : vhea->header.version != 0x00011000) {
27 0 : return OTS_FAILURE_MSG("Bad vhea version %x", vhea->header.version);
28 : }
29 :
30 0 : if (!ParseMetricsHeader(font, &table, &vhea->header)) {
31 0 : return OTS_FAILURE_MSG("Failed to parse metrics in vhea");
32 : }
33 :
34 0 : return true;
35 : }
36 :
37 0 : bool ots_vhea_should_serialise(Font *font) {
38 : // vhea should'nt serialise when vmtx doesn't exist.
39 0 : return font->vhea != NULL && font->vmtx != NULL;
40 : }
41 :
42 0 : bool ots_vhea_serialise(OTSStream *out, Font *font) {
43 0 : if (!SerialiseMetricsHeader(font, out, &font->vhea->header)) {
44 0 : return OTS_FAILURE_MSG("Failed to write vhea metrics");
45 : }
46 0 : return true;
47 : }
48 :
49 0 : void ots_vhea_reuse(Font *font, Font *other) {
50 0 : font->vhea = other->vhea;
51 0 : font->vhea_reused = true;
52 0 : }
53 :
54 0 : void ots_vhea_free(Font *font) {
55 0 : delete font->vhea;
56 0 : }
57 :
58 : } // namespace ots
59 :
60 : #undef TABLE_NAME
|