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.

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

mercurial