1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/ots/src/vhea.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +// Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#include "vhea.h" 1.9 + 1.10 +#include "gsub.h" 1.11 +#include "head.h" 1.12 +#include "maxp.h" 1.13 + 1.14 +// vhea - Vertical Header Table 1.15 +// http://www.microsoft.com/typography/otspec/vhea.htm 1.16 + 1.17 +#define TABLE_NAME "vhea" 1.18 + 1.19 +namespace ots { 1.20 + 1.21 +bool ots_vhea_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { 1.22 + Buffer table(data, length); 1.23 + OpenTypeVHEA *vhea = new OpenTypeVHEA; 1.24 + file->vhea = vhea; 1.25 + 1.26 + if (!table.ReadU32(&vhea->header.version)) { 1.27 + return OTS_FAILURE_MSG("Failed to read version"); 1.28 + } 1.29 + if (vhea->header.version != 0x00010000 && 1.30 + vhea->header.version != 0x00011000) { 1.31 + return OTS_FAILURE_MSG("Bad vhea version %x", vhea->header.version); 1.32 + } 1.33 + 1.34 + if (!ParseMetricsHeader(file, &table, &vhea->header)) { 1.35 + return OTS_FAILURE_MSG("Failed to parse metrics in vhea"); 1.36 + } 1.37 + 1.38 + return true; 1.39 +} 1.40 + 1.41 +bool ots_vhea_should_serialise(OpenTypeFile *file) { 1.42 + // vhea should'nt serialise when vmtx doesn't exist. 1.43 + // Firefox developer pointed out that vhea/vmtx should serialise iff GSUB is 1.44 + // preserved. See http://crbug.com/77386 1.45 + return file->vhea != NULL && file->vmtx != NULL && 1.46 + ots_gsub_should_serialise(file); 1.47 +} 1.48 + 1.49 +bool ots_vhea_serialise(OTSStream *out, OpenTypeFile *file) { 1.50 + if (!SerialiseMetricsHeader(file, out, &file->vhea->header)) { 1.51 + return OTS_FAILURE_MSG("Failed to write vhea metrics"); 1.52 + } 1.53 + return true; 1.54 +} 1.55 + 1.56 +void ots_vhea_free(OpenTypeFile *file) { 1.57 + delete file->vhea; 1.58 +} 1.59 + 1.60 +} // namespace ots 1.61 +