1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/ots/src/vmtx.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 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 "vmtx.h" 1.9 + 1.10 +#include "gsub.h" 1.11 +#include "maxp.h" 1.12 +#include "vhea.h" 1.13 + 1.14 +// vmtx - Vertical Metrics Table 1.15 +// http://www.microsoft.com/typography/otspec/vmtx.htm 1.16 + 1.17 +#define TABLE_NAME "vmtx" 1.18 + 1.19 +namespace ots { 1.20 + 1.21 +bool ots_vmtx_parse(OpenTypeFile *file, const uint8_t *data, size_t length) { 1.22 + Buffer table(data, length); 1.23 + OpenTypeVMTX *vmtx = new OpenTypeVMTX; 1.24 + file->vmtx = vmtx; 1.25 + 1.26 + if (!file->vhea || !file->maxp) { 1.27 + return OTS_FAILURE_MSG("vhea or maxp table missing as needed by vmtx"); 1.28 + } 1.29 + 1.30 + if (!ParseMetricsTable(file, &table, file->maxp->num_glyphs, 1.31 + &file->vhea->header, &vmtx->metrics)) { 1.32 + return OTS_FAILURE_MSG("Failed to parse vmtx metrics"); 1.33 + } 1.34 + 1.35 + return true; 1.36 +} 1.37 + 1.38 +bool ots_vmtx_should_serialise(OpenTypeFile *file) { 1.39 + // vmtx should serialise when vhea and GSUB are preserved. 1.40 + // See the comment in ots_vhea_should_serialise(). 1.41 + return file->vmtx != NULL && file->vhea != NULL && 1.42 + ots_gsub_should_serialise(file); 1.43 +} 1.44 + 1.45 +bool ots_vmtx_serialise(OTSStream *out, OpenTypeFile *file) { 1.46 + if (!SerialiseMetricsTable(file, out, &file->vmtx->metrics)) { 1.47 + return OTS_FAILURE_MSG("Failed to write vmtx metrics"); 1.48 + } 1.49 + return true; 1.50 +} 1.51 + 1.52 +void ots_vmtx_free(OpenTypeFile *file) { 1.53 + delete file->vmtx; 1.54 +} 1.55 + 1.56 +} // namespace ots 1.57 +