Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 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 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 29 | #ifndef HB_FACE_HH |
| 30 | #define HB_FACE_HH |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 31 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 32 | #include "hb.hh" |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 33 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 34 | #include "hb-shaper.hh" |
| 35 | #include "hb-shape-plan.hh" |
Behdad Esfahbod | 914b595 | 2018-11-05 22:39:50 -0500 | [diff] [blame] | 36 | #include "hb-ot-face.hh" |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 37 | |
| 38 | |
| 39 | /* |
| 40 | * hb_face_t |
| 41 | */ |
| 42 | |
Behdad Esfahbod | ce5da0f | 2018-11-16 02:29:13 -0500 | [diff] [blame] | 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 | |
Behdad Esfahbod | 3506672 | 2018-08-06 06:17:48 -0700 | [diff] [blame] | 47 | struct hb_face_t |
| 48 | { |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 49 | hb_object_header_t header; |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 50 | |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 51 | hb_reference_table_func_t reference_table_func; |
| 52 | void *user_data; |
| 53 | hb_destroy_func_t destroy; |
| 54 | |
Behdad Esfahbod | 29fb0cb | 2017-01-09 21:18:55 -0800 | [diff] [blame] | 55 | unsigned int index; /* Face index in a collection, zero-based. */ |
Behdad Esfahbod | fc44dea | 2018-11-13 11:54:33 -0500 | [diff] [blame] | 56 | mutable hb_atomic_int_t upem; /* Units-per-EM. */ |
| 57 | mutable hb_atomic_int_t num_glyphs; /* Number of glyphs. */ |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 58 | |
Behdad Esfahbod | ce5da0f | 2018-11-16 02:29:13 -0500 | [diff] [blame] | 59 | hb_shaper_object_dataset_t<hb_face_t> data;/* Various shaper data. */ |
Behdad Esfahbod | e88d47b | 2018-11-11 16:25:43 -0500 | [diff] [blame] | 60 | hb_ot_face_t table; /* All the face's tables. */ |
Behdad Esfahbod | 914b595 | 2018-11-05 22:39:50 -0500 | [diff] [blame] | 61 | |
Behdad Esfahbod | 29fb0cb | 2017-01-09 21:18:55 -0800 | [diff] [blame] | 62 | /* Cache */ |
Behdad Esfahbod | 52fbd23 | 2018-08-03 16:22:16 -0700 | [diff] [blame] | 63 | struct plan_node_t |
| 64 | { |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 65 | hb_shape_plan_t *shape_plan; |
| 66 | plan_node_t *next; |
Behdad Esfahbod | 1f73809 | 2018-08-09 00:22:37 -0700 | [diff] [blame] | 67 | }; |
| 68 | hb_atomic_ptr_t<plan_node_t> shape_plans; |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 69 | |
Ebrahim Byagowi | b2ebaa9 | 2018-12-16 22:38:10 +0330 | [diff] [blame] | 70 | hb_blob_t *reference_table (hb_tag_t tag) const |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 71 | { |
| 72 | hb_blob_t *blob; |
| 73 | |
Behdad Esfahbod | cc3b2d4 | 2014-08-14 12:59:16 -0400 | [diff] [blame] | 74 | if (unlikely (!reference_table_func)) |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 75 | 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 Byagowi | e412008 | 2018-12-17 21:31:01 +0330 | [diff] [blame] | 84 | HB_PURE_FUNC unsigned int get_upem () const |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 85 | { |
Behdad Esfahbod | fc44dea | 2018-11-13 11:54:33 -0500 | [diff] [blame] | 86 | unsigned int ret = upem.get_relaxed (); |
| 87 | if (unlikely (!ret)) |
| 88 | { |
| 89 | return load_upem (); |
| 90 | } |
| 91 | return ret; |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 92 | } |
| 93 | |
Ebrahim Byagowi | e412008 | 2018-12-17 21:31:01 +0330 | [diff] [blame] | 94 | unsigned int get_num_glyphs () const |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 95 | { |
Behdad Esfahbod | fc44dea | 2018-11-13 11:54:33 -0500 | [diff] [blame] | 96 | unsigned int ret = num_glyphs.get_relaxed (); |
| 97 | if (unlikely (ret == (unsigned int) -1)) |
| 98 | return load_num_glyphs (); |
| 99 | return ret; |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | private: |
Ebrahim Byagowi | e412008 | 2018-12-17 21:31:01 +0330 | [diff] [blame] | 103 | HB_INTERNAL unsigned int load_upem () const; |
| 104 | HB_INTERNAL unsigned int load_num_glyphs () const; |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 105 | }; |
Behdad Esfahbod | 3506672 | 2018-08-06 06:17:48 -0700 | [diff] [blame] | 106 | DECLARE_NULL_INSTANCE (hb_face_t); |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 107 | |
Behdad Esfahbod | 2e3a07a | 2013-08-26 18:49:07 -0400 | [diff] [blame] | 108 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 109 | #endif /* HB_FACE_HH */ |