gfx/ots/src/vmtx.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) 2011 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 "vmtx.h"
michael@0 6
michael@0 7 #include "gsub.h"
michael@0 8 #include "maxp.h"
michael@0 9 #include "vhea.h"
michael@0 10
michael@0 11 // vmtx - Vertical Metrics Table
michael@0 12 // http://www.microsoft.com/typography/otspec/vmtx.htm
michael@0 13
michael@0 14 #define TABLE_NAME "vmtx"
michael@0 15
michael@0 16 namespace ots {
michael@0 17
michael@0 18 bool ots_vmtx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
michael@0 19 Buffer table(data, length);
michael@0 20 OpenTypeVMTX *vmtx = new OpenTypeVMTX;
michael@0 21 file->vmtx = vmtx;
michael@0 22
michael@0 23 if (!file->vhea || !file->maxp) {
michael@0 24 return OTS_FAILURE_MSG("vhea or maxp table missing as needed by vmtx");
michael@0 25 }
michael@0 26
michael@0 27 if (!ParseMetricsTable(file, &table, file->maxp->num_glyphs,
michael@0 28 &file->vhea->header, &vmtx->metrics)) {
michael@0 29 return OTS_FAILURE_MSG("Failed to parse vmtx metrics");
michael@0 30 }
michael@0 31
michael@0 32 return true;
michael@0 33 }
michael@0 34
michael@0 35 bool ots_vmtx_should_serialise(OpenTypeFile *file) {
michael@0 36 // vmtx should serialise when vhea and GSUB are preserved.
michael@0 37 // See the comment in ots_vhea_should_serialise().
michael@0 38 return file->vmtx != NULL && file->vhea != NULL &&
michael@0 39 ots_gsub_should_serialise(file);
michael@0 40 }
michael@0 41
michael@0 42 bool ots_vmtx_serialise(OTSStream *out, OpenTypeFile *file) {
michael@0 43 if (!SerialiseMetricsTable(file, out, &file->vmtx->metrics)) {
michael@0 44 return OTS_FAILURE_MSG("Failed to write vmtx metrics");
michael@0 45 }
michael@0 46 return true;
michael@0 47 }
michael@0 48
michael@0 49 void ots_vmtx_free(OpenTypeFile *file) {
michael@0 50 delete file->vmtx;
michael@0 51 }
michael@0 52
michael@0 53 } // namespace ots
michael@0 54

mercurial