Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/workdir/UnpackedTarball/harfbuzz/src/hb-subset-table.hh
Line
Count
Source
1
/*
2
 * Copyright © 2018  Google, 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
 * Google Author(s): Garret Rieger, Roderick Sheeter
25
 */
26
27
#ifndef HB_SUBSET_TABLE_HH
28
#define HB_SUBSET_TABLE_HH
29
30
31
#include "hb.hh"
32
33
#include "hb-subset.hh"
34
#include "hb-repacker.hh"
35
36
37
template<typename TableType>
38
static bool
39
_hb_subset_table_try (const TableType *table,
40
          hb_vector_t<char>* buf,
41
          hb_subset_context_t* c /* OUT */)
42
86.6k
{
43
86.6k
  c->serializer->start_serialize ();
44
86.6k
  if (c->serializer->in_error ()) return false;
45
46
86.6k
  bool needed = table->subset (c);
47
86.6k
  if (!c->serializer->ran_out_of_room ())
48
86.6k
  {
49
86.6k
    c->serializer->end_serialize ();
50
86.6k
    return needed;
51
86.6k
  }
52
53
17
  unsigned buf_size = buf->allocated;
54
17
  buf_size = buf_size * 2 + 16;
55
56
57
58
59
17
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.",
60
17
             HB_UNTAG (c->table_tag), buf_size);
61
62
17
  if (unlikely (buf_size > c->source_blob->length * 256 ||
63
17
    !buf->alloc_exact (buf_size)))
64
0
  {
65
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.",
66
0
               HB_UNTAG (c->table_tag), buf_size);
67
0
    return needed;
68
0
  }
69
70
17
  c->serializer->reset (buf->arrayZ, buf->allocated);
71
17
  return _hb_subset_table_try (table, buf, c);
72
17
}
hb-subset.cc:bool _hb_subset_table_try<OT::head>(OT::head const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Line
Count
Source
42
1.19k
{
43
1.19k
  c->serializer->start_serialize ();
44
1.19k
  if (c->serializer->in_error ()) return false;
45
46
1.19k
  bool needed = table->subset (c);
47
1.19k
  if (!c->serializer->ran_out_of_room ())
48
1.19k
  {
49
1.19k
    c->serializer->end_serialize ();
50
1.19k
    return needed;
51
1.19k
  }
52
53
0
  unsigned buf_size = buf->allocated;
54
0
  buf_size = buf_size * 2 + 16;
55
56
57
58
59
0
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.",
60
0
             HB_UNTAG (c->table_tag), buf_size);
61
62
0
  if (unlikely (buf_size > c->source_blob->length * 256 ||
63
0
    !buf->alloc_exact (buf_size)))
64
0
  {
65
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.",
66
0
               HB_UNTAG (c->table_tag), buf_size);
67
0
    return needed;
68
0
  }
69
70
0
  c->serializer->reset (buf->arrayZ, buf->allocated);
71
0
  return _hb_subset_table_try (table, buf, c);
72
0
}
Unexecuted instantiation: hb-subset.cc:bool _hb_subset_table_try<OT::STAT>(OT::STAT const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table_try<OT::GDEF>(OT::GDEF const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table_try<OT::Layout::GSUB>(OT::Layout::GSUB const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table_try<OT::Layout::GPOS>(OT::Layout::GPOS const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table_try<OT::BASE>(OT::BASE const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table_try<OT::MATH>(OT::MATH const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::HVAR>(OT::HVAR const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::VVAR>(OT::VVAR const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::gvar>(OT::gvar const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::GVAR>(OT::GVAR const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::VARC>(OT::VARC const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::fvar>(OT::fvar const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::avar>(OT::avar const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::cvar>(OT::cvar const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table_try<OT::MVAR>(OT::MVAR const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-cff.cc:bool _hb_subset_table_try<OT::cff1_subset_accelerator_t>(OT::cff1_subset_accelerator_t const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-cff.cc:bool _hb_subset_table_try<OT::cff2_subset_accelerator_t>(OT::cff2_subset_accelerator_t const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-cff.cc:bool _hb_subset_table_try<OT::VORG>(OT::VORG const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-color.cc:bool _hb_subset_table_try<OT::sbix>(OT::sbix const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-color.cc:bool _hb_subset_table_try<OT::COLR>(OT::COLR const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-color.cc:bool _hb_subset_table_try<OT::CPAL>(OT::CPAL const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-color.cc:bool _hb_subset_table_try<OT::CBLC>(OT::CBLC const*, hb_vector_t<char, false>*, hb_subset_context_t*)
hb-subset-table-other.cc:bool _hb_subset_table_try<OT::glyf>(OT::glyf const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Line
Count
Source
42
16.7k
{
43
16.7k
  c->serializer->start_serialize ();
44
16.7k
  if (c->serializer->in_error ()) return false;
45
46
16.7k
  bool needed = table->subset (c);
47
16.7k
  if (!c->serializer->ran_out_of_room ())
48
16.7k
  {
49
16.7k
    c->serializer->end_serialize ();
50
16.7k
    return needed;
51
16.7k
  }
52
53
17
  unsigned buf_size = buf->allocated;
54
17
  buf_size = buf_size * 2 + 16;
55
56
57
58
59
17
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.",
60
17
             HB_UNTAG (c->table_tag), buf_size);
61
62
17
  if (unlikely (buf_size > c->source_blob->length * 256 ||
63
17
    !buf->alloc_exact (buf_size)))
64
0
  {
65
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.",
66
0
               HB_UNTAG (c->table_tag), buf_size);
67
0
    return needed;
68
0
  }
69
70
17
  c->serializer->reset (buf->arrayZ, buf->allocated);
71
17
  return _hb_subset_table_try (table, buf, c);
72
17
}
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table_try<OT::hdmx>(OT::hdmx const*, hb_vector_t<char, false>*, hb_subset_context_t*)
hb-subset-table-other.cc:bool _hb_subset_table_try<OT::name>(OT::name const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Line
Count
Source
42
12.3k
{
43
12.3k
  c->serializer->start_serialize ();
44
12.3k
  if (c->serializer->in_error ()) return false;
45
46
12.3k
  bool needed = table->subset (c);
47
12.3k
  if (!c->serializer->ran_out_of_room ())
48
12.3k
  {
49
12.3k
    c->serializer->end_serialize ();
50
12.3k
    return needed;
51
12.3k
  }
52
53
0
  unsigned buf_size = buf->allocated;
54
0
  buf_size = buf_size * 2 + 16;
55
56
57
58
59
0
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.",
60
0
             HB_UNTAG (c->table_tag), buf_size);
61
62
0
  if (unlikely (buf_size > c->source_blob->length * 256 ||
63
0
    !buf->alloc_exact (buf_size)))
64
0
  {
65
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.",
66
0
               HB_UNTAG (c->table_tag), buf_size);
67
0
    return needed;
68
0
  }
69
70
0
  c->serializer->reset (buf->arrayZ, buf->allocated);
71
0
  return _hb_subset_table_try (table, buf, c);
72
0
}
hb-subset-table-other.cc:bool _hb_subset_table_try<OT::hmtx>(OT::hmtx const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Line
Count
Source
42
14.6k
{
43
14.6k
  c->serializer->start_serialize ();
44
14.6k
  if (c->serializer->in_error ()) return false;
45
46
14.6k
  bool needed = table->subset (c);
47
14.6k
  if (!c->serializer->ran_out_of_room ())
48
14.6k
  {
49
14.6k
    c->serializer->end_serialize ();
50
14.6k
    return needed;
51
14.6k
  }
52
53
0
  unsigned buf_size = buf->allocated;
54
0
  buf_size = buf_size * 2 + 16;
55
56
57
58
59
0
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.",
60
0
             HB_UNTAG (c->table_tag), buf_size);
61
62
0
  if (unlikely (buf_size > c->source_blob->length * 256 ||
63
0
    !buf->alloc_exact (buf_size)))
64
0
  {
65
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.",
66
0
               HB_UNTAG (c->table_tag), buf_size);
67
0
    return needed;
68
0
  }
69
70
0
  c->serializer->reset (buf->arrayZ, buf->allocated);
71
0
  return _hb_subset_table_try (table, buf, c);
72
0
}
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table_try<OT::vmtx>(OT::vmtx const*, hb_vector_t<char, false>*, hb_subset_context_t*)
hb-subset-table-other.cc:bool _hb_subset_table_try<OT::maxp>(OT::maxp const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Line
Count
Source
42
14.6k
{
43
14.6k
  c->serializer->start_serialize ();
44
14.6k
  if (c->serializer->in_error ()) return false;
45
46
14.6k
  bool needed = table->subset (c);
47
14.6k
  if (!c->serializer->ran_out_of_room ())
48
14.6k
  {
49
14.6k
    c->serializer->end_serialize ();
50
14.6k
    return needed;
51
14.6k
  }
52
53
0
  unsigned buf_size = buf->allocated;
54
0
  buf_size = buf_size * 2 + 16;
55
56
57
58
59
0
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.",
60
0
             HB_UNTAG (c->table_tag), buf_size);
61
62
0
  if (unlikely (buf_size > c->source_blob->length * 256 ||
63
0
    !buf->alloc_exact (buf_size)))
64
0
  {
65
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.",
66
0
               HB_UNTAG (c->table_tag), buf_size);
67
0
    return needed;
68
0
  }
69
70
0
  c->serializer->reset (buf->arrayZ, buf->allocated);
71
0
  return _hb_subset_table_try (table, buf, c);
72
0
}
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table_try<OT::GLYF>(OT::GLYF const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table_try<OT::HMTX>(OT::HMTX const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table_try<OT::VMTX>(OT::VMTX const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table_try<OT::MAXP>(OT::MAXP const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table_try<OT::cmap>(OT::cmap const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table_try<OT::DMAP>(OT::DMAP const*, hb_vector_t<char, false>*, hb_subset_context_t*)
hb-subset-table-other.cc:bool _hb_subset_table_try<OT::OS2>(OT::OS2 const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Line
Count
Source
42
15.6k
{
43
15.6k
  c->serializer->start_serialize ();
44
15.6k
  if (c->serializer->in_error ()) return false;
45
46
15.6k
  bool needed = table->subset (c);
47
15.6k
  if (!c->serializer->ran_out_of_room ())
48
15.6k
  {
49
15.6k
    c->serializer->end_serialize ();
50
15.6k
    return needed;
51
15.6k
  }
52
53
0
  unsigned buf_size = buf->allocated;
54
0
  buf_size = buf_size * 2 + 16;
55
56
57
58
59
0
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.",
60
0
             HB_UNTAG (c->table_tag), buf_size);
61
62
0
  if (unlikely (buf_size > c->source_blob->length * 256 ||
63
0
    !buf->alloc_exact (buf_size)))
64
0
  {
65
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.",
66
0
               HB_UNTAG (c->table_tag), buf_size);
67
0
    return needed;
68
0
  }
69
70
0
  c->serializer->reset (buf->arrayZ, buf->allocated);
71
0
  return _hb_subset_table_try (table, buf, c);
72
0
}
hb-subset-table-other.cc:bool _hb_subset_table_try<OT::post>(OT::post const*, hb_vector_t<char, false>*, hb_subset_context_t*)
Line
Count
Source
42
11.3k
{
43
11.3k
  c->serializer->start_serialize ();
44
11.3k
  if (c->serializer->in_error ()) return false;
45
46
11.3k
  bool needed = table->subset (c);
47
11.3k
  if (!c->serializer->ran_out_of_room ())
48
11.3k
  {
49
11.3k
    c->serializer->end_serialize ();
50
11.3k
    return needed;
51
11.3k
  }
52
53
0
  unsigned buf_size = buf->allocated;
54
0
  buf_size = buf_size * 2 + 16;
55
56
57
58
59
0
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.",
60
0
             HB_UNTAG (c->table_tag), buf_size);
61
62
0
  if (unlikely (buf_size > c->source_blob->length * 256 ||
63
0
    !buf->alloc_exact (buf_size)))
64
0
  {
65
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to reallocate %u bytes.",
66
0
               HB_UNTAG (c->table_tag), buf_size);
67
0
    return needed;
68
0
  }
69
70
0
  c->serializer->reset (buf->arrayZ, buf->allocated);
71
0
  return _hb_subset_table_try (table, buf, c);
72
0
}
73
74
static HB_UNUSED unsigned
75
_hb_subset_estimate_table_size (hb_subset_plan_t *plan,
76
        unsigned table_len,
77
        hb_tag_t table_tag)
78
86.6k
{
79
86.6k
  unsigned src_glyphs = plan->source->get_num_glyphs ();
80
86.6k
  unsigned dst_glyphs = plan->glyphset ()->get_population ();
81
82
86.6k
  unsigned bulk = 8192;
83
  /* Tables that we want to allocate same space as the source table. For GSUB/GPOS it's
84
   * because those are expensive to subset, so giving them more room is fine. */
85
86.6k
  bool same_size = table_tag == HB_TAG('G','S','U','B') ||
86
86.6k
       table_tag == HB_TAG('G','P','O','S') ||
87
86.6k
       table_tag == HB_TAG('G','D','E','F') ||
88
86.6k
       table_tag == HB_TAG('n','a','m','e');
89
90
86.6k
  if (plan->flags & HB_SUBSET_FLAGS_RETAIN_GIDS)
91
0
  {
92
0
    if (table_tag == HB_TAG('C','F','F',' '))
93
0
    {
94
      /* Add some extra room for the CFF charset. */
95
0
      bulk += src_glyphs * 16;
96
0
    }
97
0
    else if (table_tag == HB_TAG('C','F','F','2'))
98
0
    {
99
      /* Just extra CharString offsets. */
100
0
      bulk += src_glyphs * 4;
101
0
    }
102
0
  }
103
104
86.6k
  if (unlikely (!src_glyphs) || same_size)
105
12.3k
    return bulk + table_len;
106
107
74.2k
  return bulk + (unsigned) (table_len * sqrt ((double) dst_glyphs / src_glyphs));
108
86.6k
}
hb-subset.cc:_hb_subset_estimate_table_size(hb_subset_plan_t*, unsigned int, unsigned int)
Line
Count
Source
78
1.19k
{
79
1.19k
  unsigned src_glyphs = plan->source->get_num_glyphs ();
80
1.19k
  unsigned dst_glyphs = plan->glyphset ()->get_population ();
81
82
1.19k
  unsigned bulk = 8192;
83
  /* Tables that we want to allocate same space as the source table. For GSUB/GPOS it's
84
   * because those are expensive to subset, so giving them more room is fine. */
85
1.19k
  bool same_size = table_tag == HB_TAG('G','S','U','B') ||
86
1.19k
       table_tag == HB_TAG('G','P','O','S') ||
87
1.19k
       table_tag == HB_TAG('G','D','E','F') ||
88
1.19k
       table_tag == HB_TAG('n','a','m','e');
89
90
1.19k
  if (plan->flags & HB_SUBSET_FLAGS_RETAIN_GIDS)
91
0
  {
92
0
    if (table_tag == HB_TAG('C','F','F',' '))
93
0
    {
94
      /* Add some extra room for the CFF charset. */
95
0
      bulk += src_glyphs * 16;
96
0
    }
97
0
    else if (table_tag == HB_TAG('C','F','F','2'))
98
0
    {
99
      /* Just extra CharString offsets. */
100
0
      bulk += src_glyphs * 4;
101
0
    }
102
0
  }
103
104
1.19k
  if (unlikely (!src_glyphs) || same_size)
105
0
    return bulk + table_len;
106
107
1.19k
  return bulk + (unsigned) (table_len * sqrt ((double) dst_glyphs / src_glyphs));
108
1.19k
}
Unexecuted instantiation: hb-subset-table-layout.cc:_hb_subset_estimate_table_size(hb_subset_plan_t*, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-table-var.cc:_hb_subset_estimate_table_size(hb_subset_plan_t*, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-table-cff.cc:_hb_subset_estimate_table_size(hb_subset_plan_t*, unsigned int, unsigned int)
Unexecuted instantiation: hb-subset-table-color.cc:_hb_subset_estimate_table_size(hb_subset_plan_t*, unsigned int, unsigned int)
hb-subset-table-other.cc:_hb_subset_estimate_table_size(hb_subset_plan_t*, unsigned int, unsigned int)
Line
Count
Source
78
85.4k
{
79
85.4k
  unsigned src_glyphs = plan->source->get_num_glyphs ();
80
85.4k
  unsigned dst_glyphs = plan->glyphset ()->get_population ();
81
82
85.4k
  unsigned bulk = 8192;
83
  /* Tables that we want to allocate same space as the source table. For GSUB/GPOS it's
84
   * because those are expensive to subset, so giving them more room is fine. */
85
85.4k
  bool same_size = table_tag == HB_TAG('G','S','U','B') ||
86
85.4k
       table_tag == HB_TAG('G','P','O','S') ||
87
85.4k
       table_tag == HB_TAG('G','D','E','F') ||
88
85.4k
       table_tag == HB_TAG('n','a','m','e');
89
90
85.4k
  if (plan->flags & HB_SUBSET_FLAGS_RETAIN_GIDS)
91
0
  {
92
0
    if (table_tag == HB_TAG('C','F','F',' '))
93
0
    {
94
      /* Add some extra room for the CFF charset. */
95
0
      bulk += src_glyphs * 16;
96
0
    }
97
0
    else if (table_tag == HB_TAG('C','F','F','2'))
98
0
    {
99
      /* Just extra CharString offsets. */
100
0
      bulk += src_glyphs * 4;
101
0
    }
102
0
  }
103
104
85.4k
  if (unlikely (!src_glyphs) || same_size)
105
12.3k
    return bulk + table_len;
106
107
73.1k
  return bulk + (unsigned) (table_len * sqrt ((double) dst_glyphs / src_glyphs));
108
85.4k
}
109
110
/*
111
 * Repack the serialization buffer if any offset overflows exist.
112
 */
113
static HB_UNUSED hb_blob_t*
114
_hb_subset_repack (hb_tag_t tag, const hb_serialize_context_t& c)
115
81.9k
{
116
81.9k
  if (!c.offset_overflow ())
117
81.9k
    return c.copy_blob ();
118
119
0
  hb_blob_t* result = hb_resolve_overflows (c.object_graph (), tag);
120
121
0
  if (unlikely (!result))
122
0
  {
123
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c offset overflow resolution failed.",
124
0
               HB_UNTAG (tag));
125
0
    return nullptr;
126
0
  }
127
128
0
  return result;
129
0
}
hb-subset.cc:_hb_subset_repack(unsigned int, hb_serialize_context_t const&)
Line
Count
Source
115
1.19k
{
116
1.19k
  if (!c.offset_overflow ())
117
1.19k
    return c.copy_blob ();
118
119
0
  hb_blob_t* result = hb_resolve_overflows (c.object_graph (), tag);
120
121
0
  if (unlikely (!result))
122
0
  {
123
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c offset overflow resolution failed.",
124
0
               HB_UNTAG (tag));
125
0
    return nullptr;
126
0
  }
127
128
0
  return result;
129
0
}
Unexecuted instantiation: hb-subset-table-layout.cc:_hb_subset_repack(unsigned int, hb_serialize_context_t const&)
Unexecuted instantiation: hb-subset-table-var.cc:_hb_subset_repack(unsigned int, hb_serialize_context_t const&)
Unexecuted instantiation: hb-subset-table-cff.cc:_hb_subset_repack(unsigned int, hb_serialize_context_t const&)
Unexecuted instantiation: hb-subset-table-color.cc:_hb_subset_repack(unsigned int, hb_serialize_context_t const&)
hb-subset-table-other.cc:_hb_subset_repack(unsigned int, hb_serialize_context_t const&)
Line
Count
Source
115
80.7k
{
116
80.7k
  if (!c.offset_overflow ())
117
80.7k
    return c.copy_blob ();
118
119
0
  hb_blob_t* result = hb_resolve_overflows (c.object_graph (), tag);
120
121
0
  if (unlikely (!result))
122
0
  {
123
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c offset overflow resolution failed.",
124
0
               HB_UNTAG (tag));
125
0
    return nullptr;
126
0
  }
127
128
0
  return result;
129
0
}
130
131
template <typename T>
132
static HB_UNUSED auto _hb_do_destroy (T &t, hb_priority<1>) HB_RETURN (void, t.destroy ())
133
134
template <typename T>
135
0
static HB_UNUSED void _hb_do_destroy (T &t, hb_priority<0>) {}
Unexecuted instantiation: hb-subset-table-cff.cc:void _hb_do_destroy<hb_face_lazy_loader_t<OT::cff1_subset_accelerator_t, 1u> >(hb_face_lazy_loader_t<OT::cff1_subset_accelerator_t, 1u>&, hb_priority<0u>)
Unexecuted instantiation: hb-subset-table-cff.cc:void _hb_do_destroy<hb_face_lazy_loader_t<OT::cff2_subset_accelerator_t, 2u> >(hb_face_lazy_loader_t<OT::cff2_subset_accelerator_t, 2u>&, hb_priority<0u>)
136
137
template<typename TableType>
138
static bool
139
_hb_subset_table (hb_subset_plan_t *plan, hb_vector_t<char> &buf)
140
91.1k
{
141
91.1k
  auto &&source_blob = plan->source_table<TableType> ();
142
91.1k
  auto *table = source_blob.get ();
143
144
91.1k
  hb_tag_t tag = TableType::tableTag;
145
91.1k
  hb_blob_t *blob = source_blob.get_blob();
146
91.1k
  if (unlikely (!blob || !blob->data))
147
4.57k
  {
148
4.57k
    DEBUG_MSG (SUBSET, nullptr,
149
4.57k
               "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
150
4.57k
    _hb_do_destroy (source_blob, hb_prioritize);
151
4.57k
    return false;
152
4.57k
  }
153
154
86.6k
  unsigned buf_size = _hb_subset_estimate_table_size (plan, blob->length, TableType::tableTag);
155
86.6k
  DEBUG_MSG (SUBSET, nullptr,
156
86.6k
             "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
157
86.6k
  if (unlikely (!buf.alloc (buf_size)))
158
0
  {
159
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
160
0
    _hb_do_destroy (source_blob, hb_prioritize);
161
0
    return false;
162
0
  }
163
164
86.6k
  bool needed = false;
165
86.6k
  hb_serialize_context_t serializer (buf.arrayZ, buf.allocated);
166
86.6k
  {
167
86.6k
    hb_subset_context_t c (blob, plan, &serializer, tag);
168
86.6k
    needed = _hb_subset_table_try (table, &buf, &c);
169
86.6k
  }
170
86.6k
  _hb_do_destroy (source_blob, hb_prioritize);
171
172
86.6k
  if (serializer.in_error () && !serializer.only_offset_overflow ())
173
3.21k
  {
174
3.21k
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset FAILED!", HB_UNTAG (tag));
175
3.21k
    return false;
176
3.21k
  }
177
178
83.4k
  if (!needed)
179
1.43k
  {
180
1.43k
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
181
1.43k
    return true;
182
1.43k
  }
183
184
81.9k
  bool result = false;
185
81.9k
  hb_blob_t *dest_blob = _hb_subset_repack (tag, serializer);
186
81.9k
  if (dest_blob)
187
81.9k
  {
188
81.9k
    DEBUG_MSG (SUBSET, nullptr,
189
81.9k
               "OT::%c%c%c%c final subset table size: %u bytes.",
190
81.9k
               HB_UNTAG (tag), dest_blob->length);
191
81.9k
    result = plan->add_table (tag, dest_blob);
192
81.9k
    hb_blob_destroy (dest_blob);
193
81.9k
  }
194
195
81.9k
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset %s",
196
81.9k
             HB_UNTAG (tag), result ? "success" : "FAILED!");
197
81.9k
  return result;
198
83.4k
}
hb-subset.cc:bool _hb_subset_table<OT::head const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Line
Count
Source
140
2.39k
{
141
2.39k
  auto &&source_blob = plan->source_table<TableType> ();
142
2.39k
  auto *table = source_blob.get ();
143
144
2.39k
  hb_tag_t tag = TableType::tableTag;
145
2.39k
  hb_blob_t *blob = source_blob.get_blob();
146
2.39k
  if (unlikely (!blob || !blob->data))
147
1.19k
  {
148
1.19k
    DEBUG_MSG (SUBSET, nullptr,
149
1.19k
               "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
150
1.19k
    _hb_do_destroy (source_blob, hb_prioritize);
151
1.19k
    return false;
152
1.19k
  }
153
154
1.19k
  unsigned buf_size = _hb_subset_estimate_table_size (plan, blob->length, TableType::tableTag);
155
1.19k
  DEBUG_MSG (SUBSET, nullptr,
156
1.19k
             "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
157
1.19k
  if (unlikely (!buf.alloc (buf_size)))
158
0
  {
159
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
160
0
    _hb_do_destroy (source_blob, hb_prioritize);
161
0
    return false;
162
0
  }
163
164
1.19k
  bool needed = false;
165
1.19k
  hb_serialize_context_t serializer (buf.arrayZ, buf.allocated);
166
1.19k
  {
167
1.19k
    hb_subset_context_t c (blob, plan, &serializer, tag);
168
1.19k
    needed = _hb_subset_table_try (table, &buf, &c);
169
1.19k
  }
170
1.19k
  _hb_do_destroy (source_blob, hb_prioritize);
171
172
1.19k
  if (serializer.in_error () && !serializer.only_offset_overflow ())
173
0
  {
174
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset FAILED!", HB_UNTAG (tag));
175
0
    return false;
176
0
  }
177
178
1.19k
  if (!needed)
179
0
  {
180
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
181
0
    return true;
182
0
  }
183
184
1.19k
  bool result = false;
185
1.19k
  hb_blob_t *dest_blob = _hb_subset_repack (tag, serializer);
186
1.19k
  if (dest_blob)
187
1.19k
  {
188
1.19k
    DEBUG_MSG (SUBSET, nullptr,
189
1.19k
               "OT::%c%c%c%c final subset table size: %u bytes.",
190
1.19k
               HB_UNTAG (tag), dest_blob->length);
191
1.19k
    result = plan->add_table (tag, dest_blob);
192
1.19k
    hb_blob_destroy (dest_blob);
193
1.19k
  }
194
195
1.19k
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset %s",
196
1.19k
             HB_UNTAG (tag), result ? "success" : "FAILED!");
197
1.19k
  return result;
198
1.19k
}
Unexecuted instantiation: hb-subset.cc:bool _hb_subset_table<OT::STAT const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table<OT::GDEF const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table<OT::Layout::GSUB const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table<OT::Layout::GPOS const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table<OT::BASE const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-layout.cc:bool _hb_subset_table<OT::MATH const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::HVAR const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::VVAR const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::gvar const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::GVAR const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::VARC const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::fvar const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::avar const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::cvar const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-var.cc:bool _hb_subset_table<OT::MVAR const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool _hb_subset_table<OT::cff1 const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool _hb_subset_table<OT::cff2 const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-cff.cc:bool _hb_subset_table<OT::VORG const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-color.cc:bool _hb_subset_table<OT::sbix const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-color.cc:bool _hb_subset_table<OT::COLR const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-color.cc:bool _hb_subset_table<OT::CPAL const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-color.cc:bool _hb_subset_table<OT::CBLC const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
hb-subset-table-other.cc:bool _hb_subset_table<OT::glyf const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Line
Count
Source
140
16.8k
{
141
16.8k
  auto &&source_blob = plan->source_table<TableType> ();
142
16.8k
  auto *table = source_blob.get ();
143
144
16.8k
  hb_tag_t tag = TableType::tableTag;
145
16.8k
  hb_blob_t *blob = source_blob.get_blob();
146
16.8k
  if (unlikely (!blob || !blob->data))
147
133
  {
148
133
    DEBUG_MSG (SUBSET, nullptr,
149
133
               "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
150
133
    _hb_do_destroy (source_blob, hb_prioritize);
151
133
    return false;
152
133
  }
153
154
16.7k
  unsigned buf_size = _hb_subset_estimate_table_size (plan, blob->length, TableType::tableTag);
155
16.7k
  DEBUG_MSG (SUBSET, nullptr,
156
16.7k
             "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
157
16.7k
  if (unlikely (!buf.alloc (buf_size)))
158
0
  {
159
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
160
0
    _hb_do_destroy (source_blob, hb_prioritize);
161
0
    return false;
162
0
  }
163
164
16.7k
  bool needed = false;
165
16.7k
  hb_serialize_context_t serializer (buf.arrayZ, buf.allocated);
166
16.7k
  {
167
16.7k
    hb_subset_context_t c (blob, plan, &serializer, tag);
168
16.7k
    needed = _hb_subset_table_try (table, &buf, &c);
169
16.7k
  }
170
16.7k
  _hb_do_destroy (source_blob, hb_prioritize);
171
172
16.7k
  if (serializer.in_error () && !serializer.only_offset_overflow ())
173
3.21k
  {
174
3.21k
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset FAILED!", HB_UNTAG (tag));
175
3.21k
    return false;
176
3.21k
  }
177
178
13.5k
  if (!needed)
179
249
  {
180
249
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
181
249
    return true;
182
249
  }
183
184
13.2k
  bool result = false;
185
13.2k
  hb_blob_t *dest_blob = _hb_subset_repack (tag, serializer);
186
13.2k
  if (dest_blob)
187
13.2k
  {
188
13.2k
    DEBUG_MSG (SUBSET, nullptr,
189
13.2k
               "OT::%c%c%c%c final subset table size: %u bytes.",
190
13.2k
               HB_UNTAG (tag), dest_blob->length);
191
13.2k
    result = plan->add_table (tag, dest_blob);
192
13.2k
    hb_blob_destroy (dest_blob);
193
13.2k
  }
194
195
13.2k
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset %s",
196
13.2k
             HB_UNTAG (tag), result ? "success" : "FAILED!");
197
13.2k
  return result;
198
13.5k
}
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table<OT::hdmx const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
hb-subset-table-other.cc:bool _hb_subset_table<OT::name const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Line
Count
Source
140
13.9k
{
141
13.9k
  auto &&source_blob = plan->source_table<TableType> ();
142
13.9k
  auto *table = source_blob.get ();
143
144
13.9k
  hb_tag_t tag = TableType::tableTag;
145
13.9k
  hb_blob_t *blob = source_blob.get_blob();
146
13.9k
  if (unlikely (!blob || !blob->data))
147
1.67k
  {
148
1.67k
    DEBUG_MSG (SUBSET, nullptr,
149
1.67k
               "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
150
1.67k
    _hb_do_destroy (source_blob, hb_prioritize);
151
1.67k
    return false;
152
1.67k
  }
153
154
12.3k
  unsigned buf_size = _hb_subset_estimate_table_size (plan, blob->length, TableType::tableTag);
155
12.3k
  DEBUG_MSG (SUBSET, nullptr,
156
12.3k
             "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
157
12.3k
  if (unlikely (!buf.alloc (buf_size)))
158
0
  {
159
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
160
0
    _hb_do_destroy (source_blob, hb_prioritize);
161
0
    return false;
162
0
  }
163
164
12.3k
  bool needed = false;
165
12.3k
  hb_serialize_context_t serializer (buf.arrayZ, buf.allocated);
166
12.3k
  {
167
12.3k
    hb_subset_context_t c (blob, plan, &serializer, tag);
168
12.3k
    needed = _hb_subset_table_try (table, &buf, &c);
169
12.3k
  }
170
12.3k
  _hb_do_destroy (source_blob, hb_prioritize);
171
172
12.3k
  if (serializer.in_error () && !serializer.only_offset_overflow ())
173
0
  {
174
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset FAILED!", HB_UNTAG (tag));
175
0
    return false;
176
0
  }
177
178
12.3k
  if (!needed)
179
0
  {
180
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
181
0
    return true;
182
0
  }
183
184
12.3k
  bool result = false;
185
12.3k
  hb_blob_t *dest_blob = _hb_subset_repack (tag, serializer);
186
12.3k
  if (dest_blob)
187
12.3k
  {
188
12.3k
    DEBUG_MSG (SUBSET, nullptr,
189
12.3k
               "OT::%c%c%c%c final subset table size: %u bytes.",
190
12.3k
               HB_UNTAG (tag), dest_blob->length);
191
12.3k
    result = plan->add_table (tag, dest_blob);
192
12.3k
    hb_blob_destroy (dest_blob);
193
12.3k
  }
194
195
12.3k
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset %s",
196
12.3k
             HB_UNTAG (tag), result ? "success" : "FAILED!");
197
12.3k
  return result;
198
12.3k
}
hb-subset-table-other.cc:bool _hb_subset_table<OT::hmtx const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Line
Count
Source
140
14.6k
{
141
14.6k
  auto &&source_blob = plan->source_table<TableType> ();
142
14.6k
  auto *table = source_blob.get ();
143
144
14.6k
  hb_tag_t tag = TableType::tableTag;
145
14.6k
  hb_blob_t *blob = source_blob.get_blob();
146
14.6k
  if (unlikely (!blob || !blob->data))
147
16
  {
148
16
    DEBUG_MSG (SUBSET, nullptr,
149
16
               "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
150
16
    _hb_do_destroy (source_blob, hb_prioritize);
151
16
    return false;
152
16
  }
153
154
14.6k
  unsigned buf_size = _hb_subset_estimate_table_size (plan, blob->length, TableType::tableTag);
155
14.6k
  DEBUG_MSG (SUBSET, nullptr,
156
14.6k
             "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
157
14.6k
  if (unlikely (!buf.alloc (buf_size)))
158
0
  {
159
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
160
0
    _hb_do_destroy (source_blob, hb_prioritize);
161
0
    return false;
162
0
  }
163
164
14.6k
  bool needed = false;
165
14.6k
  hb_serialize_context_t serializer (buf.arrayZ, buf.allocated);
166
14.6k
  {
167
14.6k
    hb_subset_context_t c (blob, plan, &serializer, tag);
168
14.6k
    needed = _hb_subset_table_try (table, &buf, &c);
169
14.6k
  }
170
14.6k
  _hb_do_destroy (source_blob, hb_prioritize);
171
172
14.6k
  if (serializer.in_error () && !serializer.only_offset_overflow ())
173
0
  {
174
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset FAILED!", HB_UNTAG (tag));
175
0
    return false;
176
0
  }
177
178
14.6k
  if (!needed)
179
1.18k
  {
180
1.18k
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
181
1.18k
    return true;
182
1.18k
  }
183
184
13.4k
  bool result = false;
185
13.4k
  hb_blob_t *dest_blob = _hb_subset_repack (tag, serializer);
186
13.4k
  if (dest_blob)
187
13.4k
  {
188
13.4k
    DEBUG_MSG (SUBSET, nullptr,
189
13.4k
               "OT::%c%c%c%c final subset table size: %u bytes.",
190
13.4k
               HB_UNTAG (tag), dest_blob->length);
191
13.4k
    result = plan->add_table (tag, dest_blob);
192
13.4k
    hb_blob_destroy (dest_blob);
193
13.4k
  }
194
195
13.4k
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset %s",
196
13.4k
             HB_UNTAG (tag), result ? "success" : "FAILED!");
197
13.4k
  return result;
198
14.6k
}
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table<OT::vmtx const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
hb-subset-table-other.cc:bool _hb_subset_table<OT::maxp const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Line
Count
Source
140
14.6k
{
141
14.6k
  auto &&source_blob = plan->source_table<TableType> ();
142
14.6k
  auto *table = source_blob.get ();
143
144
14.6k
  hb_tag_t tag = TableType::tableTag;
145
14.6k
  hb_blob_t *blob = source_blob.get_blob();
146
14.6k
  if (unlikely (!blob || !blob->data))
147
0
  {
148
0
    DEBUG_MSG (SUBSET, nullptr,
149
0
               "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
150
0
    _hb_do_destroy (source_blob, hb_prioritize);
151
0
    return false;
152
0
  }
153
154
14.6k
  unsigned buf_size = _hb_subset_estimate_table_size (plan, blob->length, TableType::tableTag);
155
14.6k
  DEBUG_MSG (SUBSET, nullptr,
156
14.6k
             "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
157
14.6k
  if (unlikely (!buf.alloc (buf_size)))
158
0
  {
159
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
160
0
    _hb_do_destroy (source_blob, hb_prioritize);
161
0
    return false;
162
0
  }
163
164
14.6k
  bool needed = false;
165
14.6k
  hb_serialize_context_t serializer (buf.arrayZ, buf.allocated);
166
14.6k
  {
167
14.6k
    hb_subset_context_t c (blob, plan, &serializer, tag);
168
14.6k
    needed = _hb_subset_table_try (table, &buf, &c);
169
14.6k
  }
170
14.6k
  _hb_do_destroy (source_blob, hb_prioritize);
171
172
14.6k
  if (serializer.in_error () && !serializer.only_offset_overflow ())
173
0
  {
174
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset FAILED!", HB_UNTAG (tag));
175
0
    return false;
176
0
  }
177
178
14.6k
  if (!needed)
179
0
  {
180
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
181
0
    return true;
182
0
  }
183
184
14.6k
  bool result = false;
185
14.6k
  hb_blob_t *dest_blob = _hb_subset_repack (tag, serializer);
186
14.6k
  if (dest_blob)
187
14.6k
  {
188
14.6k
    DEBUG_MSG (SUBSET, nullptr,
189
14.6k
               "OT::%c%c%c%c final subset table size: %u bytes.",
190
14.6k
               HB_UNTAG (tag), dest_blob->length);
191
14.6k
    result = plan->add_table (tag, dest_blob);
192
14.6k
    hb_blob_destroy (dest_blob);
193
14.6k
  }
194
195
14.6k
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset %s",
196
14.6k
             HB_UNTAG (tag), result ? "success" : "FAILED!");
197
14.6k
  return result;
198
14.6k
}
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table<OT::GLYF const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table<OT::HMTX const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table<OT::VMTX const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table<OT::MAXP const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table<OT::cmap const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Unexecuted instantiation: hb-subset-table-other.cc:bool _hb_subset_table<OT::DMAP const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
hb-subset-table-other.cc:bool _hb_subset_table<OT::OS2 const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Line
Count
Source
140
16.7k
{
141
16.7k
  auto &&source_blob = plan->source_table<TableType> ();
142
16.7k
  auto *table = source_blob.get ();
143
144
16.7k
  hb_tag_t tag = TableType::tableTag;
145
16.7k
  hb_blob_t *blob = source_blob.get_blob();
146
16.7k
  if (unlikely (!blob || !blob->data))
147
1.08k
  {
148
1.08k
    DEBUG_MSG (SUBSET, nullptr,
149
1.08k
               "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
150
1.08k
    _hb_do_destroy (source_blob, hb_prioritize);
151
1.08k
    return false;
152
1.08k
  }
153
154
15.6k
  unsigned buf_size = _hb_subset_estimate_table_size (plan, blob->length, TableType::tableTag);
155
15.6k
  DEBUG_MSG (SUBSET, nullptr,
156
15.6k
             "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
157
15.6k
  if (unlikely (!buf.alloc (buf_size)))
158
0
  {
159
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
160
0
    _hb_do_destroy (source_blob, hb_prioritize);
161
0
    return false;
162
0
  }
163
164
15.6k
  bool needed = false;
165
15.6k
  hb_serialize_context_t serializer (buf.arrayZ, buf.allocated);
166
15.6k
  {
167
15.6k
    hb_subset_context_t c (blob, plan, &serializer, tag);
168
15.6k
    needed = _hb_subset_table_try (table, &buf, &c);
169
15.6k
  }
170
15.6k
  _hb_do_destroy (source_blob, hb_prioritize);
171
172
15.6k
  if (serializer.in_error () && !serializer.only_offset_overflow ())
173
0
  {
174
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset FAILED!", HB_UNTAG (tag));
175
0
    return false;
176
0
  }
177
178
15.6k
  if (!needed)
179
0
  {
180
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
181
0
    return true;
182
0
  }
183
184
15.6k
  bool result = false;
185
15.6k
  hb_blob_t *dest_blob = _hb_subset_repack (tag, serializer);
186
15.6k
  if (dest_blob)
187
15.6k
  {
188
15.6k
    DEBUG_MSG (SUBSET, nullptr,
189
15.6k
               "OT::%c%c%c%c final subset table size: %u bytes.",
190
15.6k
               HB_UNTAG (tag), dest_blob->length);
191
15.6k
    result = plan->add_table (tag, dest_blob);
192
15.6k
    hb_blob_destroy (dest_blob);
193
15.6k
  }
194
195
15.6k
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset %s",
196
15.6k
             HB_UNTAG (tag), result ? "success" : "FAILED!");
197
15.6k
  return result;
198
15.6k
}
hb-subset-table-other.cc:bool _hb_subset_table<OT::post const>(hb_subset_plan_t*, hb_vector_t<char, false>&)
Line
Count
Source
140
11.8k
{
141
11.8k
  auto &&source_blob = plan->source_table<TableType> ();
142
11.8k
  auto *table = source_blob.get ();
143
144
11.8k
  hb_tag_t tag = TableType::tableTag;
145
11.8k
  hb_blob_t *blob = source_blob.get_blob();
146
11.8k
  if (unlikely (!blob || !blob->data))
147
462
  {
148
462
    DEBUG_MSG (SUBSET, nullptr,
149
462
               "OT::%c%c%c%c::subset sanitize failed on source table.", HB_UNTAG (tag));
150
462
    _hb_do_destroy (source_blob, hb_prioritize);
151
462
    return false;
152
462
  }
153
154
11.3k
  unsigned buf_size = _hb_subset_estimate_table_size (plan, blob->length, TableType::tableTag);
155
11.3k
  DEBUG_MSG (SUBSET, nullptr,
156
11.3k
             "OT::%c%c%c%c initial estimated table size: %u bytes.", HB_UNTAG (tag), buf_size);
157
11.3k
  if (unlikely (!buf.alloc (buf_size)))
158
0
  {
159
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c failed to allocate %u bytes.", HB_UNTAG (tag), buf_size);
160
0
    _hb_do_destroy (source_blob, hb_prioritize);
161
0
    return false;
162
0
  }
163
164
11.3k
  bool needed = false;
165
11.3k
  hb_serialize_context_t serializer (buf.arrayZ, buf.allocated);
166
11.3k
  {
167
11.3k
    hb_subset_context_t c (blob, plan, &serializer, tag);
168
11.3k
    needed = _hb_subset_table_try (table, &buf, &c);
169
11.3k
  }
170
11.3k
  _hb_do_destroy (source_blob, hb_prioritize);
171
172
11.3k
  if (serializer.in_error () && !serializer.only_offset_overflow ())
173
0
  {
174
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset FAILED!", HB_UNTAG (tag));
175
0
    return false;
176
0
  }
177
178
11.3k
  if (!needed)
179
0
  {
180
0
    DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset table subsetted to empty.", HB_UNTAG (tag));
181
0
    return true;
182
0
  }
183
184
11.3k
  bool result = false;
185
11.3k
  hb_blob_t *dest_blob = _hb_subset_repack (tag, serializer);
186
11.3k
  if (dest_blob)
187
11.3k
  {
188
11.3k
    DEBUG_MSG (SUBSET, nullptr,
189
11.3k
               "OT::%c%c%c%c final subset table size: %u bytes.",
190
11.3k
               HB_UNTAG (tag), dest_blob->length);
191
11.3k
    result = plan->add_table (tag, dest_blob);
192
11.3k
    hb_blob_destroy (dest_blob);
193
11.3k
  }
194
195
11.3k
  DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c::subset %s",
196
11.3k
             HB_UNTAG (tag), result ? "success" : "FAILED!");
197
11.3k
  return result;
198
11.3k
}
199
200
static HB_UNUSED bool
201
_hb_subset_table_passthrough (hb_subset_plan_t *plan, hb_tag_t tag)
202
35.2k
{
203
35.2k
  hb_blob_t *source_table = hb_face_reference_table (plan->source, tag);
204
35.2k
  bool result = plan->add_table (tag, source_table);
205
35.2k
  hb_blob_destroy (source_table);
206
35.2k
  return result;
207
35.2k
}
hb-subset.cc:_hb_subset_table_passthrough(hb_subset_plan_t*, unsigned int)
Line
Count
Source
202
35.2k
{
203
35.2k
  hb_blob_t *source_table = hb_face_reference_table (plan->source, tag);
204
35.2k
  bool result = plan->add_table (tag, source_table);
205
35.2k
  hb_blob_destroy (source_table);
206
35.2k
  return result;
207
35.2k
}
Unexecuted instantiation: hb-subset-table-layout.cc:_hb_subset_table_passthrough(hb_subset_plan_t*, unsigned int)
Unexecuted instantiation: hb-subset-table-var.cc:_hb_subset_table_passthrough(hb_subset_plan_t*, unsigned int)
Unexecuted instantiation: hb-subset-table-cff.cc:_hb_subset_table_passthrough(hb_subset_plan_t*, unsigned int)
Unexecuted instantiation: hb-subset-table-color.cc:_hb_subset_table_passthrough(hb_subset_plan_t*, unsigned int)
Unexecuted instantiation: hb-subset-table-other.cc:_hb_subset_table_passthrough(hb_subset_plan_t*, unsigned int)
208
209
210
HB_INTERNAL bool _hb_subset_table_layout  (hb_subset_plan_t *plan, hb_vector_t<char> &buf, hb_tag_t tag, bool *success);
211
HB_INTERNAL bool _hb_subset_table_var   (hb_subset_plan_t *plan, hb_vector_t<char> &buf, hb_tag_t tag, bool *success);
212
HB_INTERNAL bool _hb_subset_table_cff   (hb_subset_plan_t *plan, hb_vector_t<char> &buf, hb_tag_t tag, bool *success);
213
HB_INTERNAL bool _hb_subset_table_color   (hb_subset_plan_t *plan, hb_vector_t<char> &buf, hb_tag_t tag, bool *success);
214
HB_INTERNAL bool _hb_subset_table_other   (hb_subset_plan_t *plan, hb_vector_t<char> &buf, hb_tag_t tag, bool *success);
215
216
217
#endif /* HB_SUBSET_TABLE_HH */