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.
11 // vhea - Vertical Header Table
12 // http://www.microsoft.com/typography/otspec/vhea.htm
14 #define TABLE_NAME "vhea"
18 bool ots_vhea_parse(Font
*font
, const uint8_t *data
, size_t length
) {
19 Buffer
table(data
, length
);
20 OpenTypeVHEA
*vhea
= new OpenTypeVHEA
;
23 if (!table
.ReadU32(&vhea
->header
.version
)) {
24 return OTS_FAILURE_MSG("Failed to read version");
26 if (vhea
->header
.version
!= 0x00010000 &&
27 vhea
->header
.version
!= 0x00011000) {
28 return OTS_FAILURE_MSG("Bad vhea version %x", vhea
->header
.version
);
31 if (!ParseMetricsHeader(font
, &table
, &vhea
->header
)) {
32 return OTS_FAILURE_MSG("Failed to parse metrics in vhea");
38 bool ots_vhea_should_serialise(Font
*font
) {
39 // vhea should'nt serialise when vmtx doesn't exist.
40 // Firefox developer pointed out that vhea/vmtx should serialise iff GSUB is
41 // preserved. See http://crbug.com/77386
42 return font
->vhea
!= NULL
&& font
->vmtx
!= NULL
&&
43 ots_gsub_should_serialise(font
);
46 bool ots_vhea_serialise(OTSStream
*out
, Font
*font
) {
47 if (!SerialiseMetricsHeader(font
, out
, &font
->vhea
->header
)) {
48 return OTS_FAILURE_MSG("Failed to write vhea metrics");
53 void ots_vhea_reuse(Font
*font
, Font
*other
) {
54 font
->vhea
= other
->vhea
;
55 font
->vhea_reused
= true;
58 void ots_vhea_free(Font
*font
) {