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