Update V8 to version 4.7.44.
[chromium-blink-merge.git] / third_party / ots / src / hhea.cc
blob6242872802ae044a8574e993776de28c8ec960b2
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.
5 #include "hhea.h"
7 #include "head.h"
8 #include "maxp.h"
10 // hhea - Horizontal Header
11 // http://www.microsoft.com/typography/otspec/hhea.htm
13 #define TABLE_NAME "hhea"
15 namespace ots {
17 bool ots_hhea_parse(Font *font, const uint8_t *data, size_t length) {
18 Buffer table(data, length);
19 OpenTypeHHEA *hhea = new OpenTypeHHEA;
20 font->hhea = hhea;
22 if (!table.ReadU32(&hhea->header.version)) {
23 return OTS_FAILURE_MSG("Failed to read hhea version");
25 if (hhea->header.version >> 16 != 1) {
26 return OTS_FAILURE_MSG("Bad hhea version of %d", hhea->header.version);
29 if (!ParseMetricsHeader(font, &table, &hhea->header)) {
30 return OTS_FAILURE_MSG("Failed to parse horizontal metrics");
33 return true;
36 bool ots_hhea_should_serialise(Font *font) {
37 return font->hhea != NULL;
40 bool ots_hhea_serialise(OTSStream *out, Font *font) {
41 if (!SerialiseMetricsHeader(font, out, &font->hhea->header)) {
42 return OTS_FAILURE_MSG("Failed to serialise horizontal metrics");
44 return true;
47 void ots_hhea_reuse(Font *font, Font *other) {
48 font->hhea = other->hhea;
49 font->hhea_reused = true;
52 void ots_hhea_free(Font *font) {
53 delete font->hhea;
56 } // namespace ots
58 #undef TABLE_NAME