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 13namespace ots { 14 15bool ots_hhea_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { 16 Buffer table(data, length); 17 OpenTypeHHEA *hhea = new OpenTypeHHEA; 18 file->hhea = hhea; 19 20 if (!table.ReadU32(&hhea->header.version)) { 21 return OTS_FAILURE(); 22 } 23 if (hhea->header.version >> 16 != 1) { 24 return OTS_FAILURE(); 25 } 26 27 if (!ParseMetricsHeader(file, &table, &hhea->header)) { 28 return OTS_FAILURE(); 29 } 30 31 return true; 32} 33 34bool ots_hhea_should_serialise(OpenTypeFile *file) { 35 return file->hhea != NULL; 36} 37 38bool ots_hhea_serialise(OTSStream *out, OpenTypeFile *file) { 39 if (!SerialiseMetricsHeader(out, &file->hhea->header)) { 40 return OTS_FAILURE(); 41 } 42 return true; 43} 44 45void ots_hhea_free(OpenTypeFile *file) { 46 delete file->hhea; 47} 48 49} // namespace ots 50