blob: 68834baeb838b6b59cc8e4dc719146c5ea047b46 [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
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070029#ifndef HB_FACE_HH
30#define HB_FACE_HH
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040031
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070032#include "hb.hh"
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040033
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070034#include "hb-shaper.hh"
35#include "hb-shape-plan.hh"
Behdad Esfahbod914b5952018-11-05 22:39:50 -050036#include "hb-ot-face.hh"
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040037
38
39/*
40 * hb_face_t
41 */
42
Behdad Esfahbodce5da0f2018-11-16 02:29:13 -050043#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INSTANTIATE_SHAPERS(shaper, face);
44#include "hb-shaper-list.hh"
45#undef HB_SHAPER_IMPLEMENT
46
Behdad Esfahbod35066722018-08-06 06:17:48 -070047struct hb_face_t
48{
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040049 hb_object_header_t header;
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040050
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040051 hb_reference_table_func_t reference_table_func;
52 void *user_data;
53 hb_destroy_func_t destroy;
54
Behdad Esfahbod29fb0cb2017-01-09 21:18:55 -080055 unsigned int index; /* Face index in a collection, zero-based. */
Behdad Esfahbodfc44dea2018-11-13 11:54:33 -050056 mutable hb_atomic_int_t upem; /* Units-per-EM. */
57 mutable hb_atomic_int_t num_glyphs; /* Number of glyphs. */
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040058
Behdad Esfahbodce5da0f2018-11-16 02:29:13 -050059 hb_shaper_object_dataset_t<hb_face_t> data;/* Various shaper data. */
Behdad Esfahbode88d47b2018-11-11 16:25:43 -050060 hb_ot_face_t table; /* All the face's tables. */
Behdad Esfahbod914b5952018-11-05 22:39:50 -050061
Behdad Esfahbod29fb0cb2017-01-09 21:18:55 -080062 /* Cache */
Behdad Esfahbod52fbd232018-08-03 16:22:16 -070063 struct plan_node_t
64 {
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040065 hb_shape_plan_t *shape_plan;
66 plan_node_t *next;
Behdad Esfahbod1f738092018-08-09 00:22:37 -070067 };
68 hb_atomic_ptr_t<plan_node_t> shape_plans;
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040069
Ebrahim Byagowib2ebaa92018-12-16 22:38:10 +033070 hb_blob_t *reference_table (hb_tag_t tag) const
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040071 {
72 hb_blob_t *blob;
73
Behdad Esfahbodcc3b2d42014-08-14 12:59:16 -040074 if (unlikely (!reference_table_func))
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040075 return hb_blob_get_empty ();
76
77 blob = reference_table_func (/*XXX*/const_cast<hb_face_t *> (this), tag, user_data);
78 if (unlikely (!blob))
79 return hb_blob_get_empty ();
80
81 return blob;
82 }
83
Ebrahim Byagowie4120082018-12-17 21:31:01 +033084 HB_PURE_FUNC unsigned int get_upem () const
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040085 {
Behdad Esfahbodfc44dea2018-11-13 11:54:33 -050086 unsigned int ret = upem.get_relaxed ();
87 if (unlikely (!ret))
88 {
89 return load_upem ();
90 }
91 return ret;
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040092 }
93
Ebrahim Byagowie4120082018-12-17 21:31:01 +033094 unsigned int get_num_glyphs () const
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -040095 {
Behdad Esfahbodfc44dea2018-11-13 11:54:33 -050096 unsigned int ret = num_glyphs.get_relaxed ();
97 if (unlikely (ret == (unsigned int) -1))
98 return load_num_glyphs ();
99 return ret;
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -0400100 }
101
102 private:
Ebrahim Byagowie4120082018-12-17 21:31:01 +0330103 HB_INTERNAL unsigned int load_upem () const;
104 HB_INTERNAL unsigned int load_num_glyphs () const;
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -0400105};
Behdad Esfahbod35066722018-08-06 06:17:48 -0700106DECLARE_NULL_INSTANCE (hb_face_t);
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -0400107
Behdad Esfahbod2e3a07a2013-08-26 18:49:07 -0400108
Behdad Esfahbodc77ae402018-08-25 22:36:36 -0700109#endif /* HB_FACE_HH */