Coverage Report

Created: 2026-06-16 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ots/src/prep.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 "prep.h"
6
7
// prep - Control Value Program
8
// http://www.microsoft.com/typography/otspec/prep.htm
9
10
namespace ots {
11
12
4.92k
bool OpenTypePREP::Parse(const uint8_t *data, size_t length) {
13
4.92k
  Buffer table(data, length);
14
15
4.92k
  if (length >= 128 * 1024u) {
16
    // almost all prep tables are less than 9k bytes.
17
0
    return Error("Table length %ld > 120K", length);
18
0
  }
19
20
4.92k
  if (!table.Skip(length)) {
21
0
    return Error("Failed to read table of length %ld", length);
22
0
  }
23
24
4.92k
  this->m_data = data;
25
4.92k
  this->m_length = length;
26
4.92k
  return true;
27
4.92k
}
28
29
1.97k
bool OpenTypePREP::Serialize(OTSStream *out) {
30
1.97k
  if (!out->Write(this->m_data, this->m_length)) {
31
0
    return Error("Failed to write table length");
32
0
  }
33
34
1.97k
  return true;
35
1.97k
}
36
37
13.1k
bool OpenTypePREP::ShouldSerialize() {
38
13.1k
  return Table::ShouldSerialize() &&
39
         // this table is not for CFF fonts.
40
13.1k
         GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
41
13.1k
}
42
43
}  // namespace ots