Coverage Report

Created: 2025-07-07 10:01

/work/workdir/UnpackedTarball/harfbuzz/src/hb-face.hh
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright © 2009  Red Hat, Inc.
3
 * Copyright © 2011  Google, Inc.
4
 *
5
 *  This is part of HarfBuzz, a text shaping library.
6
 *
7
 * Permission is hereby granted, without written agreement and without
8
 * license or royalty fees, to use, copy, modify, and distribute this
9
 * software and its documentation for any purpose, provided that the
10
 * above copyright notice and the following two paragraphs appear in
11
 * all copies of this software.
12
 *
13
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17
 * DAMAGE.
18
 *
19
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24
 *
25
 * Red Hat Author(s): Behdad Esfahbod
26
 * Google Author(s): Behdad Esfahbod
27
 */
28
29
#ifndef HB_FACE_HH
30
#define HB_FACE_HH
31
32
#include "hb.hh"
33
34
#include "hb-shaper.hh"
35
#include "hb-shape-plan.hh"
36
#include "hb-ot-face.hh"
37
38
39
/*
40
 * hb_face_t
41
 */
42
43
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INSTANTIATE_SHAPERS(shaper, face);
44
#include "hb-shaper-list.hh"
45
#undef HB_SHAPER_IMPLEMENT
46
47
struct hb_face_t
48
{
49
  hb_object_header_t header;
50
51
  unsigned int index;     /* Face index in a collection, zero-based. */
52
  mutable hb_atomic_t<unsigned> upem; /* Units-per-EM. */
53
  mutable hb_atomic_t<unsigned> num_glyphs;/* Number of glyphs. */
54
55
  hb_reference_table_func_t  reference_table_func;
56
  void                      *user_data;
57
  hb_destroy_func_t          destroy;
58
59
  hb_get_table_tags_func_t   get_table_tags_func;
60
  void                      *get_table_tags_user_data;
61
  hb_destroy_func_t          get_table_tags_destroy;
62
63
  hb_shaper_object_dataset_t<hb_face_t> data;/* Various shaper data. */
64
  hb_ot_face_t table;     /* All the face's tables. */
65
66
  /* Cache */
67
  struct plan_node_t
68
  {
69
    hb_shape_plan_t *shape_plan;
70
    plan_node_t *next;
71
  };
72
#ifndef HB_NO_SHAPER
73
  hb_atomic_t<plan_node_t *> shape_plans;
74
#endif
75
76
  hb_blob_t *reference_table (hb_tag_t tag) const
77
55.6M
  {
78
55.6M
    hb_blob_t *blob;
79
80
55.6M
    if (unlikely (!reference_table_func))
81
0
      return hb_blob_get_empty ();
82
83
55.6M
    blob = reference_table_func (/*Oh, well.*/const_cast<hb_face_t *> (this), tag, user_data);
84
55.6M
    if (unlikely (!blob))
85
0
      return hb_blob_get_empty ();
86
87
55.6M
    return blob;
88
55.6M
  }
89
90
  unsigned int get_upem () const
91
43.6M
  {
92
43.6M
    unsigned int ret = upem;
93
43.6M
    if (unlikely (!ret))
94
60
    {
95
60
      return load_upem ();
96
60
    }
97
43.6M
    return ret;
98
43.6M
  }
99
100
  unsigned int get_num_glyphs () const
101
50.6M
  {
102
50.6M
    unsigned int ret = num_glyphs;
103
50.6M
    if (unlikely (ret == UINT_MAX))
104
60
      return load_num_glyphs ();
105
50.6M
    return ret;
106
50.6M
  }
107
108
  private:
109
  HB_INTERNAL unsigned int load_upem () const;
110
  HB_INTERNAL unsigned int load_num_glyphs () const;
111
};
112
DECLARE_NULL_INSTANCE (hb_face_t);
113
114
115
#endif /* HB_FACE_HH */