Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 2 | * Copyright © 2007,2008,2009 Red Hat, Inc. |
Behdad Esfahbod | 4695246 | 2013-10-17 21:01:57 +0200 | [diff] [blame] | 3 | * Copyright © 2012,2013 Google, Inc. |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 4 | * |
Behdad Esfahbod | c755cb3 | 2010-04-22 00:11:43 -0400 | [diff] [blame] | 5 | * This is part of HarfBuzz, a text shaping library. |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 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 |
Behdad Esfahbod | f860366 | 2012-07-30 02:38:39 -0400 | [diff] [blame] | 26 | * Google Author(s): Behdad Esfahbod |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 27 | */ |
| 28 | |
Behdad Esfahbod | 0f0cd9d | 2010-06-09 06:32:56 -0400 | [diff] [blame] | 29 | #ifndef HB_OT_LAYOUT_PRIVATE_HH |
| 30 | #define HB_OT_LAYOUT_PRIVATE_HH |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 31 | |
Behdad Esfahbod | c57d454 | 2011-04-20 18:50:27 -0400 | [diff] [blame] | 32 | #include "hb-private.hh" |
Behdad Esfahbod | 2c80296 | 2009-08-02 15:20:22 -0400 | [diff] [blame] | 33 | |
Behdad Esfahbod | c57d454 | 2011-04-20 18:50:27 -0400 | [diff] [blame] | 34 | #include "hb-font-private.hh" |
Behdad Esfahbod | 22da7fd | 2010-05-12 18:23:21 -0400 | [diff] [blame] | 35 | #include "hb-buffer-private.hh" |
Behdad Esfahbod | 1336ecd | 2012-08-01 21:46:36 -0400 | [diff] [blame] | 36 | #include "hb-set-private.hh" |
Behdad Esfahbod | 1f810da | 2017-01-09 23:50:56 -0800 | [diff] [blame^] | 37 | #include "hb-open-type-private.hh" |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 38 | |
Behdad Esfahbod | 23c86aa | 2009-08-03 21:40:20 -0400 | [diff] [blame] | 39 | |
Behdad Esfahbod | 0f98fe8 | 2015-07-23 11:52:11 +0100 | [diff] [blame] | 40 | /* Private API corresponding to hb-ot-layout.h: */ |
| 41 | |
| 42 | HB_INTERNAL hb_bool_t |
| 43 | hb_ot_layout_table_find_feature (hb_face_t *face, |
| 44 | hb_tag_t table_tag, |
| 45 | hb_tag_t feature_tag, |
| 46 | unsigned int *feature_index); |
| 47 | |
| 48 | |
Behdad Esfahbod | 266b344 | 2011-05-03 00:35:53 -0400 | [diff] [blame] | 49 | /* |
| 50 | * GDEF |
| 51 | */ |
| 52 | |
Behdad Esfahbod | aa7044d | 2015-11-04 16:25:57 -0800 | [diff] [blame] | 53 | enum hb_ot_layout_glyph_props_flags_t |
Behdad Esfahbod | 05ad6b5 | 2013-10-18 00:45:59 +0200 | [diff] [blame] | 54 | { |
Behdad Esfahbod | 03058c3 | 2013-10-17 20:55:34 +0200 | [diff] [blame] | 55 | /* The following three match LookupFlags::Ignore* numbers. */ |
Behdad Esfahbod | 941b699 | 2013-10-17 20:47:33 +0200 | [diff] [blame] | 56 | HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH = 0x02u, |
| 57 | HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE = 0x04u, |
Behdad Esfahbod | 05ad6b5 | 2013-10-18 00:45:59 +0200 | [diff] [blame] | 58 | HB_OT_LAYOUT_GLYPH_PROPS_MARK = 0x08u, |
| 59 | |
| 60 | /* The following are used internally; not derived from GDEF. */ |
Behdad Esfahbod | 09675a8 | 2013-10-18 01:05:58 +0200 | [diff] [blame] | 61 | HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED = 0x10u, |
| 62 | HB_OT_LAYOUT_GLYPH_PROPS_LIGATED = 0x20u, |
Behdad Esfahbod | 832a6f9 | 2014-06-04 16:57:42 -0400 | [diff] [blame] | 63 | HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED = 0x40u, |
Behdad Esfahbod | 03058c3 | 2013-10-17 20:55:34 +0200 | [diff] [blame] | 64 | |
Behdad Esfahbod | 09675a8 | 2013-10-18 01:05:58 +0200 | [diff] [blame] | 65 | HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE = HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED | |
Behdad Esfahbod | 832a6f9 | 2014-06-04 16:57:42 -0400 | [diff] [blame] | 66 | HB_OT_LAYOUT_GLYPH_PROPS_LIGATED | |
| 67 | HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED |
Behdad Esfahbod | aa7044d | 2015-11-04 16:25:57 -0800 | [diff] [blame] | 68 | }; |
Chun-wei Fan | 167c327 | 2015-11-09 17:17:56 +0800 | [diff] [blame] | 69 | HB_MARK_AS_FLAG_T (hb_ot_layout_glyph_props_flags_t); |
Behdad Esfahbod | 5a08ecf | 2012-11-16 13:34:29 -0800 | [diff] [blame] | 70 | |
Behdad Esfahbod | ead428d | 2008-01-24 03:54:09 -0500 | [diff] [blame] | 71 | |
Behdad Esfahbod | 49c5ec5 | 2012-07-23 20:14:13 -0400 | [diff] [blame] | 72 | /* |
| 73 | * GSUB/GPOS |
| 74 | */ |
| 75 | |
Behdad Esfahbod | f860366 | 2012-07-30 02:38:39 -0400 | [diff] [blame] | 76 | HB_INTERNAL hb_bool_t |
Behdad Esfahbod | 362a990 | 2012-11-15 14:57:31 -0800 | [diff] [blame] | 77 | hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face, |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 78 | unsigned int lookup_index, |
Behdad Esfahbod | f860366 | 2012-07-30 02:38:39 -0400 | [diff] [blame] | 79 | const hb_codepoint_t *glyphs, |
| 80 | unsigned int glyphs_length, |
Behdad Esfahbod | d9b204d | 2012-08-23 16:22:28 -0400 | [diff] [blame] | 81 | hb_bool_t zero_context); |
Behdad Esfahbod | f860366 | 2012-07-30 02:38:39 -0400 | [diff] [blame] | 82 | |
Behdad Esfahbod | b0e6a26 | 2012-08-02 08:11:14 -0400 | [diff] [blame] | 83 | |
| 84 | /* Should be called before all the substitute_lookup's are done. */ |
| 85 | HB_INTERNAL void |
Behdad Esfahbod | afbcc24 | 2012-08-02 08:36:40 -0400 | [diff] [blame] | 86 | hb_ot_layout_substitute_start (hb_font_t *font, |
Behdad Esfahbod | b0e6a26 | 2012-08-02 08:11:14 -0400 | [diff] [blame] | 87 | hb_buffer_t *buffer); |
Behdad Esfahbod | f860366 | 2012-07-30 02:38:39 -0400 | [diff] [blame] | 88 | |
Behdad Esfahbod | bac1dd6 | 2013-05-02 18:52:24 -0400 | [diff] [blame] | 89 | |
| 90 | struct hb_ot_layout_lookup_accelerator_t; |
| 91 | |
| 92 | namespace OT { |
| 93 | struct hb_apply_context_t; |
| 94 | struct SubstLookup; |
| 95 | } |
| 96 | |
| 97 | HB_INTERNAL void |
| 98 | hb_ot_layout_substitute_lookup (OT::hb_apply_context_t *c, |
| 99 | const OT::SubstLookup &lookup, |
| 100 | const hb_ot_layout_lookup_accelerator_t &accel); |
| 101 | |
Behdad Esfahbod | b0e6a26 | 2012-08-02 08:11:14 -0400 | [diff] [blame] | 102 | |
Behdad Esfahbod | 7d8d58a | 2016-02-11 16:34:28 +0700 | [diff] [blame] | 103 | /* Should be called before all the position_lookup's are done. */ |
Behdad Esfahbod | b0e6a26 | 2012-08-02 08:11:14 -0400 | [diff] [blame] | 104 | HB_INTERNAL void |
| 105 | hb_ot_layout_position_start (hb_font_t *font, |
| 106 | hb_buffer_t *buffer); |
| 107 | |
Behdad Esfahbod | 7d8d58a | 2016-02-11 16:34:28 +0700 | [diff] [blame] | 108 | /* Should be called after all the position_lookup's are done, to finish advances. */ |
Behdad Esfahbod | b0e6a26 | 2012-08-02 08:11:14 -0400 | [diff] [blame] | 109 | HB_INTERNAL void |
Behdad Esfahbod | 7d8d58a | 2016-02-11 16:34:28 +0700 | [diff] [blame] | 110 | hb_ot_layout_position_finish_advances (hb_font_t *font, |
| 111 | hb_buffer_t *buffer); |
| 112 | |
| 113 | /* Should be called after hb_ot_layout_position_finish_advances, to finish offsets. */ |
| 114 | HB_INTERNAL void |
| 115 | hb_ot_layout_position_finish_offsets (hb_font_t *font, |
| 116 | hb_buffer_t *buffer); |
Behdad Esfahbod | b0e6a26 | 2012-08-02 08:11:14 -0400 | [diff] [blame] | 117 | |
Behdad Esfahbod | f860366 | 2012-07-30 02:38:39 -0400 | [diff] [blame] | 118 | |
| 119 | |
Behdad Esfahbod | 266b344 | 2011-05-03 00:35:53 -0400 | [diff] [blame] | 120 | /* |
| 121 | * hb_ot_layout_t |
| 122 | */ |
| 123 | |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 124 | namespace OT { |
| 125 | struct GDEF; |
| 126 | struct GSUB; |
| 127 | struct GPOS; |
Frédéric Wang | 5fbcb99 | 2016-08-25 10:47:15 +0200 | [diff] [blame] | 128 | struct MATH; |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 129 | } |
| 130 | |
Behdad Esfahbod | 45fd942 | 2013-05-02 18:06:51 -0400 | [diff] [blame] | 131 | struct hb_ot_layout_lookup_accelerator_t |
| 132 | { |
| 133 | template <typename TLookup> |
| 134 | inline void init (const TLookup &lookup) |
| 135 | { |
| 136 | digest.init (); |
| 137 | lookup.add_coverage (&digest); |
| 138 | } |
| 139 | |
Behdad Esfahbod | 395b359 | 2014-12-28 16:03:26 -0800 | [diff] [blame] | 140 | inline void fini (void) |
Behdad Esfahbod | 45fd942 | 2013-05-02 18:06:51 -0400 | [diff] [blame] | 141 | { |
| 142 | } |
| 143 | |
Behdad Esfahbod | 241eac9 | 2015-01-28 20:55:42 -0800 | [diff] [blame] | 144 | inline bool may_have (hb_codepoint_t g) const { |
| 145 | return digest.may_have (g); |
| 146 | } |
| 147 | |
| 148 | private: |
Behdad Esfahbod | 45fd942 | 2013-05-02 18:06:51 -0400 | [diff] [blame] | 149 | hb_set_digest_t digest; |
| 150 | }; |
| 151 | |
Behdad Esfahbod | 266b344 | 2011-05-03 00:35:53 -0400 | [diff] [blame] | 152 | struct hb_ot_layout_t |
| 153 | { |
| 154 | hb_blob_t *gdef_blob; |
| 155 | hb_blob_t *gsub_blob; |
| 156 | hb_blob_t *gpos_blob; |
Behdad Esfahbod | 266b344 | 2011-05-03 00:35:53 -0400 | [diff] [blame] | 157 | |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 158 | const struct OT::GDEF *gdef; |
| 159 | const struct OT::GSUB *gsub; |
| 160 | const struct OT::GPOS *gpos; |
Behdad Esfahbod | 1f810da | 2017-01-09 23:50:56 -0800 | [diff] [blame^] | 161 | OT::hb_lazy_table_loader_t<struct OT::MATH> math; |
Behdad Esfahbod | 1336ecd | 2012-08-01 21:46:36 -0400 | [diff] [blame] | 162 | |
Behdad Esfahbod | 6f76113 | 2012-08-02 04:00:31 -0400 | [diff] [blame] | 163 | unsigned int gsub_lookup_count; |
| 164 | unsigned int gpos_lookup_count; |
| 165 | |
Behdad Esfahbod | 45fd942 | 2013-05-02 18:06:51 -0400 | [diff] [blame] | 166 | hb_ot_layout_lookup_accelerator_t *gsub_accels; |
| 167 | hb_ot_layout_lookup_accelerator_t *gpos_accels; |
Behdad Esfahbod | 266b344 | 2011-05-03 00:35:53 -0400 | [diff] [blame] | 168 | }; |
| 169 | |
Behdad Esfahbod | 266b344 | 2011-05-03 00:35:53 -0400 | [diff] [blame] | 170 | |
| 171 | HB_INTERNAL hb_ot_layout_t * |
| 172 | _hb_ot_layout_create (hb_face_t *face); |
| 173 | |
| 174 | HB_INTERNAL void |
| 175 | _hb_ot_layout_destroy (hb_ot_layout_t *layout); |
| 176 | |
| 177 | |
Behdad Esfahbod | 4695246 | 2013-10-17 21:01:57 +0200 | [diff] [blame] | 178 | #define hb_ot_layout_from_face(face) ((hb_ot_layout_t *) face->shaper_data.ot) |
| 179 | |
Behdad Esfahbod | fd92a3d | 2008-01-24 03:11:09 -0500 | [diff] [blame] | 180 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 181 | /* |
| 182 | * Buffer var routines. |
| 183 | */ |
| 184 | |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 185 | /* buffer var allocations, used during the entire shaping process */ |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 186 | #define unicode_props() var2.u16[0] |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 187 | |
| 188 | /* buffer var allocations, used during the GSUB/GPOS processing */ |
| 189 | #define glyph_props() var1.u16[0] /* GDEF glyph properties */ |
| 190 | #define lig_props() var1.u8[2] /* GSUB/GPOS ligature tracking */ |
| 191 | #define syllable() var1.u8[3] /* GSUB/GPOS shaping boundaries */ |
| 192 | |
Behdad Esfahbod | ac59651 | 2015-07-22 11:54:02 +0100 | [diff] [blame] | 193 | |
| 194 | /* loop over syllables */ |
| 195 | |
| 196 | #define foreach_syllable(buffer, start, end) \ |
| 197 | for (unsigned int \ |
| 198 | _count = buffer->len, \ |
| 199 | start = 0, end = _count ? _next_syllable (buffer, 0) : 0; \ |
| 200 | start < _count; \ |
| 201 | start = end, end = _next_syllable (buffer, start)) |
| 202 | |
| 203 | static inline unsigned int |
| 204 | _next_syllable (hb_buffer_t *buffer, unsigned int start) |
| 205 | { |
| 206 | hb_glyph_info_t *info = buffer->info; |
| 207 | unsigned int count = buffer->len; |
| 208 | |
| 209 | unsigned int syllable = info[start].syllable(); |
| 210 | while (++start < count && syllable == info[start].syllable()) |
| 211 | ; |
| 212 | |
| 213 | return start; |
| 214 | } |
| 215 | |
| 216 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 217 | /* unicode_props */ |
| 218 | |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 219 | /* Design: |
| 220 | * unicode_props() is a two-byte number. The low byte includes: |
| 221 | * - General_Category: 5 bits. |
| 222 | * - A bit each for: |
| 223 | * * Is it Default_Ignorable(); we have a modified Default_Ignorable(). |
Behdad Esfahbod | b203050 | 2016-04-26 16:41:17 -0700 | [diff] [blame] | 224 | * * Whether it's one of the three Mongolian Free Variation Selectors. |
| 225 | * * One free bit right now. |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 226 | * |
| 227 | * The high-byte has different meanings, switched by the Gen-Cat: |
| 228 | * - For Mn,Mc,Me: the modified Combining_Class. |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 229 | * - For Cf: whether it's ZWJ, ZWNJ, or something else. |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 230 | * - For Ws: index of which space character this is, if space fallback |
| 231 | * is needed, ie. we don't set this by default, only if asked to. |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 232 | */ |
| 233 | |
Behdad Esfahbod | aa7044d | 2015-11-04 16:25:57 -0800 | [diff] [blame] | 234 | enum hb_unicode_props_flags_t { |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 235 | UPROPS_MASK_GEN_CAT = 0x001Fu, |
| 236 | UPROPS_MASK_IGNORABLE = 0x0020u, |
Behdad Esfahbod | b203050 | 2016-04-26 16:41:17 -0700 | [diff] [blame] | 237 | UPROPS_MASK_FVS = 0x0040u, /* MONGOLIAN FREE VARIATION SELECTOR 1..3 */ |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 238 | |
| 239 | /* If GEN_CAT=FORMAT, top byte masks: */ |
| 240 | UPROPS_MASK_Cf_ZWJ = 0x0100u, |
| 241 | UPROPS_MASK_Cf_ZWNJ = 0x0200u |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 242 | }; |
Chun-wei Fan | 167c327 | 2015-11-09 17:17:56 +0800 | [diff] [blame] | 243 | HB_MARK_AS_FLAG_T (hb_unicode_props_flags_t); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 244 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 245 | static inline void |
Behdad Esfahbod | 6986208 | 2015-11-04 18:46:22 -0800 | [diff] [blame] | 246 | _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 247 | { |
Behdad Esfahbod | 6986208 | 2015-11-04 18:46:22 -0800 | [diff] [blame] | 248 | hb_unicode_funcs_t *unicode = buffer->unicode; |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 249 | unsigned int u = info->codepoint; |
| 250 | unsigned int gen_cat = (unsigned int) unicode->general_category (u); |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 251 | unsigned int props = gen_cat; |
| 252 | |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 253 | if (u >= 0x80) |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 254 | { |
Behdad Esfahbod | e3e4bb0 | 2015-11-04 18:58:02 -0800 | [diff] [blame] | 255 | buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII; |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 256 | if (unlikely (unicode->is_default_ignorable (u))) |
| 257 | { |
Behdad Esfahbod | 6986208 | 2015-11-04 18:46:22 -0800 | [diff] [blame] | 258 | buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES; |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 259 | props |= UPROPS_MASK_IGNORABLE; |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 260 | if (u == 0x200Cu) props |= UPROPS_MASK_Cf_ZWNJ; |
| 261 | if (u == 0x200Du) props |= UPROPS_MASK_Cf_ZWJ; |
Behdad Esfahbod | b203050 | 2016-04-26 16:41:17 -0700 | [diff] [blame] | 262 | /* Mongolian Free Variation Selectors need to be remembered |
| 263 | * because although we need to hide them like default-ignorables, |
| 264 | * they need to non-ignorable during shaping. This is similar to |
| 265 | * what we do for joiners in Indic-like shapers, but since the |
| 266 | * FVSes are GC=Mn, we have use a separate bit to remember them. |
| 267 | * Fixes: |
| 268 | * https://github.com/behdad/harfbuzz/issues/234 |
| 269 | */ |
| 270 | if (unlikely (hb_in_range (u, 0x180Bu, 0x180Du))) props |= UPROPS_MASK_FVS; |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 271 | } |
Behdad Esfahbod | aae2847 | 2016-02-18 17:06:25 +0700 | [diff] [blame] | 272 | else if (unlikely (HB_UNICODE_GENERAL_CATEGORY_IS_NON_ENCLOSING_MARK_OR_MODIFIER_SYMBOL (gen_cat))) |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 273 | { |
Behdad Esfahbod | aae2847 | 2016-02-18 17:06:25 +0700 | [diff] [blame] | 274 | /* The above check is just an optimization to let in only things we need further |
| 275 | * processing on. */ |
| 276 | |
Behdad Esfahbod | 90d75f9 | 2015-11-03 12:58:12 -0800 | [diff] [blame] | 277 | /* Only Mn and Mc can have non-zero ccc: |
| 278 | * http://www.unicode.org/policies/stability_policy.html#Property_Value |
| 279 | * """ |
| 280 | * Canonical_Combining_Class, General_Category |
| 281 | * All characters other than those with General_Category property values |
| 282 | * Spacing_Mark (Mc) and Nonspacing_Mark (Mn) have the Canonical_Combining_Class |
| 283 | * property value 0. |
| 284 | * 1.1.5+ |
| 285 | * """ |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 286 | * |
| 287 | * Also, all Mn's that are Default_Ignorable, have ccc=0, hence |
| 288 | * the "else if". |
Behdad Esfahbod | 90d75f9 | 2015-11-03 12:58:12 -0800 | [diff] [blame] | 289 | */ |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 290 | props |= unicode->modified_combining_class (info->codepoint)<<8; |
Behdad Esfahbod | aae2847 | 2016-02-18 17:06:25 +0700 | [diff] [blame] | 291 | |
| 292 | /* Recategorize emoji skin-tone modifiers as Unicode mark, so they |
| 293 | * behave correctly in non-native directionality. They originally |
| 294 | * are MODIFIER_SYMBOL. Fixes: |
| 295 | * https://github.com/behdad/harfbuzz/issues/169 |
| 296 | */ |
| 297 | if (unlikely (hb_in_range (u, 0x1F3FBu, 0x1F3FFu))) |
| 298 | { |
| 299 | props = gen_cat = HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK; |
| 300 | } |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 301 | } |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 302 | } |
Behdad Esfahbod | ed2024e | 2015-11-02 17:58:12 -0800 | [diff] [blame] | 303 | |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 304 | info->unicode_props() = props; |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 305 | } |
| 306 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 307 | static inline void |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 308 | _hb_glyph_info_set_general_category (hb_glyph_info_t *info, |
| 309 | hb_unicode_general_category_t gen_cat) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 310 | { |
Behdad Esfahbod | cc5d3a3 | 2015-11-04 13:21:25 -0800 | [diff] [blame] | 311 | /* Clears top-byte. */ |
| 312 | info->unicode_props() = (unsigned int) gen_cat | (info->unicode_props() & (0xFF & ~UPROPS_MASK_GEN_CAT)); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 313 | } |
| 314 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 315 | static inline hb_unicode_general_category_t |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 316 | _hb_glyph_info_get_general_category (const hb_glyph_info_t *info) |
| 317 | { |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 318 | return (hb_unicode_general_category_t) (info->unicode_props() & UPROPS_MASK_GEN_CAT); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 319 | } |
| 320 | |
Behdad Esfahbod | 2f38dde | 2015-11-04 13:17:33 -0800 | [diff] [blame] | 321 | static inline bool |
| 322 | _hb_glyph_info_is_unicode_mark (const hb_glyph_info_t *info) |
| 323 | { |
| 324 | return HB_UNICODE_GENERAL_CATEGORY_IS_MARK (info->unicode_props() & UPROPS_MASK_GEN_CAT); |
| 325 | } |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 326 | static inline void |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 327 | _hb_glyph_info_set_modified_combining_class (hb_glyph_info_t *info, |
| 328 | unsigned int modified_class) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 329 | { |
Behdad Esfahbod | 8249ec3 | 2015-11-04 13:26:17 -0800 | [diff] [blame] | 330 | if (unlikely (!_hb_glyph_info_is_unicode_mark (info))) |
| 331 | return; |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 332 | info->unicode_props() = (modified_class<<8) | (info->unicode_props() & 0xFF); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 333 | } |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 334 | static inline unsigned int |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 335 | _hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info) |
| 336 | { |
Behdad Esfahbod | 8249ec3 | 2015-11-04 13:26:17 -0800 | [diff] [blame] | 337 | return _hb_glyph_info_is_unicode_mark (info) ? info->unicode_props()>>8 : 0; |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 338 | } |
| 339 | |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 340 | static inline bool |
| 341 | _hb_glyph_info_is_unicode_space (const hb_glyph_info_t *info) |
| 342 | { |
| 343 | return _hb_glyph_info_get_general_category (info) == |
| 344 | HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR; |
| 345 | } |
| 346 | static inline void |
Behdad Esfahbod | 7793aad | 2015-11-04 14:48:46 -0800 | [diff] [blame] | 347 | _hb_glyph_info_set_unicode_space_fallback_type (hb_glyph_info_t *info, hb_unicode_funcs_t::space_t s) |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 348 | { |
| 349 | if (unlikely (!_hb_glyph_info_is_unicode_space (info))) |
| 350 | return; |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 351 | info->unicode_props() = (((unsigned int) s)<<8) | (info->unicode_props() & 0xFF); |
| 352 | } |
Behdad Esfahbod | 7793aad | 2015-11-04 14:48:46 -0800 | [diff] [blame] | 353 | static inline hb_unicode_funcs_t::space_t |
| 354 | _hb_glyph_info_get_unicode_space_fallback_type (const hb_glyph_info_t *info) |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 355 | { |
Behdad Esfahbod | 7793aad | 2015-11-04 14:48:46 -0800 | [diff] [blame] | 356 | return _hb_glyph_info_is_unicode_space (info) ? |
| 357 | (hb_unicode_funcs_t::space_t) (info->unicode_props()>>8) : |
| 358 | hb_unicode_funcs_t::NOT_SPACE; |
Behdad Esfahbod | 9ac4b96 | 2015-11-04 14:18:39 -0800 | [diff] [blame] | 359 | } |
| 360 | |
Behdad Esfahbod | 4ba796b | 2015-07-22 17:41:31 +0100 | [diff] [blame] | 361 | static inline bool _hb_glyph_info_ligated (const hb_glyph_info_t *info); |
| 362 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 363 | static inline hb_bool_t |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 364 | _hb_glyph_info_is_default_ignorable (const hb_glyph_info_t *info) |
| 365 | { |
Behdad Esfahbod | b203050 | 2016-04-26 16:41:17 -0700 | [diff] [blame] | 366 | return (info->unicode_props() & UPROPS_MASK_IGNORABLE) && |
| 367 | !_hb_glyph_info_ligated (info); |
| 368 | } |
| 369 | static inline hb_bool_t |
| 370 | _hb_glyph_info_is_default_ignorable_and_not_fvs (const hb_glyph_info_t *info) |
| 371 | { |
| 372 | return ((info->unicode_props() & (UPROPS_MASK_IGNORABLE|UPROPS_MASK_FVS)) |
| 373 | == UPROPS_MASK_IGNORABLE) && |
| 374 | !_hb_glyph_info_ligated (info); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 375 | } |
| 376 | |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 377 | static inline bool |
| 378 | _hb_glyph_info_is_unicode_format (const hb_glyph_info_t *info) |
| 379 | { |
| 380 | return _hb_glyph_info_get_general_category (info) == |
| 381 | HB_UNICODE_GENERAL_CATEGORY_FORMAT; |
| 382 | } |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 383 | static inline hb_bool_t |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 384 | _hb_glyph_info_is_zwnj (const hb_glyph_info_t *info) |
| 385 | { |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 386 | return _hb_glyph_info_is_unicode_format (info) && (info->unicode_props() & UPROPS_MASK_Cf_ZWNJ); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 387 | } |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 388 | static inline hb_bool_t |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 389 | _hb_glyph_info_is_zwj (const hb_glyph_info_t *info) |
| 390 | { |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 391 | return _hb_glyph_info_is_unicode_format (info) && (info->unicode_props() & UPROPS_MASK_Cf_ZWJ); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 392 | } |
Behdad Esfahbod | 815bdd7 | 2016-02-22 18:22:44 +0900 | [diff] [blame] | 393 | static inline hb_bool_t |
| 394 | _hb_glyph_info_is_joiner (const hb_glyph_info_t *info) |
| 395 | { |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 396 | return _hb_glyph_info_is_unicode_format (info) && (info->unicode_props() & (UPROPS_MASK_Cf_ZWNJ|UPROPS_MASK_Cf_ZWJ)); |
Behdad Esfahbod | 815bdd7 | 2016-02-22 18:22:44 +0900 | [diff] [blame] | 397 | } |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 398 | static inline void |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 399 | _hb_glyph_info_flip_joiners (hb_glyph_info_t *info) |
| 400 | { |
Behdad Esfahbod | 21ab550 | 2016-04-26 16:02:04 -0700 | [diff] [blame] | 401 | if (!_hb_glyph_info_is_unicode_format (info)) |
| 402 | return; |
| 403 | info->unicode_props() ^= UPROPS_MASK_Cf_ZWNJ | UPROPS_MASK_Cf_ZWJ; |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | /* lig_props: aka lig_id / lig_comp |
| 407 | * |
| 408 | * When a ligature is formed: |
| 409 | * |
| 410 | * - The ligature glyph and any marks in between all the same newly allocated |
| 411 | * lig_id, |
| 412 | * - The ligature glyph will get lig_num_comps set to the number of components |
| 413 | * - The marks get lig_comp > 0, reflecting which component of the ligature |
| 414 | * they were applied to. |
| 415 | * - This is used in GPOS to attach marks to the right component of a ligature |
| 416 | * in MarkLigPos, |
| 417 | * - Note that when marks are ligated together, much of the above is skipped |
| 418 | * and the current lig_id reused. |
| 419 | * |
| 420 | * When a multiple-substitution is done: |
| 421 | * |
| 422 | * - All resulting glyphs will have lig_id = 0, |
| 423 | * - The resulting glyphs will have lig_comp = 0, 1, 2, ... respectively. |
| 424 | * - This is used in GPOS to attach marks to the first component of a |
| 425 | * multiple substitution in MarkBasePos. |
| 426 | * |
| 427 | * The numbers are also used in GPOS to do mark-to-mark positioning only |
| 428 | * to marks that belong to the same component of the same ligature. |
| 429 | */ |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 430 | |
| 431 | static inline void |
| 432 | _hb_glyph_info_clear_lig_props (hb_glyph_info_t *info) |
| 433 | { |
| 434 | info->lig_props() = 0; |
| 435 | } |
| 436 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 437 | #define IS_LIG_BASE 0x10 |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 438 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 439 | static inline void |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 440 | _hb_glyph_info_set_lig_props_for_ligature (hb_glyph_info_t *info, |
| 441 | unsigned int lig_id, |
| 442 | unsigned int lig_num_comps) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 443 | { |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 444 | info->lig_props() = (lig_id << 5) | IS_LIG_BASE | (lig_num_comps & 0x0F); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 445 | } |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 446 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 447 | static inline void |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 448 | _hb_glyph_info_set_lig_props_for_mark (hb_glyph_info_t *info, |
| 449 | unsigned int lig_id, |
| 450 | unsigned int lig_comp) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 451 | { |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 452 | info->lig_props() = (lig_id << 5) | (lig_comp & 0x0F); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 453 | } |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 454 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 455 | static inline void |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 456 | _hb_glyph_info_set_lig_props_for_component (hb_glyph_info_t *info, unsigned int comp) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 457 | { |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 458 | _hb_glyph_info_set_lig_props_for_mark (info, 0, comp); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | static inline unsigned int |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 462 | _hb_glyph_info_get_lig_id (const hb_glyph_info_t *info) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 463 | { |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 464 | return info->lig_props() >> 5; |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 465 | } |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 466 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 467 | static inline bool |
Behdad Esfahbod | a1f7b28 | 2013-10-18 01:09:08 +0200 | [diff] [blame] | 468 | _hb_glyph_info_ligated_internal (const hb_glyph_info_t *info) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 469 | { |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 470 | return !!(info->lig_props() & IS_LIG_BASE); |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 471 | } |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 472 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 473 | static inline unsigned int |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 474 | _hb_glyph_info_get_lig_comp (const hb_glyph_info_t *info) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 475 | { |
Behdad Esfahbod | a1f7b28 | 2013-10-18 01:09:08 +0200 | [diff] [blame] | 476 | if (_hb_glyph_info_ligated_internal (info)) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 477 | return 0; |
| 478 | else |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 479 | return info->lig_props() & 0x0F; |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 480 | } |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 481 | |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 482 | static inline unsigned int |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 483 | _hb_glyph_info_get_lig_num_comps (const hb_glyph_info_t *info) |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 484 | { |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 485 | if ((info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE) && |
Behdad Esfahbod | a1f7b28 | 2013-10-18 01:09:08 +0200 | [diff] [blame] | 486 | _hb_glyph_info_ligated_internal (info)) |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 487 | return info->lig_props() & 0x0F; |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 488 | else |
| 489 | return 1; |
| 490 | } |
| 491 | |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 492 | static inline uint8_t |
| 493 | _hb_allocate_lig_id (hb_buffer_t *buffer) { |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 494 | uint8_t lig_id = buffer->next_serial () & 0x07; |
| 495 | if (unlikely (!lig_id)) |
Behdad Esfahbod | 3ddf892 | 2013-10-18 00:02:43 +0200 | [diff] [blame] | 496 | lig_id = _hb_allocate_lig_id (buffer); /* in case of overflow */ |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 497 | return lig_id; |
| 498 | } |
| 499 | |
Behdad Esfahbod | 91689de | 2013-10-18 00:21:59 +0200 | [diff] [blame] | 500 | /* glyph_props: */ |
| 501 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 502 | static inline void |
Behdad Esfahbod | 91689de | 2013-10-18 00:21:59 +0200 | [diff] [blame] | 503 | _hb_glyph_info_set_glyph_props (hb_glyph_info_t *info, unsigned int props) |
| 504 | { |
| 505 | info->glyph_props() = props; |
| 506 | } |
| 507 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 508 | static inline unsigned int |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 509 | _hb_glyph_info_get_glyph_props (const hb_glyph_info_t *info) |
| 510 | { |
| 511 | return info->glyph_props(); |
| 512 | } |
Behdad Esfahbod | 91689de | 2013-10-18 00:21:59 +0200 | [diff] [blame] | 513 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 514 | static inline bool |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 515 | _hb_glyph_info_is_base_glyph (const hb_glyph_info_t *info) |
| 516 | { |
| 517 | return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH); |
| 518 | } |
| 519 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 520 | static inline bool |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 521 | _hb_glyph_info_is_ligature (const hb_glyph_info_t *info) |
| 522 | { |
| 523 | return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE); |
| 524 | } |
| 525 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 526 | static inline bool |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 527 | _hb_glyph_info_is_mark (const hb_glyph_info_t *info) |
| 528 | { |
| 529 | return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK); |
| 530 | } |
| 531 | |
Behdad Esfahbod | a1f7b28 | 2013-10-18 01:09:08 +0200 | [diff] [blame] | 532 | static inline bool |
Behdad Esfahbod | 8570273 | 2013-10-18 01:11:05 +0200 | [diff] [blame] | 533 | _hb_glyph_info_substituted (const hb_glyph_info_t *info) |
| 534 | { |
| 535 | return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED); |
| 536 | } |
| 537 | |
| 538 | static inline bool |
Behdad Esfahbod | a1f7b28 | 2013-10-18 01:09:08 +0200 | [diff] [blame] | 539 | _hb_glyph_info_ligated (const hb_glyph_info_t *info) |
| 540 | { |
| 541 | return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATED); |
| 542 | } |
| 543 | |
Behdad Esfahbod | 832a6f9 | 2014-06-04 16:57:42 -0400 | [diff] [blame] | 544 | static inline bool |
| 545 | _hb_glyph_info_multiplied (const hb_glyph_info_t *info) |
| 546 | { |
| 547 | return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED); |
| 548 | } |
| 549 | |
| 550 | static inline bool |
| 551 | _hb_glyph_info_ligated_and_didnt_multiply (const hb_glyph_info_t *info) |
| 552 | { |
| 553 | return _hb_glyph_info_ligated (info) && !_hb_glyph_info_multiplied (info); |
| 554 | } |
| 555 | |
Behdad Esfahbod | 04dc52f | 2014-06-06 17:28:38 -0400 | [diff] [blame] | 556 | static inline void |
| 557 | _hb_glyph_info_clear_ligated_and_multiplied (hb_glyph_info_t *info) |
| 558 | { |
| 559 | info->glyph_props() &= ~(HB_OT_LAYOUT_GLYPH_PROPS_LIGATED | |
| 560 | HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED); |
| 561 | } |
| 562 | |
Behdad Esfahbod | 595936e | 2015-07-21 14:15:35 +0100 | [diff] [blame] | 563 | static inline void |
Behdad Esfahbod | 2ab0de9 | 2015-12-17 11:59:15 +0000 | [diff] [blame] | 564 | _hb_glyph_info_clear_substituted (hb_glyph_info_t *info) |
Behdad Esfahbod | 595936e | 2015-07-21 14:15:35 +0100 | [diff] [blame] | 565 | { |
Behdad Esfahbod | 2ab0de9 | 2015-12-17 11:59:15 +0000 | [diff] [blame] | 566 | info->glyph_props() &= ~(HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED); |
Behdad Esfahbod | 595936e | 2015-07-21 14:15:35 +0100 | [diff] [blame] | 567 | } |
| 568 | |
Behdad Esfahbod | 04dc52f | 2014-06-06 17:28:38 -0400 | [diff] [blame] | 569 | |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 570 | /* Allocation / deallocation. */ |
| 571 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 572 | static inline void |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 573 | _hb_buffer_allocate_unicode_vars (hb_buffer_t *buffer) |
| 574 | { |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 575 | HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props); |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 576 | } |
| 577 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 578 | static inline void |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 579 | _hb_buffer_deallocate_unicode_vars (hb_buffer_t *buffer) |
| 580 | { |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 581 | HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props); |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 582 | } |
| 583 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 584 | static inline void |
Behdad Esfahbod | 8f3eebf | 2014-08-02 17:18:46 -0400 | [diff] [blame] | 585 | _hb_buffer_assert_unicode_vars (hb_buffer_t *buffer) |
| 586 | { |
Behdad Esfahbod | 9382c47 | 2015-11-02 17:36:51 -0800 | [diff] [blame] | 587 | HB_BUFFER_ASSERT_VAR (buffer, unicode_props); |
Behdad Esfahbod | 8f3eebf | 2014-08-02 17:18:46 -0400 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | static inline void |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 591 | _hb_buffer_allocate_gsubgpos_vars (hb_buffer_t *buffer) |
| 592 | { |
| 593 | HB_BUFFER_ALLOCATE_VAR (buffer, glyph_props); |
| 594 | HB_BUFFER_ALLOCATE_VAR (buffer, lig_props); |
| 595 | HB_BUFFER_ALLOCATE_VAR (buffer, syllable); |
| 596 | } |
| 597 | |
Behdad Esfahbod | 6faff8e | 2014-04-28 14:29:39 -0700 | [diff] [blame] | 598 | static inline void |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 599 | _hb_buffer_deallocate_gsubgpos_vars (hb_buffer_t *buffer) |
| 600 | { |
| 601 | HB_BUFFER_DEALLOCATE_VAR (buffer, syllable); |
| 602 | HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props); |
| 603 | HB_BUFFER_DEALLOCATE_VAR (buffer, glyph_props); |
| 604 | } |
| 605 | |
Behdad Esfahbod | 8f3eebf | 2014-08-02 17:18:46 -0400 | [diff] [blame] | 606 | static inline void |
| 607 | _hb_buffer_assert_gsubgpos_vars (hb_buffer_t *buffer) |
| 608 | { |
| 609 | HB_BUFFER_ASSERT_VAR (buffer, glyph_props); |
| 610 | HB_BUFFER_ASSERT_VAR (buffer, lig_props); |
| 611 | HB_BUFFER_ASSERT_VAR (buffer, syllable); |
| 612 | } |
| 613 | |
Behdad Esfahbod | 101303d | 2013-10-18 00:42:39 +0200 | [diff] [blame] | 614 | /* Make sure no one directly touches our props... */ |
| 615 | #undef unicode_props0 |
| 616 | #undef unicode_props1 |
| 617 | #undef lig_props |
| 618 | #undef glyph_props |
Behdad Esfahbod | 2e96d2c | 2013-10-17 21:16:20 +0200 | [diff] [blame] | 619 | |
| 620 | |
Behdad Esfahbod | 0f0cd9d | 2010-06-09 06:32:56 -0400 | [diff] [blame] | 621 | #endif /* HB_OT_LAYOUT_PRIVATE_HH */ |