Coverage Report

Created: 2025-12-05 06:40

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