blob: eb0e850aa87a6c45dfc619962bf2c1fa620cbf84 [file] [log] [blame]
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -04001/*
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_PRIVATE_HH
30#define HB_FACE_PRIVATE_HH
31
32#include "hb-private.hh"
33
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040034#include "hb-object-private.hh"
35#include "hb-shaper-private.hh"
36#include "hb-shape-plan-private.hh"
37
38
39/*
40 * hb_face_t
41 */
42
43struct hb_face_t {
44 hb_object_header_t header;
45 ASSERT_POD ();
46
47 hb_bool_t immutable;
48
49 hb_reference_table_func_t reference_table_func;
50 void *user_data;
51 hb_destroy_func_t destroy;
52
Behdad Esfahbod29fb0cb2017-01-09 21:18:55 -080053 unsigned int index; /* Face index in a collection, zero-based. */
54 mutable unsigned int upem; /* Units-per-EM. */
55 mutable unsigned int num_glyphs; /* Number of glyphs. */
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040056
Behdad Esfahbodd3d36912017-02-03 15:42:03 -080057 enum dirty_t {
58 NOTHING = 0x0000,
59 INDEX = 0x0001,
60 UPEM = 0x0002,
61 NUM_GLYPHS = 0x0004,
62 } dirty;
63
Behdad Esfahbod29fb0cb2017-01-09 21:18:55 -080064 struct hb_shaper_data_t shaper_data; /* Various shaper data. */
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040065
Behdad Esfahbod29fb0cb2017-01-09 21:18:55 -080066 /* Various non-shaping data. */
67 /* ... */
68
69 /* Cache */
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040070 struct plan_node_t {
71 hb_shape_plan_t *shape_plan;
72 plan_node_t *next;
73 } *shape_plans;
74
75
76 inline hb_blob_t *reference_table (hb_tag_t tag) const
77 {
78 hb_blob_t *blob;
79
Behdad Esfahbodcc3b2d42014-08-14 12:59:16 -040080 if (unlikely (!reference_table_func))
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040081 return hb_blob_get_empty ();
82
83 blob = reference_table_func (/*XXX*/const_cast<hb_face_t *> (this), tag, user_data);
84 if (unlikely (!blob))
85 return hb_blob_get_empty ();
86
87 return blob;
88 }
89
90 inline HB_PURE_FUNC unsigned int get_upem (void) const
91 {
92 if (unlikely (!upem))
93 load_upem ();
94 return upem;
95 }
96
97 inline unsigned int get_num_glyphs (void) const
98 {
99 if (unlikely (num_glyphs == (unsigned int) -1))
100 load_num_glyphs ();
101 return num_glyphs;
102 }
103
104 private:
105 HB_INTERNAL void load_upem (void) const;
106 HB_INTERNAL void load_num_glyphs (void) const;
107};
108
Behdad Esfahbodd3d36912017-02-03 15:42:03 -0800109HB_MARK_AS_FLAG_T (hb_face_t::dirty_t);
110
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -0400111extern HB_INTERNAL const hb_face_t _hb_face_nil;
112
113#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
114#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face);
115#include "hb-shaper-list.hh"
116#undef HB_SHAPER_IMPLEMENT
117#undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
118
119
120#endif /* HB_FACE_PRIVATE_HH */