Coverage Report

Created: 2026-06-16 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ots/src/cvt.cc
Line
Count
Source
1
// Copyright (c) 2009-2017 The OTS 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 "cvt.h"
6
7
// cvt - Control Value Table
8
// http://www.microsoft.com/typography/otspec/cvt.htm
9
10
namespace ots {
11
12
944
bool OpenTypeCVT::Parse(const uint8_t *data, size_t length) {
13
944
  Buffer table(data, length);
14
15
944
  if (length >= 128 * 1024u) {
16
0
    return Error("Length (%d) > 120K");  // almost all cvt tables are less than 4k bytes.
17
0
  }
18
19
944
  if (length % 2 != 0) {
20
10
    return Error("Uneven table length (%d)", length);
21
10
  }
22
23
934
  if (!table.Skip(length)) {
24
0
    return Error("Table length too high");
25
0
  }
26
27
934
  this->data = data;
28
934
  this->length = length;
29
934
  return true;
30
934
}
31
32
809
bool OpenTypeCVT::Serialize(OTSStream *out) {
33
809
  if (!out->Write(this->data, this->length)) {
34
0
    return Error("Failed to write cvt table");
35
0
  }
36
37
809
  return true;
38
809
}
39
40
3.77k
bool OpenTypeCVT::ShouldSerialize() {
41
3.77k
  return Table::ShouldSerialize() &&
42
         // this table is not for CFF fonts.
43
3.77k
         GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
44
3.77k
}
45
46
}  // namespace ots