gfx/ots/src/hhea.cc

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #include "hhea.h"
michael@0 6
michael@0 7 #include "head.h"
michael@0 8 #include "maxp.h"
michael@0 9
michael@0 10 // hhea - Horizontal Header
michael@0 11 // http://www.microsoft.com/typography/otspec/hhea.htm
michael@0 12
michael@0 13 #define TABLE_NAME "hhea"
michael@0 14
michael@0 15 namespace ots {
michael@0 16
michael@0 17 bool ots_hhea_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
michael@0 18 Buffer table(data, length);
michael@0 19 OpenTypeHHEA *hhea = new OpenTypeHHEA;
michael@0 20 file->hhea = hhea;
michael@0 21
michael@0 22 if (!table.ReadU32(&hhea->header.version)) {
michael@0 23 return OTS_FAILURE_MSG("Failed to read hhea version");
michael@0 24 }
michael@0 25 if (hhea->header.version >> 16 != 1) {
michael@0 26 return OTS_FAILURE_MSG("Bad hhea version of %d", hhea->header.version);
michael@0 27 }
michael@0 28
michael@0 29 if (!ParseMetricsHeader(file, &table, &hhea->header)) {
michael@0 30 return OTS_FAILURE_MSG("Failed to parse horizontal metrics");
michael@0 31 }
michael@0 32
michael@0 33 return true;
michael@0 34 }
michael@0 35
michael@0 36 bool ots_hhea_should_serialise(OpenTypeFile *file) {
michael@0 37 return file->hhea != NULL;
michael@0 38 }
michael@0 39
michael@0 40 bool ots_hhea_serialise(OTSStream *out, OpenTypeFile *file) {
michael@0 41 if (!SerialiseMetricsHeader(file, out, &file->hhea->header)) {
michael@0 42 return OTS_FAILURE_MSG("Failed to serialise horizontal metrics");
michael@0 43 }
michael@0 44 return true;
michael@0 45 }
michael@0 46
michael@0 47 void ots_hhea_free(OpenTypeFile *file) {
michael@0 48 delete file->hhea;
michael@0 49 }
michael@0 50
michael@0 51 } // namespace ots

mercurial