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