Behdad Esfahbod | a806762 | 2010-10-08 19:18:40 -0400 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 2 | * Copyright © 2010 Google, Inc. |
Behdad Esfahbod | a806762 | 2010-10-08 19:18:40 -0400 | [diff] [blame] | 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): Behdad Esfahbod |
| 25 | */ |
| 26 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 27 | #ifndef HB_OT_SHAPE_HH |
| 28 | #define HB_OT_SHAPE_HH |
Behdad Esfahbod | a806762 | 2010-10-08 19:18:40 -0400 | [diff] [blame] | 29 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 30 | #include "hb.hh" |
Behdad Esfahbod | a806762 | 2010-10-08 19:18:40 -0400 | [diff] [blame] | 31 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 32 | #include "hb-ot-map.hh" |
Behdad Esfahbod | ffe3478 | 2018-10-23 14:14:03 -0700 | [diff] [blame] | 33 | #include "hb-aat-map.hh" |
Behdad Esfahbod | a806762 | 2010-10-08 19:18:40 -0400 | [diff] [blame] | 34 | |
Behdad Esfahbod | a806762 | 2010-10-08 19:18:40 -0400 | [diff] [blame] | 35 | |
Behdad Esfahbod | cc84287 | 2018-11-12 18:48:10 -0500 | [diff] [blame] | 36 | struct hb_ot_shape_plan_key_t |
| 37 | { |
| 38 | unsigned int variations_index[2]; |
| 39 | |
Ebrahim Byagowi | 071e2e3 | 2020-03-26 12:01:53 +0430 | [diff] [blame] | 40 | void init (hb_face_t *face, |
| 41 | const int *coords, |
| 42 | unsigned num_coords) |
Behdad Esfahbod | cc84287 | 2018-11-12 18:48:10 -0500 | [diff] [blame] | 43 | { |
| 44 | for (unsigned int table_index = 0; table_index < 2; table_index++) |
| 45 | hb_ot_layout_table_find_feature_variations (face, |
| 46 | table_tags[table_index], |
| 47 | coords, |
| 48 | num_coords, |
| 49 | &variations_index[table_index]); |
| 50 | } |
| 51 | |
Ebrahim Byagowi | b2ebaa9 | 2018-12-16 22:38:10 +0330 | [diff] [blame] | 52 | bool equal (const hb_ot_shape_plan_key_t *other) |
Behdad Esfahbod | cc84287 | 2018-11-12 18:48:10 -0500 | [diff] [blame] | 53 | { |
| 54 | return 0 == memcmp (this, other, sizeof (*this)); |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | |
Behdad Esfahbod | 1082338 | 2018-11-12 18:05:02 -0500 | [diff] [blame] | 59 | struct hb_shape_plan_key_t; |
| 60 | |
Behdad Esfahbod | 13403bc | 2010-10-12 17:23:54 -0400 | [diff] [blame] | 61 | struct hb_ot_shape_plan_t |
| 62 | { |
Behdad Esfahbod | 16c6a27 | 2012-08-02 09:38:28 -0400 | [diff] [blame] | 63 | hb_segment_properties_t props; |
| 64 | const struct hb_ot_complex_shaper_t *shaper; |
Behdad Esfahbod | 5393e3a | 2012-08-02 09:24:35 -0400 | [diff] [blame] | 65 | hb_ot_map_t map; |
Behdad Esfahbod | ffe3478 | 2018-10-23 14:14:03 -0700 | [diff] [blame] | 66 | hb_aat_map_t aat_map; |
Behdad Esfahbod | a8c6da9 | 2012-08-02 10:46:34 -0400 | [diff] [blame] | 67 | const void *data; |
Behdad Esfahbod | d84932b | 2019-06-19 16:57:48 -0700 | [diff] [blame] | 68 | #ifndef HB_NO_OT_SHAPE_FRACTIONS |
Behdad Esfahbod | cf92d65 | 2018-10-23 03:10:56 -0700 | [diff] [blame] | 69 | hb_mask_t frac_mask, numr_mask, dnom_mask; |
Behdad Esfahbod | d84932b | 2019-06-19 16:57:48 -0700 | [diff] [blame] | 70 | #else |
| 71 | static constexpr hb_mask_t frac_mask = 0; |
| 72 | static constexpr hb_mask_t numr_mask = 0; |
| 73 | static constexpr hb_mask_t dnom_mask = 0; |
| 74 | #endif |
Behdad Esfahbod | cf92d65 | 2018-10-23 03:10:56 -0700 | [diff] [blame] | 75 | hb_mask_t rtlm_mask; |
Behdad Esfahbod | d8bf672 | 2019-06-19 17:04:16 -0700 | [diff] [blame] | 76 | #ifndef HB_NO_OT_KERN |
Behdad Esfahbod | 5497a8a | 2013-12-22 20:48:53 -0500 | [diff] [blame] | 77 | hb_mask_t kern_mask; |
Behdad Esfahbod | d8bf672 | 2019-06-19 17:04:16 -0700 | [diff] [blame] | 78 | #else |
| 79 | static constexpr hb_mask_t kern_mask = 0; |
| 80 | #endif |
Behdad Esfahbod | 12092a4 | 2019-06-26 13:31:01 -0700 | [diff] [blame] | 81 | #ifndef HB_NO_AAT_SHAPE |
Behdad Esfahbod | cf92d65 | 2018-10-23 03:10:56 -0700 | [diff] [blame] | 82 | hb_mask_t trak_mask; |
Behdad Esfahbod | 43d7048 | 2019-06-19 17:02:32 -0700 | [diff] [blame] | 83 | #else |
| 84 | static constexpr hb_mask_t trak_mask = 0; |
| 85 | #endif |
Behdad Esfahbod | 96eca87 | 2018-10-02 13:24:40 +0200 | [diff] [blame] | 86 | |
Behdad Esfahbod | d8bf672 | 2019-06-19 17:04:16 -0700 | [diff] [blame] | 87 | #ifndef HB_NO_OT_KERN |
Behdad Esfahbod | 60f86d3 | 2018-10-10 18:10:05 -0400 | [diff] [blame] | 88 | bool requested_kerning : 1; |
Behdad Esfahbod | d8bf672 | 2019-06-19 17:04:16 -0700 | [diff] [blame] | 89 | #else |
| 90 | static constexpr bool requested_kerning = false; |
| 91 | #endif |
Behdad Esfahbod | 12092a4 | 2019-06-26 13:31:01 -0700 | [diff] [blame] | 92 | #ifndef HB_NO_AAT_SHAPE |
Behdad Esfahbod | cf92d65 | 2018-10-23 03:10:56 -0700 | [diff] [blame] | 93 | bool requested_tracking : 1; |
Behdad Esfahbod | 43d7048 | 2019-06-19 17:02:32 -0700 | [diff] [blame] | 94 | #else |
| 95 | static constexpr bool requested_tracking = false; |
| 96 | #endif |
Behdad Esfahbod | d84932b | 2019-06-19 16:57:48 -0700 | [diff] [blame] | 97 | #ifndef HB_NO_OT_SHAPE_FRACTIONS |
Behdad Esfahbod | 1d1734e | 2018-10-02 13:04:05 +0200 | [diff] [blame] | 98 | bool has_frac : 1; |
Behdad Esfahbod | d84932b | 2019-06-19 16:57:48 -0700 | [diff] [blame] | 99 | #else |
| 100 | static constexpr bool has_frac = false; |
| 101 | #endif |
Behdad Esfahbod | 2dc20e6 | 2019-12-05 15:28:42 +0000 | [diff] [blame] | 102 | bool has_vert : 1; |
Behdad Esfahbod | 1d1734e | 2018-10-02 13:04:05 +0200 | [diff] [blame] | 103 | bool has_gpos_mark : 1; |
Behdad Esfahbod | ca23567 | 2018-11-07 16:19:51 -0500 | [diff] [blame] | 104 | bool zero_marks : 1; |
Behdad Esfahbod | 96eca87 | 2018-10-02 13:24:40 +0200 | [diff] [blame] | 105 | bool fallback_glyph_classes : 1; |
Behdad Esfahbod | 09ad261 | 2018-10-08 23:30:24 -0400 | [diff] [blame] | 106 | bool fallback_mark_positioning : 1; |
Behdad Esfahbod | a201fa7 | 2018-11-22 15:52:29 -0500 | [diff] [blame] | 107 | bool adjust_mark_positioning_when_zeroing : 1; |
Behdad Esfahbod | 8bb5deb | 2012-08-02 10:07:58 -0400 | [diff] [blame] | 108 | |
Behdad Esfahbod | b59a428 | 2018-10-11 13:24:17 -0400 | [diff] [blame] | 109 | bool apply_gpos : 1; |
Behdad Esfahbod | 588697a | 2019-06-19 16:24:51 -0700 | [diff] [blame] | 110 | #ifndef HB_NO_OT_KERN |
Behdad Esfahbod | a519588 | 2018-10-08 23:57:45 -0400 | [diff] [blame] | 111 | bool apply_kern : 1; |
Behdad Esfahbod | 588697a | 2019-06-19 16:24:51 -0700 | [diff] [blame] | 112 | #else |
| 113 | static constexpr bool apply_kern = false; |
| 114 | #endif |
Behdad Esfahbod | 79e8b30 | 2021-07-16 15:06:10 -0600 | [diff] [blame] | 115 | bool apply_fallback_kern : 1; |
Behdad Esfahbod | 12092a4 | 2019-06-26 13:31:01 -0700 | [diff] [blame] | 116 | #ifndef HB_NO_AAT_SHAPE |
Behdad Esfahbod | 809c587 | 2019-05-13 14:45:51 -0700 | [diff] [blame] | 117 | bool apply_kerx : 1; |
Behdad Esfahbod | b59a428 | 2018-10-11 13:24:17 -0400 | [diff] [blame] | 118 | bool apply_morx : 1; |
| 119 | bool apply_trak : 1; |
Behdad Esfahbod | 809c587 | 2019-05-13 14:45:51 -0700 | [diff] [blame] | 120 | #else |
| 121 | static constexpr bool apply_kerx = false; |
| 122 | static constexpr bool apply_morx = false; |
| 123 | static constexpr bool apply_trak = false; |
| 124 | #endif |
Behdad Esfahbod | 14ff3cb | 2018-10-04 11:34:21 +0200 | [diff] [blame] | 125 | |
Ebrahim Byagowi | b2ebaa9 | 2018-12-16 22:38:10 +0330 | [diff] [blame] | 126 | void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 127 | { |
| 128 | unsigned int table_index; |
| 129 | switch (table_tag) { |
| 130 | case HB_OT_TAG_GSUB: table_index = 0; break; |
| 131 | case HB_OT_TAG_GPOS: table_index = 1; break; |
| 132 | default: return; |
| 133 | } |
| 134 | map.collect_lookups (table_index, lookups); |
| 135 | } |
Behdad Esfahbod | 8bb5deb | 2012-08-02 10:07:58 -0400 | [diff] [blame] | 136 | |
Behdad Esfahbod | 3e284e0 | 2018-11-11 22:51:34 -0500 | [diff] [blame] | 137 | HB_INTERNAL bool init0 (hb_face_t *face, |
Behdad Esfahbod | 1082338 | 2018-11-12 18:05:02 -0500 | [diff] [blame] | 138 | const hb_shape_plan_key_t *key); |
Ebrahim Byagowi | e412008 | 2018-12-17 21:31:01 +0330 | [diff] [blame] | 139 | HB_INTERNAL void fini (); |
Behdad Esfahbod | c221dc0 | 2018-11-14 14:49:34 -0500 | [diff] [blame] | 140 | |
| 141 | HB_INTERNAL void substitute (hb_font_t *font, hb_buffer_t *buffer) const; |
| 142 | HB_INTERNAL void position (hb_font_t *font, hb_buffer_t *buffer) const; |
Behdad Esfahbod | 13403bc | 2010-10-12 17:23:54 -0400 | [diff] [blame] | 143 | }; |
| 144 | |
Behdad Esfahbod | f521a28 | 2018-11-11 21:32:01 -0500 | [diff] [blame] | 145 | struct hb_shape_plan_t; |
| 146 | |
Behdad Esfahbod | 5393e3a | 2012-08-02 09:24:35 -0400 | [diff] [blame] | 147 | struct hb_ot_shape_planner_t |
| 148 | { |
| 149 | /* In the order that they are filled in. */ |
| 150 | hb_face_t *face; |
| 151 | hb_segment_properties_t props; |
Behdad Esfahbod | 5393e3a | 2012-08-02 09:24:35 -0400 | [diff] [blame] | 152 | hb_ot_map_builder_t map; |
Behdad Esfahbod | ffe3478 | 2018-10-23 14:14:03 -0700 | [diff] [blame] | 153 | hb_aat_map_builder_t aat_map; |
Behdad Esfahbod | 12092a4 | 2019-06-26 13:31:01 -0700 | [diff] [blame] | 154 | #ifndef HB_NO_AAT_SHAPE |
Behdad Esfahbod | 76324d9 | 2018-10-23 13:09:30 -0700 | [diff] [blame] | 155 | bool apply_morx : 1; |
Behdad Esfahbod | 809c587 | 2019-05-13 14:45:51 -0700 | [diff] [blame] | 156 | #else |
| 157 | static constexpr bool apply_morx = false; |
| 158 | #endif |
Behdad Esfahbod | a201fa7 | 2018-11-22 15:52:29 -0500 | [diff] [blame] | 159 | bool script_zero_marks : 1; |
| 160 | bool script_fallback_mark_positioning : 1; |
Behdad Esfahbod | 76324d9 | 2018-10-23 13:09:30 -0700 | [diff] [blame] | 161 | const struct hb_ot_complex_shaper_t *shaper; |
Behdad Esfahbod | 5393e3a | 2012-08-02 09:24:35 -0400 | [diff] [blame] | 162 | |
Behdad Esfahbod | 3e284e0 | 2018-11-11 22:51:34 -0500 | [diff] [blame] | 163 | HB_INTERNAL hb_ot_shape_planner_t (hb_face_t *face, |
| 164 | const hb_segment_properties_t *props); |
Behdad Esfahbod | 5393e3a | 2012-08-02 09:24:35 -0400 | [diff] [blame] | 165 | |
Behdad Esfahbod | cc84287 | 2018-11-12 18:48:10 -0500 | [diff] [blame] | 166 | HB_INTERNAL void compile (hb_ot_shape_plan_t &plan, |
| 167 | const hb_ot_shape_plan_key_t &key); |
Behdad Esfahbod | 5393e3a | 2012-08-02 09:24:35 -0400 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 171 | #endif /* HB_OT_SHAPE_HH */ |