Coverage Report

Created: 2025-11-16 06:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/harfbuzz/src/hb-ot-cff-common.hh
Line
Count
Source
1
/*
2
 * Copyright © 2018 Adobe Inc.
3
 *
4
 *  This is part of HarfBuzz, a text shaping library.
5
 *
6
 * Permission is hereby granted, without written agreement and without
7
 * license or royalty fees, to use, copy, modify, and distribute this
8
 * software and its documentation for any purpose, provided that the
9
 * above copyright notice and the following two paragraphs appear in
10
 * all copies of this software.
11
 *
12
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16
 * DAMAGE.
17
 *
18
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23
 *
24
 * Adobe Author(s): Michiharu Ariza
25
 */
26
#ifndef HB_OT_CFF_COMMON_HH
27
#define HB_OT_CFF_COMMON_HH
28
29
#include "hb-open-type.hh"
30
#include "hb-bimap.hh"
31
#include "hb-ot-layout-common.hh"
32
#include "hb-cff-interp-dict-common.hh"
33
#include "hb-subset-plan.hh"
34
35
namespace CFF {
36
37
using namespace OT;
38
39
548k
#define CFF_UNDEF_CODE  0xFFFFFFFF
40
41
using objidx_t = hb_serialize_context_t::objidx_t;
42
using whence_t = hb_serialize_context_t::whence_t;
43
44
/* CFF offsets can technically be negative */
45
template<typename Type, typename ...Ts>
46
static inline const Type& StructAtOffsetOrNull (const void *P, int offset, hb_sanitize_context_t &sc, Ts&&... ds)
47
96.0k
{
48
96.0k
  if (!offset) return Null (Type);
49
50
60.7k
  const char *p = (const char *) P + offset;
51
60.7k
  if (!sc.check_point (p)) return Null (Type);
52
53
58.8k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
58.8k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
54.0k
  return obj;
57
58.8k
}
Unexecuted instantiation: hb-ot-face.cc:OT::CFFIndex<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:CFF::Charset const& CFF::StructAtOffsetOrNull<CFF::Charset, unsigned int*>(void const*, int, hb_sanitize_context_t&, unsigned int*&&)
Unexecuted instantiation: hb-ot-face.cc:CFF::CFF1FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF1FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:CFF::CFF1FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF1FDSelect, OT::NumType<true, unsigned short, 2u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned short, 2u> const&)
Unexecuted instantiation: hb-ot-face.cc:CFF::Encoding const& CFF::StructAtOffsetOrNull<CFF::Encoding>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:CFF::CFF1StringIndex const& CFF::StructAtOffsetOrNull<CFF::CFF1StringIndex>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:CFF::Subrs<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Unexecuted instantiation: hb-ot-face.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-face.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Unexecuted instantiation: hb-ot-font.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-font.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-font.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-font.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-font.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Unexecuted instantiation: hb-ot-font.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Unexecuted instantiation: hb-ot-font.cc:OT::CFFIndex<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-font.cc:CFF::Charset const& CFF::StructAtOffsetOrNull<CFF::Charset, unsigned int*>(void const*, int, hb_sanitize_context_t&, unsigned int*&&)
Unexecuted instantiation: hb-ot-font.cc:CFF::CFF1FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF1FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-font.cc:CFF::CFF1FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF1FDSelect, OT::NumType<true, unsigned short, 2u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned short, 2u> const&)
Unexecuted instantiation: hb-ot-font.cc:CFF::Encoding const& CFF::StructAtOffsetOrNull<CFF::Encoding>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-font.cc:CFF::CFF1StringIndex const& CFF::StructAtOffsetOrNull<CFF::CFF1StringIndex>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-font.cc:CFF::Subrs<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Unexecuted instantiation: VARC.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Unexecuted instantiation: VARC.cc:OT::CFFIndex<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:CFF::Charset const& CFF::StructAtOffsetOrNull<CFF::Charset, unsigned int*>(void const*, int, hb_sanitize_context_t&, unsigned int*&&)
Unexecuted instantiation: VARC.cc:CFF::CFF1FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF1FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:CFF::CFF1FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF1FDSelect, OT::NumType<true, unsigned short, 2u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned short, 2u> const&)
Unexecuted instantiation: VARC.cc:CFF::Encoding const& CFF::StructAtOffsetOrNull<CFF::Encoding>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:CFF::CFF1StringIndex const& CFF::StructAtOffsetOrNull<CFF::CFF1StringIndex>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: VARC.cc:CFF::Subrs<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff1-table.cc:OT::CFFIndex<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff1-table.cc:CFF::Charset const& CFF::StructAtOffsetOrNull<CFF::Charset, unsigned int*>(void const*, int, hb_sanitize_context_t&, unsigned int*&&)
Unexecuted instantiation: hb-ot-cff1-table.cc:CFF::CFF1FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF1FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff1-table.cc:CFF::CFF1FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF1FDSelect, OT::NumType<true, unsigned short, 2u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned short, 2u> const&)
Unexecuted instantiation: hb-ot-cff1-table.cc:CFF::Encoding const& CFF::StructAtOffsetOrNull<CFF::Encoding>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff1-table.cc:CFF::CFF1StringIndex const& CFF::StructAtOffsetOrNull<CFF::CFF1StringIndex>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff1-table.cc:CFF::Subrs<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff1-table.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Unexecuted instantiation: hb-ot-cff2-table.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff2-table.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff2-table.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff2-table.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-ot-cff2-table.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Unexecuted instantiation: hb-ot-cff2-table.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
hb-subset-plan.cc:OT::CFFIndex<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
11.5k
{
48
11.5k
  if (!offset) return Null (Type);
49
50
11.5k
  const char *p = (const char *) P + offset;
51
11.5k
  if (!sc.check_point (p)) return Null (Type);
52
53
11.4k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
11.4k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
11.3k
  return obj;
57
11.4k
}
hb-subset-plan.cc:CFF::Charset const& CFF::StructAtOffsetOrNull<CFF::Charset, unsigned int*>(void const*, int, hb_sanitize_context_t&, unsigned int*&&)
Line
Count
Source
47
2.65k
{
48
2.65k
  if (!offset) return Null (Type);
49
50
2.65k
  const char *p = (const char *) P + offset;
51
2.65k
  if (!sc.check_point (p)) return Null (Type);
52
53
2.62k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
2.62k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
2.55k
  return obj;
57
2.62k
}
hb-subset-plan.cc:CFF::CFF1FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF1FDArray>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
1.06k
{
48
1.06k
  if (!offset) return Null (Type);
49
50
993
  const char *p = (const char *) P + offset;
51
993
  if (!sc.check_point (p)) return Null (Type);
52
53
825
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
825
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
805
  return obj;
57
825
}
hb-subset-plan.cc:CFF::CFF1FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF1FDSelect, OT::NumType<true, unsigned short, 2u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned short, 2u> const&)
Line
Count
Source
47
1.06k
{
48
1.06k
  if (!offset) return Null (Type);
49
50
961
  const char *p = (const char *) P + offset;
51
961
  if (!sc.check_point (p)) return Null (Type);
52
53
854
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
854
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
791
  return obj;
57
854
}
hb-subset-plan.cc:CFF::Encoding const& CFF::StructAtOffsetOrNull<CFF::Encoding>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
1.22k
{
48
1.22k
  if (!offset) return Null (Type);
49
50
1.22k
  const char *p = (const char *) P + offset;
51
1.22k
  if (!sc.check_point (p)) return Null (Type);
52
53
1.19k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
1.19k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
1.13k
  return obj;
57
1.19k
}
hb-subset-plan.cc:CFF::CFF1StringIndex const& CFF::StructAtOffsetOrNull<CFF::CFF1StringIndex>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
5.28k
{
48
5.28k
  if (!offset) return Null (Type);
49
50
5.28k
  const char *p = (const char *) P + offset;
51
5.28k
  if (!sc.check_point (p)) return Null (Type);
52
53
5.28k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
5.28k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
5.12k
  return obj;
57
5.28k
}
hb-subset-plan.cc:CFF::Subrs<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
28.5k
{
48
28.5k
  if (!offset) return Null (Type);
49
50
10.9k
  const char *p = (const char *) P + offset;
51
10.9k
  if (!sc.check_point (p)) return Null (Type);
52
53
10.3k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
10.3k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
7.08k
  return obj;
57
10.3k
}
hb-subset-plan.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Line
Count
Source
47
23.6k
{
48
23.6k
  if (!offset) return Null (Type);
49
50
16.9k
  const char *p = (const char *) P + offset;
51
16.9k
  if (!sc.check_point (p)) return Null (Type);
52
53
16.8k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
16.8k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
16.8k
  return obj;
57
16.8k
}
Unexecuted instantiation: hb-subset-plan.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-plan.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-plan.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-plan.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-plan.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Unexecuted instantiation: hb-subset-plan-var.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-plan-var.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-plan-var.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-plan-var.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-plan-var.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Unexecuted instantiation: hb-subset-plan-var.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Unexecuted instantiation: hb-subset-table-cff.cc:OT::CFFIndex<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-table-cff.cc:CFF::Charset const& CFF::StructAtOffsetOrNull<CFF::Charset, unsigned int*>(void const*, int, hb_sanitize_context_t&, unsigned int*&&)
Unexecuted instantiation: hb-subset-table-cff.cc:CFF::CFF1FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF1FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-table-cff.cc:CFF::CFF1FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF1FDSelect, OT::NumType<true, unsigned short, 2u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned short, 2u> const&)
Unexecuted instantiation: hb-subset-table-cff.cc:CFF::Encoding const& CFF::StructAtOffsetOrNull<CFF::Encoding>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-table-cff.cc:CFF::CFF1StringIndex const& CFF::StructAtOffsetOrNull<CFF::CFF1StringIndex>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-table-cff.cc:CFF::Subrs<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
hb-subset-table-cff.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Line
Count
Source
47
5.14k
{
48
5.14k
  if (!offset) return Null (Type);
49
50
1.86k
  const char *p = (const char *) P + offset;
51
1.86k
  if (!sc.check_point (p)) return Null (Type);
52
53
1.85k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
1.85k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
1.84k
  return obj;
57
1.85k
}
hb-subset-table-cff.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
7.26k
{
48
7.26k
  if (!offset) return Null (Type);
49
50
3.10k
  const char *p = (const char *) P + offset;
51
3.10k
  if (!sc.check_point (p)) return Null (Type);
52
53
2.96k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
2.96k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
2.38k
  return obj;
57
2.96k
}
hb-subset-table-cff.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
2.15k
{
48
2.15k
  if (!offset) return Null (Type);
49
50
977
  const char *p = (const char *) P + offset;
51
977
  if (!sc.check_point (p)) return Null (Type);
52
53
883
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
883
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
711
  return obj;
57
883
}
hb-subset-table-cff.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
2.15k
{
48
2.15k
  if (!offset) return Null (Type);
49
50
1.92k
  const char *p = (const char *) P + offset;
51
1.92k
  if (!sc.check_point (p)) return Null (Type);
52
53
1.80k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
1.80k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
1.70k
  return obj;
57
1.80k
}
hb-subset-table-cff.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Line
Count
Source
47
2.15k
{
48
2.15k
  if (!offset) return Null (Type);
49
50
1.88k
  const char *p = (const char *) P + offset;
51
1.88k
  if (!sc.check_point (p)) return Null (Type);
52
53
1.77k
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
1.77k
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
1.69k
  return obj;
57
1.77k
}
hb-subset-table-cff.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Line
Count
Source
47
2.15k
{
48
2.15k
  if (!offset) return Null (Type);
49
50
358
  const char *p = (const char *) P + offset;
51
358
  if (!sc.check_point (p)) return Null (Type);
52
53
187
  const Type &obj = *reinterpret_cast<const Type *> (p);
54
187
  if (!obj.sanitize (&sc, std::forward<Ts> (ds)...)) return Null (Type);
55
56
92
  return obj;
57
187
}
Unexecuted instantiation: hb-subset-cff1.cc:OT::CFFIndex<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff1.cc:CFF::Charset const& CFF::StructAtOffsetOrNull<CFF::Charset, unsigned int*>(void const*, int, hb_sanitize_context_t&, unsigned int*&&)
Unexecuted instantiation: hb-subset-cff1.cc:CFF::CFF1FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF1FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff1.cc:CFF::CFF1FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF1FDSelect, OT::NumType<true, unsigned short, 2u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned short, 2u> const&)
Unexecuted instantiation: hb-subset-cff1.cc:CFF::Encoding const& CFF::StructAtOffsetOrNull<CFF::Encoding>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff1.cc:CFF::CFF1StringIndex const& CFF::StructAtOffsetOrNull<CFF::CFF1StringIndex>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff1.cc:CFF::Subrs<OT::NumType<true, unsigned short, 2u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned short, 2u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff1.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Unexecuted instantiation: hb-subset-cff2.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff2.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff2.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff2.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff2.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Unexecuted instantiation: hb-subset-cff2.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
Unexecuted instantiation: hb-subset-cff-common.cc:CFF::Subrs<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<CFF::Subrs<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff-common.cc:CFF::CFF2ItemVariationStore const& CFF::StructAtOffsetOrNull<CFF::CFF2ItemVariationStore>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff-common.cc:OT::CFFIndex<OT::NumType<true, unsigned int, 4u> > const& CFF::StructAtOffsetOrNull<OT::CFFIndex<OT::NumType<true, unsigned int, 4u> >>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff-common.cc:CFF::CFF2FDArray const& CFF::StructAtOffsetOrNull<CFF::CFF2FDArray>(void const*, int, hb_sanitize_context_t&)
Unexecuted instantiation: hb-subset-cff-common.cc:CFF::CFF2FDSelect const& CFF::StructAtOffsetOrNull<CFF::CFF2FDSelect, OT::NumType<true, unsigned int, 4u> const&>(void const*, int, hb_sanitize_context_t&, OT::NumType<true, unsigned int, 4u> const&)
Unexecuted instantiation: hb-subset-cff-common.cc:CFF::UnsizedByteStr const& CFF::StructAtOffsetOrNull<CFF::UnsizedByteStr, unsigned int&>(void const*, int, hb_sanitize_context_t&, unsigned int&)
58
59
60
struct code_pair_t
61
{
62
  unsigned code;
63
  hb_codepoint_t glyph;
64
};
65
66
67
using str_buff_t = hb_vector_t<unsigned char>;
68
using str_buff_vec_t = hb_vector_t<str_buff_t>;
69
using glyph_to_sid_map_t = hb_vector_t<code_pair_t>;
70
71
/* Top Dict, Font Dict, Private Dict */
72
struct Dict : UnsizedByteStr
73
{
74
  template <typename DICTVAL, typename OP_SERIALIZER, typename ...Ts>
75
  bool serialize (hb_serialize_context_t *c,
76
      const DICTVAL &dictval,
77
      OP_SERIALIZER& opszr,
78
      Ts&&... ds)
79
5.68k
  {
80
5.68k
    TRACE_SERIALIZE (this);
81
76.0k
    for (unsigned int i = 0; i < dictval.get_count (); i++)
82
70.3k
      if (unlikely (!opszr.serialize (c, dictval[i], ds...)))
83
8
  return_trace (false);
84
85
5.68k
    return_trace (true);
86
5.68k
  }
bool CFF::Dict::serialize<CFF::cff1_private_dict_values_base_t<CFF::op_str_t>, cff1_private_dict_op_serializer_t, unsigned int&>(hb_serialize_context_t*, CFF::cff1_private_dict_values_base_t<CFF::op_str_t> const&, cff1_private_dict_op_serializer_t&, unsigned int&)
Line
Count
Source
79
1.37k
  {
80
1.37k
    TRACE_SERIALIZE (this);
81
34.4k
    for (unsigned int i = 0; i < dictval.get_count (); i++)
82
33.1k
      if (unlikely (!opszr.serialize (c, dictval[i], ds...)))
83
2
  return_trace (false);
84
85
1.37k
    return_trace (true);
86
1.37k
  }
bool CFF::Dict::serialize<CFF::cff1_font_dict_values_mod_t, cff1_font_dict_op_serializer_t, CFF::cff1_font_dict_values_mod_t const&>(hb_serialize_context_t*, CFF::cff1_font_dict_values_mod_t const&, cff1_font_dict_op_serializer_t&, CFF::cff1_font_dict_values_mod_t const&)
Line
Count
Source
79
294
  {
80
294
    TRACE_SERIALIZE (this);
81
873
    for (unsigned int i = 0; i < dictval.get_count (); i++)
82
580
      if (unlikely (!opszr.serialize (c, dictval[i], ds...)))
83
1
  return_trace (false);
84
85
293
    return_trace (true);
86
294
  }
bool CFF::Dict::serialize<cff1_top_dict_values_mod_t, cff1_top_dict_op_serializer_t, top_dict_modifiers_t&>(hb_serialize_context_t*, cff1_top_dict_values_mod_t const&, cff1_top_dict_op_serializer_t&, top_dict_modifiers_t&)
Line
Count
Source
79
1.24k
  {
80
1.24k
    TRACE_SERIALIZE (this);
81
12.7k
    for (unsigned int i = 0; i < dictval.get_count (); i++)
82
11.4k
      if (unlikely (!opszr.serialize (c, dictval[i], ds...)))
83
0
  return_trace (false);
84
85
1.24k
    return_trace (true);
86
1.24k
  }
bool CFF::Dict::serialize<CFF::cff2_private_dict_values_base_t<CFF::op_str_t>, cff2_private_dict_op_serializer_t, unsigned int&>(hb_serialize_context_t*, CFF::cff2_private_dict_values_base_t<CFF::op_str_t> const&, cff2_private_dict_op_serializer_t&, unsigned int&)
Line
Count
Source
79
932
  {
80
932
    TRACE_SERIALIZE (this);
81
15.5k
    for (unsigned int i = 0; i < dictval.get_count (); i++)
82
14.6k
      if (unlikely (!opszr.serialize (c, dictval[i], ds...)))
83
1
  return_trace (false);
84
85
931
    return_trace (true);
86
932
  }
bool CFF::Dict::serialize<CFF::cff2_font_dict_values_t, CFF::cff_font_dict_op_serializer_t, CFF::table_info_t const&>(hb_serialize_context_t*, CFF::cff2_font_dict_values_t const&, CFF::cff_font_dict_op_serializer_t&, CFF::table_info_t const&)
Line
Count
Source
79
931
  {
80
931
    TRACE_SERIALIZE (this);
81
6.67k
    for (unsigned int i = 0; i < dictval.get_count (); i++)
82
5.74k
      if (unlikely (!opszr.serialize (c, dictval[i], ds...)))
83
2
  return_trace (false);
84
85
929
    return_trace (true);
86
931
  }
bool CFF::Dict::serialize<CFF::cff2_top_dict_values_t, cff2_top_dict_op_serializer_t, cff2_sub_table_info_t&>(hb_serialize_context_t*, CFF::cff2_top_dict_values_t const&, cff2_top_dict_op_serializer_t&, cff2_sub_table_info_t&)
Line
Count
Source
79
911
  {
80
911
    TRACE_SERIALIZE (this);
81
5.76k
    for (unsigned int i = 0; i < dictval.get_count (); i++)
82
4.85k
      if (unlikely (!opszr.serialize (c, dictval[i], ds...)))
83
2
  return_trace (false);
84
85
909
    return_trace (true);
86
911
  }
87
88
  template <typename T, typename V>
89
  static bool serialize_int_op (hb_serialize_context_t *c, op_code_t op, V value, op_code_t intOp)
90
12.0k
  {
91
12.0k
    if (unlikely ((!serialize_int<T, V> (c, intOp, value))))
92
3
      return false;
93
94
12.0k
    TRACE_SERIALIZE (this);
95
    /* serialize the opcode */
96
12.0k
    HBUINT8 *p = c->allocate_size<HBUINT8> (OpCode_Size (op), false);
97
12.0k
    if (unlikely (!p)) return_trace (false);
98
12.0k
    if (Is_OpCode_ESC (op))
99
1.84k
    {
100
1.84k
      *p = OpCode_escape;
101
1.84k
      op = Unmake_OpCode_ESC (op);
102
1.84k
      p++;
103
1.84k
    }
104
12.0k
    *p = op;
105
12.0k
    return_trace (true);
106
12.0k
  }
bool CFF::Dict::serialize_int_op<OT::NumType<true, int, 4u>, int>(hb_serialize_context_t*, unsigned int, int, unsigned int)
Line
Count
Source
90
7.31k
  {
91
7.31k
    if (unlikely ((!serialize_int<T, V> (c, intOp, value))))
92
2
      return false;
93
94
7.31k
    TRACE_SERIALIZE (this);
95
    /* serialize the opcode */
96
7.31k
    HBUINT8 *p = c->allocate_size<HBUINT8> (OpCode_Size (op), false);
97
7.31k
    if (unlikely (!p)) return_trace (false);
98
7.31k
    if (Is_OpCode_ESC (op))
99
1.48k
    {
100
1.48k
      *p = OpCode_escape;
101
1.48k
      op = Unmake_OpCode_ESC (op);
102
1.48k
      p++;
103
1.48k
    }
104
7.31k
    *p = op;
105
7.31k
    return_trace (true);
106
7.31k
  }
bool CFF::Dict::serialize_int_op<OT::NumType<true, short, 2u>, int>(hb_serialize_context_t*, unsigned int, int, unsigned int)
Line
Count
Source
90
403
  {
91
403
    if (unlikely ((!serialize_int<T, V> (c, intOp, value))))
92
0
      return false;
93
94
403
    TRACE_SERIALIZE (this);
95
    /* serialize the opcode */
96
403
    HBUINT8 *p = c->allocate_size<HBUINT8> (OpCode_Size (op), false);
97
403
    if (unlikely (!p)) return_trace (false);
98
403
    if (Is_OpCode_ESC (op))
99
0
    {
100
0
      *p = OpCode_escape;
101
0
      op = Unmake_OpCode_ESC (op);
102
0
      p++;
103
0
    }
104
403
    *p = op;
105
403
    return_trace (true);
106
403
  }
bool CFF::Dict::serialize_int_op<OT::NumType<true, short, 2u>, unsigned int>(hb_serialize_context_t*, unsigned int, unsigned int, unsigned int)
Line
Count
Source
90
4.30k
  {
91
4.30k
    if (unlikely ((!serialize_int<T, V> (c, intOp, value))))
92
1
      return false;
93
94
4.30k
    TRACE_SERIALIZE (this);
95
    /* serialize the opcode */
96
4.30k
    HBUINT8 *p = c->allocate_size<HBUINT8> (OpCode_Size (op), false);
97
4.30k
    if (unlikely (!p)) return_trace (false);
98
4.30k
    if (Is_OpCode_ESC (op))
99
366
    {
100
366
      *p = OpCode_escape;
101
366
      op = Unmake_OpCode_ESC (op);
102
366
      p++;
103
366
    }
104
4.30k
    *p = op;
105
4.30k
    return_trace (true);
106
4.30k
  }
107
108
  template <typename V>
109
  static bool serialize_int4_op (hb_serialize_context_t *c, op_code_t op, V value)
110
  { return serialize_int_op<HBINT32> (c, op, value, OpCode_longintdict); }
111
112
  template <typename V>
113
  static bool serialize_int2_op (hb_serialize_context_t *c, op_code_t op, V value)
114
4.30k
  { return serialize_int_op<HBINT16> (c, op, value, OpCode_shortint); }
115
116
  template <typename T, int int_op>
117
  static bool serialize_link_op (hb_serialize_context_t *c, op_code_t op, objidx_t link, whence_t whence)
118
7.72k
  {
119
7.72k
    T &ofs = *(T *) (c->head + OpCode_Size (int_op));
120
7.72k
    if (unlikely (!serialize_int_op<T> (c, op, 0, int_op))) return false;
121
7.71k
    c->add_link (ofs, link, whence);
122
7.71k
    return true;
123
7.72k
  }
bool CFF::Dict::serialize_link_op<OT::NumType<true, int, 4u>, 29>(hb_serialize_context_t*, unsigned int, unsigned int, hb_serialize_context_t::whence_t)
Line
Count
Source
118
7.31k
  {
119
7.31k
    T &ofs = *(T *) (c->head + OpCode_Size (int_op));
120
7.31k
    if (unlikely (!serialize_int_op<T> (c, op, 0, int_op))) return false;
121
7.31k
    c->add_link (ofs, link, whence);
122
7.31k
    return true;
123
7.31k
  }
bool CFF::Dict::serialize_link_op<OT::NumType<true, short, 2u>, 28>(hb_serialize_context_t*, unsigned int, unsigned int, hb_serialize_context_t::whence_t)
Line
Count
Source
118
403
  {
119
403
    T &ofs = *(T *) (c->head + OpCode_Size (int_op));
120
403
    if (unlikely (!serialize_int_op<T> (c, op, 0, int_op))) return false;
121
403
    c->add_link (ofs, link, whence);
122
403
    return true;
123
403
  }
124
125
  static bool serialize_link4_op (hb_serialize_context_t *c, op_code_t op, objidx_t link, whence_t whence = whence_t::Head)
126
7.31k
  { return serialize_link_op<HBINT32, OpCode_longintdict> (c, op, link, whence); }
127
128
  static bool serialize_link2_op (hb_serialize_context_t *c, op_code_t op, objidx_t link, whence_t whence = whence_t::Head)
129
403
  { return serialize_link_op<HBINT16, OpCode_shortint> (c, op, link, whence); }
130
};
131
132
struct TopDict : Dict {};
133
struct FontDict : Dict {};
134
struct PrivateDict : Dict {};
135
136
struct table_info_t
137
{
138
93.6k
  void init () { offset = size = 0; link = 0; }
139
140
  unsigned int    offset;
141
  unsigned int    size;
142
  objidx_t    link;
143
};
144
145
template <typename COUNT>
146
struct FDArray : CFFIndex<COUNT>
147
{
148
  template <typename DICTVAL, typename INFO, typename Iterator, typename OP_SERIALIZER>
149
  bool serialize (hb_serialize_context_t *c,
150
      Iterator it,
151
      OP_SERIALIZER& opszr)
152
1.12k
  {
153
1.12k
    TRACE_SERIALIZE (this);
154
155
    /* serialize INDEX data */
156
1.12k
    hb_vector_t<unsigned> sizes;
157
1.12k
    if (it.is_random_access_iterator)
158
211
      sizes.alloc (hb_len (it));
159
160
1.12k
    c->push ();
161
1.12k
    char *data_base = c->head;
162
1.12k
    + it
163
1.12k
    | hb_map ([&] (const hb_pair_t<const DICTVAL&, const INFO&> &_)
164
1.22k
    {
165
1.22k
      FontDict *dict = c->start_embed<FontDict> ();
166
1.22k
    dict->serialize (c, _.first, opszr, _.second);
167
1.22k
    return c->head - (const char*)dict;
168
1.22k
        })
CFF::FDArray<OT::NumType<true, unsigned short, 2u> >::serialize<CFF::cff1_font_dict_values_mod_t, CFF::cff1_font_dict_values_mod_t, hb_zip_iter_t<hb_array_t<CFF::cff1_font_dict_values_mod_t const>, hb_array_t<CFF::cff1_font_dict_values_mod_t const> >, cff1_font_dict_op_serializer_t>(hb_serialize_context_t*, hb_zip_iter_t<hb_array_t<CFF::cff1_font_dict_values_mod_t const>, hb_array_t<CFF::cff1_font_dict_values_mod_t const> >, cff1_font_dict_op_serializer_t&)::{lambda(hb_pair_t<CFF::cff1_font_dict_values_mod_t const&, CFF::cff1_font_dict_values_mod_t const&> const&)#1}::operator()(hb_pair_t<CFF::cff1_font_dict_values_mod_t const&, CFF::cff1_font_dict_values_mod_t const&> const&) const
Line
Count
Source
164
294
    {
165
294
      FontDict *dict = c->start_embed<FontDict> ();
166
294
    dict->serialize (c, _.first, opszr, _.second);
167
294
    return c->head - (const char*)dict;
168
294
        })
hb-subset-cff2.cc:CFF::FDArray<OT::NumType<true, unsigned int, 4u> >::serialize<CFF::cff2_font_dict_values_t, CFF::table_info_t, hb_zip_iter_t<hb_filter_iter_t<hb_array_t<CFF::cff2_font_dict_values_t const>, OT::cff2::accelerator_subset_t::serialize(hb_serialize_context_t*, OT::cff2_subset_plan&, hb_array_t<int>) const::$_0, $_8 const&, (void*)0>, hb_array_t<CFF::table_info_t const> >, CFF::cff_font_dict_op_serializer_t>(hb_serialize_context_t*, hb_zip_iter_t<hb_filter_iter_t<hb_array_t<CFF::cff2_font_dict_values_t const>, OT::cff2::accelerator_subset_t::serialize(hb_serialize_context_t*, OT::cff2_subset_plan&, hb_array_t<int>) const::$_0, $_8 const&, (void*)0>, hb_array_t<CFF::table_info_t const> >, CFF::cff_font_dict_op_serializer_t&)::{lambda(hb_pair_t<CFF::cff2_font_dict_values_t const&, CFF::table_info_t const&> const&)#1}::operator()(hb_pair_t<CFF::cff2_font_dict_values_t const&, CFF::table_info_t const&> const&) const
Line
Count
Source
164
931
    {
165
931
      FontDict *dict = c->start_embed<FontDict> ();
166
931
    dict->serialize (c, _.first, opszr, _.second);
167
931
    return c->head - (const char*)dict;
168
931
        })
169
1.12k
    | hb_sink (sizes)
170
1.12k
    ;
171
1.12k
    unsigned data_size = c->head - data_base;
172
1.12k
    c->pop_pack (false);
173
174
1.12k
    if (unlikely (sizes.in_error ())) return_trace (false);
175
176
    /* It just happens that the above is packed right after the header below.
177
     * Such a hack. */
178
179
    /* serialize INDEX header */
180
1.12k
    return_trace (CFFIndex<COUNT>::serialize_header (c, hb_iter (sizes), data_size));
181
1.12k
  }
bool CFF::FDArray<OT::NumType<true, unsigned short, 2u> >::serialize<CFF::cff1_font_dict_values_mod_t, CFF::cff1_font_dict_values_mod_t, hb_zip_iter_t<hb_array_t<CFF::cff1_font_dict_values_mod_t const>, hb_array_t<CFF::cff1_font_dict_values_mod_t const> >, cff1_font_dict_op_serializer_t>(hb_serialize_context_t*, hb_zip_iter_t<hb_array_t<CFF::cff1_font_dict_values_mod_t const>, hb_array_t<CFF::cff1_font_dict_values_mod_t const> >, cff1_font_dict_op_serializer_t&)
Line
Count
Source
152
211
  {
153
211
    TRACE_SERIALIZE (this);
154
155
    /* serialize INDEX data */
156
211
    hb_vector_t<unsigned> sizes;
157
211
    if (it.is_random_access_iterator)
158
211
      sizes.alloc (hb_len (it));
159
160
211
    c->push ();
161
211
    char *data_base = c->head;
162
211
    + it
163
211
    | hb_map ([&] (const hb_pair_t<const DICTVAL&, const INFO&> &_)
164
211
    {
165
211
      FontDict *dict = c->start_embed<FontDict> ();
166
211
    dict->serialize (c, _.first, opszr, _.second);
167
211
    return c->head - (const char*)dict;
168
211
        })
169
211
    | hb_sink (sizes)
170
211
    ;
171
211
    unsigned data_size = c->head - data_base;
172
211
    c->pop_pack (false);
173
174
211
    if (unlikely (sizes.in_error ())) return_trace (false);
175
176
    /* It just happens that the above is packed right after the header below.
177
     * Such a hack. */
178
179
    /* serialize INDEX header */
180
210
    return_trace (CFFIndex<COUNT>::serialize_header (c, hb_iter (sizes), data_size));
181
211
  }
hb-subset-cff2.cc:bool CFF::FDArray<OT::NumType<true, unsigned int, 4u> >::serialize<CFF::cff2_font_dict_values_t, CFF::table_info_t, hb_zip_iter_t<hb_filter_iter_t<hb_array_t<CFF::cff2_font_dict_values_t const>, OT::cff2::accelerator_subset_t::serialize(hb_serialize_context_t*, OT::cff2_subset_plan&, hb_array_t<int>) const::$_0, $_8 const&, (void*)0>, hb_array_t<CFF::table_info_t const> >, CFF::cff_font_dict_op_serializer_t>(hb_serialize_context_t*, hb_zip_iter_t<hb_filter_iter_t<hb_array_t<CFF::cff2_font_dict_values_t const>, OT::cff2::accelerator_subset_t::serialize(hb_serialize_context_t*, OT::cff2_subset_plan&, hb_array_t<int>) const::$_0, $_8 const&, (void*)0>, hb_array_t<CFF::table_info_t const> >, CFF::cff_font_dict_op_serializer_t&)
Line
Count
Source
152
917
  {
153
917
    TRACE_SERIALIZE (this);
154
155
    /* serialize INDEX data */
156
917
    hb_vector_t<unsigned> sizes;
157
917
    if (it.is_random_access_iterator)
158
0
      sizes.alloc (hb_len (it));
159
160
917
    c->push ();
161
917
    char *data_base = c->head;
162
917
    + it
163
917
    | hb_map ([&] (const hb_pair_t<const DICTVAL&, const INFO&> &_)
164
917
    {
165
917
      FontDict *dict = c->start_embed<FontDict> ();
166
917
    dict->serialize (c, _.first, opszr, _.second);
167
917
    return c->head - (const char*)dict;
168
917
        })
169
917
    | hb_sink (sizes)
170
917
    ;
171
917
    unsigned data_size = c->head - data_base;
172
917
    c->pop_pack (false);
173
174
917
    if (unlikely (sizes.in_error ())) return_trace (false);
175
176
    /* It just happens that the above is packed right after the header below.
177
     * Such a hack. */
178
179
    /* serialize INDEX header */
180
913
    return_trace (CFFIndex<COUNT>::serialize_header (c, hb_iter (sizes), data_size));
181
917
  }
182
};
183
184
/* FDSelect */
185
struct FDSelect0 {
186
  bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const
187
368
  {
188
368
    TRACE_SANITIZE (this);
189
368
    if (unlikely (!(c->check_struct (this))))
190
0
      return_trace (false);
191
368
    hb_barrier ();
192
368
    if (unlikely (!c->check_array (fds, c->get_num_glyphs ())))
193
9
      return_trace (false);
194
195
368
    return_trace (true);
196
368
  }
197
198
  unsigned get_fd (hb_codepoint_t glyph) const
199
507
  { return fds[glyph]; }
200
201
  hb_pair_t<unsigned, hb_codepoint_t> get_fd_range (hb_codepoint_t glyph) const
202
301
  { return {fds[glyph], glyph + 1}; }
203
204
  unsigned int get_size (unsigned int num_glyphs) const
205
0
  { return HBUINT8::static_size * num_glyphs; }
206
207
  HBUINT8     fds[HB_VAR_ARRAY];
208
209
  DEFINE_SIZE_MIN (0);
210
};
211
212
template <typename GID_TYPE, typename FD_TYPE>
213
struct FDSelect3_4_Range
214
{
215
  bool sanitize (hb_sanitize_context_t *c, const void * /*nullptr*/, unsigned int fdcount) const
216
8.92k
  {
217
8.92k
    TRACE_SANITIZE (this);
218
8.92k
    return_trace (c->check_struct (this) &&
219
8.92k
      hb_barrier () &&
220
8.92k
      first < c->get_num_glyphs () && (fd < fdcount));
221
8.92k
  }
CFF::FDSelect3_4_Range<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::sanitize(hb_sanitize_context_t*, void const*, unsigned int) const
Line
Count
Source
216
8.21k
  {
217
8.21k
    TRACE_SANITIZE (this);
218
8.21k
    return_trace (c->check_struct (this) &&
219
8.21k
      hb_barrier () &&
220
8.21k
      first < c->get_num_glyphs () && (fd < fdcount));
221
8.21k
  }
CFF::FDSelect3_4_Range<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*, void const*, unsigned int) const
Line
Count
Source
216
712
  {
217
712
    TRACE_SANITIZE (this);
218
712
    return_trace (c->check_struct (this) &&
219
712
      hb_barrier () &&
220
712
      first < c->get_num_glyphs () && (fd < fdcount));
221
712
  }
222
223
  GID_TYPE    first;
224
  FD_TYPE     fd;
225
  public:
226
  DEFINE_SIZE_STATIC (GID_TYPE::static_size + FD_TYPE::static_size);
227
};
228
229
template <typename GID_TYPE, typename FD_TYPE>
230
struct FDSelect3_4
231
{
232
  unsigned int get_size () const
233
0
  { return GID_TYPE::static_size * 2 + ranges.get_size (); }
Unexecuted instantiation: CFF::FDSelect3_4<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::get_size() const
Unexecuted instantiation: CFF::FDSelect3_4<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::get_size() const
234
235
  bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const
236
625
  {
237
625
    TRACE_SANITIZE (this);
238
625
    if (unlikely (!(c->check_struct (this) &&
239
625
        ranges.sanitize (c, nullptr, fdcount) &&
240
625
        hb_barrier () &&
241
625
        (nRanges () != 0) &&
242
625
        ranges[0].first == 0)))
243
70
      return_trace (false);
244
245
6.81k
    for (unsigned int i = 1; i < nRanges (); i++)
246
6.27k
      if (unlikely (ranges[i - 1].first >= ranges[i].first))
247
15
  return_trace (false);
248
249
540
    if (unlikely (!(sentinel().sanitize (c) &&
250
540
       hb_barrier () &&
251
540
       (sentinel() == c->get_num_glyphs ()))))
252
16
      return_trace (false);
253
254
540
    return_trace (true);
255
540
  }
CFF::FDSelect3_4<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::sanitize(hb_sanitize_context_t*, unsigned int) const
Line
Count
Source
236
579
  {
237
579
    TRACE_SANITIZE (this);
238
579
    if (unlikely (!(c->check_struct (this) &&
239
579
        ranges.sanitize (c, nullptr, fdcount) &&
240
579
        hb_barrier () &&
241
579
        (nRanges () != 0) &&
242
579
        ranges[0].first == 0)))
243
40
      return_trace (false);
244
245
6.77k
    for (unsigned int i = 1; i < nRanges (); i++)
246
6.24k
      if (unlikely (ranges[i - 1].first >= ranges[i].first))
247
11
  return_trace (false);
248
249
528
    if (unlikely (!(sentinel().sanitize (c) &&
250
528
       hb_barrier () &&
251
528
       (sentinel() == c->get_num_glyphs ()))))
252
12
      return_trace (false);
253
254
516
    return_trace (true);
255
528
  }
CFF::FDSelect3_4<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::sanitize(hb_sanitize_context_t*, unsigned int) const
Line
Count
Source
236
46
  {
237
46
    TRACE_SANITIZE (this);
238
46
    if (unlikely (!(c->check_struct (this) &&
239
46
        ranges.sanitize (c, nullptr, fdcount) &&
240
46
        hb_barrier () &&
241
46
        (nRanges () != 0) &&
242
46
        ranges[0].first == 0)))
243
30
      return_trace (false);
244
245
42
    for (unsigned int i = 1; i < nRanges (); i++)
246
30
      if (unlikely (ranges[i - 1].first >= ranges[i].first))
247
4
  return_trace (false);
248
249
12
    if (unlikely (!(sentinel().sanitize (c) &&
250
12
       hb_barrier () &&
251
12
       (sentinel() == c->get_num_glyphs ()))))
252
4
      return_trace (false);
253
254
8
    return_trace (true);
255
12
  }
256
257
  static int _cmp_range (const void *_key, const void *_item)
258
2.50k
  {
259
2.50k
    hb_codepoint_t glyph = * (hb_codepoint_t *) _key;
260
2.50k
    FDSelect3_4_Range<GID_TYPE, FD_TYPE> *range = (FDSelect3_4_Range<GID_TYPE, FD_TYPE> *) _item;
261
262
2.50k
    if (glyph < range[0].first) return -1;
263
1.17k
    if (glyph < range[1].first) return 0;
264
305
    return +1;
265
1.17k
  }
CFF::FDSelect3_4<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::_cmp_range(void const*, void const*)
Line
Count
Source
258
2.47k
  {
259
2.47k
    hb_codepoint_t glyph = * (hb_codepoint_t *) _key;
260
2.47k
    FDSelect3_4_Range<GID_TYPE, FD_TYPE> *range = (FDSelect3_4_Range<GID_TYPE, FD_TYPE> *) _item;
261
262
2.47k
    if (glyph < range[0].first) return -1;
263
1.15k
    if (glyph < range[1].first) return 0;
264
305
    return +1;
265
1.15k
  }
CFF::FDSelect3_4<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::_cmp_range(void const*, void const*)
Line
Count
Source
258
30
  {
259
30
    hb_codepoint_t glyph = * (hb_codepoint_t *) _key;
260
30
    FDSelect3_4_Range<GID_TYPE, FD_TYPE> *range = (FDSelect3_4_Range<GID_TYPE, FD_TYPE> *) _item;
261
262
30
    if (glyph < range[0].first) return -1;
263
15
    if (glyph < range[1].first) return 0;
264
0
    return +1;
265
15
  }
266
267
  unsigned get_fd (hb_codepoint_t glyph) const
268
905
  {
269
905
    auto *range = hb_bsearch (glyph, &ranges[0], nRanges () - 1, sizeof (ranges[0]), _cmp_range);
270
905
    return range ? range->fd : ranges[nRanges () - 1].fd;
271
905
  }
CFF::FDSelect3_4<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::get_fd(unsigned int) const
Line
Count
Source
268
890
  {
269
890
    auto *range = hb_bsearch (glyph, &ranges[0], nRanges () - 1, sizeof (ranges[0]), _cmp_range);
270
890
    return range ? range->fd : ranges[nRanges () - 1].fd;
271
890
  }
CFF::FDSelect3_4<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::get_fd(unsigned int) const
Line
Count
Source
268
15
  {
269
15
    auto *range = hb_bsearch (glyph, &ranges[0], nRanges () - 1, sizeof (ranges[0]), _cmp_range);
270
15
    return range ? range->fd : ranges[nRanges () - 1].fd;
271
15
  }
272
273
  hb_pair_t<unsigned, hb_codepoint_t> get_fd_range (hb_codepoint_t glyph) const
274
424
  {
275
424
    auto *range = hb_bsearch (glyph, &ranges[0], nRanges () - 1, sizeof (ranges[0]), _cmp_range);
276
424
    unsigned fd = range ? range->fd : ranges[nRanges () - 1].fd;
277
424
    hb_codepoint_t end = range ? range[1].first : ranges[nRanges () - 1].first;
278
424
    return {fd, end};
279
424
  }
280
281
538
  GID_TYPE        &nRanges ()       { return ranges.len; }
CFF::FDSelect3_4<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::nRanges()
Line
Count
Source
281
538
  GID_TYPE        &nRanges ()       { return ranges.len; }
Unexecuted instantiation: CFF::FDSelect3_4<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::nRanges()
282
10.4k
  GID_TYPE         nRanges () const { return ranges.len; }
CFF::FDSelect3_4<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::nRanges() const
Line
Count
Source
282
10.3k
  GID_TYPE         nRanges () const { return ranges.len; }
CFF::FDSelect3_4<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::nRanges() const
Line
Count
Source
282
99
  GID_TYPE         nRanges () const { return ranges.len; }
283
269
  GID_TYPE       &sentinel ()       { return StructAfter<GID_TYPE> (ranges[nRanges () - 1]); }
CFF::FDSelect3_4<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::sentinel()
Line
Count
Source
283
269
  GID_TYPE       &sentinel ()       { return StructAfter<GID_TYPE> (ranges[nRanges () - 1]); }
Unexecuted instantiation: CFF::FDSelect3_4<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::sentinel()
284
1.07k
  const GID_TYPE &sentinel () const { return StructAfter<GID_TYPE> (ranges[nRanges () - 1]); }
CFF::FDSelect3_4<OT::NumType<true, unsigned short, 2u>, OT::NumType<true, unsigned char, 1u> >::sentinel() const
Line
Count
Source
284
1.05k
  const GID_TYPE &sentinel () const { return StructAfter<GID_TYPE> (ranges[nRanges () - 1]); }
CFF::FDSelect3_4<OT::NumType<true, unsigned int, 4u>, OT::NumType<true, unsigned short, 2u> >::sentinel() const
Line
Count
Source
284
22
  const GID_TYPE &sentinel () const { return StructAfter<GID_TYPE> (ranges[nRanges () - 1]); }
285
286
  ArrayOf<FDSelect3_4_Range<GID_TYPE, FD_TYPE>, GID_TYPE> ranges;
287
  /* GID_TYPE sentinel */
288
289
  DEFINE_SIZE_ARRAY (GID_TYPE::static_size, ranges);
290
};
291
292
typedef FDSelect3_4<HBUINT16, HBUINT8> FDSelect3;
293
typedef FDSelect3_4_Range<HBUINT16, HBUINT8> FDSelect3_Range;
294
295
struct FDSelect
296
{
297
  bool serialize (hb_serialize_context_t *c, const FDSelect &src, unsigned int num_glyphs)
298
0
  {
299
0
    TRACE_SERIALIZE (this);
300
0
    unsigned int size = src.get_size (num_glyphs);
301
0
    FDSelect *dest = c->allocate_size<FDSelect> (size, false);
302
0
    if (unlikely (!dest)) return_trace (false);
303
0
    hb_memcpy (dest, &src, size);
304
0
    return_trace (true);
305
0
  }
306
307
  unsigned int get_size (unsigned int num_glyphs) const
308
0
  {
309
0
    switch (format)
310
0
    {
311
0
    case 0: hb_barrier (); return format.static_size + u.format0.get_size (num_glyphs);
312
0
    case 3: hb_barrier (); return format.static_size + u.format3.get_size ();
313
0
    default:return 0;
314
0
    }
315
0
  }
316
317
  unsigned get_fd (hb_codepoint_t glyph) const
318
11.0k
  {
319
11.0k
    if (this == &Null (FDSelect)) return 0;
320
321
1.21k
    switch (format)
322
1.21k
    {
323
468
    case 0: hb_barrier (); return u.format0.get_fd (glyph);
324
746
    case 3: hb_barrier (); return u.format3.get_fd (glyph);
325
0
    default:return 0;
326
1.21k
    }
327
1.21k
  }
328
  /* Returns pair of fd and one after last glyph in range. */
329
  hb_pair_t<unsigned, hb_codepoint_t> get_fd_range (hb_codepoint_t glyph) const
330
737
  {
331
737
    if (this == &Null (FDSelect)) return {0, 1};
332
333
737
    switch (format)
334
737
    {
335
301
    case 0: hb_barrier (); return u.format0.get_fd_range (glyph);
336
424
    case 3: hb_barrier (); return u.format3.get_fd_range (glyph);
337
12
    default:return {0, 1};
338
737
    }
339
737
  }
340
341
  bool sanitize (hb_sanitize_context_t *c, unsigned int fdcount) const
342
854
  {
343
854
    TRACE_SANITIZE (this);
344
854
    if (unlikely (!c->check_struct (this)))
345
5
      return_trace (false);
346
849
    hb_barrier ();
347
348
849
    switch (format)
349
849
    {
350
335
    case 0: hb_barrier (); return_trace (u.format0.sanitize (c, fdcount));
351
504
    case 3: hb_barrier (); return_trace (u.format3.sanitize (c, fdcount));
352
10
    default:return_trace (false);
353
849
    }
354
849
  }
355
356
  HBUINT8 format;
357
  union {
358
  FDSelect0 format0;
359
  FDSelect3 format3;
360
  } u;
361
  public:
362
  DEFINE_SIZE_MIN (1);
363
};
364
365
template <typename COUNT>
366
struct Subrs : CFFIndex<COUNT>
367
{
368
  typedef COUNT count_type;
369
  typedef CFFIndex<COUNT> SUPER;
370
};
371
372
} /* namespace CFF */
373
374
#endif /* HB_OT_CFF_COMMON_HH */