OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2007,2008,2009 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009 Red Hat, Inc. |
3 * Copyright © 2012,2013 Google, Inc. | 3 * Copyright © 2012,2013 Google, Inc. |
4 * | 4 * |
5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
6 * | 6 * |
7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 typedef enum | 43 typedef enum |
44 { | 44 { |
45 /* The following three match LookupFlags::Ignore* numbers. */ | 45 /* The following three match LookupFlags::Ignore* numbers. */ |
46 HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH = 0x02u, | 46 HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH = 0x02u, |
47 HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE = 0x04u, | 47 HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE = 0x04u, |
48 HB_OT_LAYOUT_GLYPH_PROPS_MARK = 0x08u, | 48 HB_OT_LAYOUT_GLYPH_PROPS_MARK = 0x08u, |
49 | 49 |
50 /* The following are used internally; not derived from GDEF. */ | 50 /* The following are used internally; not derived from GDEF. */ |
51 HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED = 0x10u, | 51 HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED = 0x10u, |
52 HB_OT_LAYOUT_GLYPH_PROPS_LIGATED = 0x20u, | 52 HB_OT_LAYOUT_GLYPH_PROPS_LIGATED = 0x20u, |
| 53 HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED = 0x40u, |
53 | 54 |
54 HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE = HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED | | 55 HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE = HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED | |
55 » » » » » HB_OT_LAYOUT_GLYPH_PROPS_LIGATED | 56 » » » » » HB_OT_LAYOUT_GLYPH_PROPS_LIGATED | |
| 57 » » » » » HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED |
56 } hb_ot_layout_glyph_class_mask_t; | 58 } hb_ot_layout_glyph_class_mask_t; |
57 | 59 |
58 | 60 |
59 /* | 61 /* |
60 * GSUB/GPOS | 62 * GSUB/GPOS |
61 */ | 63 */ |
62 | 64 |
63 HB_INTERNAL hb_bool_t | 65 HB_INTERNAL hb_bool_t |
64 hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face, | 66 hb_ot_layout_lookup_would_substitute_fast (hb_face_t *face, |
65 unsigned int lookup_index, | 67 unsigned int lookup_index, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 177 |
176 /* unicode_props */ | 178 /* unicode_props */ |
177 | 179 |
178 enum { | 180 enum { |
179 MASK0_ZWJ = 0x20u, | 181 MASK0_ZWJ = 0x20u, |
180 MASK0_ZWNJ = 0x40u, | 182 MASK0_ZWNJ = 0x40u, |
181 MASK0_IGNORABLE = 0x80u, | 183 MASK0_IGNORABLE = 0x80u, |
182 MASK0_GEN_CAT = 0x1Fu | 184 MASK0_GEN_CAT = 0x1Fu |
183 }; | 185 }; |
184 | 186 |
185 inline void | 187 static inline void |
186 _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *uni
code) | 188 _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *uni
code) |
187 { | 189 { |
188 /* XXX This shouldn't be inlined, or at least not while is_default_ignorable()
is inline. */ | 190 /* XXX This shouldn't be inlined, or at least not while is_default_ignorable()
is inline. */ |
189 info->unicode_props0() = ((unsigned int) unicode->general_category (info->code
point)) | | 191 info->unicode_props0() = ((unsigned int) unicode->general_category (info->code
point)) | |
190 (unicode->is_default_ignorable (info->codepoint) ? MA
SK0_IGNORABLE : 0) | | 192 (unicode->is_default_ignorable (info->codepoint) ? MA
SK0_IGNORABLE : 0) | |
191 » » » (info->codepoint == 0x200C ? MASK0_ZWNJ : 0) | | 193 » » » (info->codepoint == 0x200Cu ? MASK0_ZWNJ : 0) | |
192 » » » (info->codepoint == 0x200D ? MASK0_ZWJ : 0); | 194 » » » (info->codepoint == 0x200Du ? MASK0_ZWJ : 0); |
193 info->unicode_props1() = unicode->modified_combining_class (info->codepoint); | 195 info->unicode_props1() = unicode->modified_combining_class (info->codepoint); |
194 } | 196 } |
195 | 197 |
196 inline void | 198 static inline void |
197 _hb_glyph_info_set_general_category (hb_glyph_info_t *info, | 199 _hb_glyph_info_set_general_category (hb_glyph_info_t *info, |
198 hb_unicode_general_category_t gen_cat) | 200 hb_unicode_general_category_t gen_cat) |
199 { | 201 { |
200 info->unicode_props0() = (unsigned int) gen_cat | ((info->unicode_props0()) &
~MASK0_GEN_CAT); | 202 info->unicode_props0() = (unsigned int) gen_cat | ((info->unicode_props0()) &
~MASK0_GEN_CAT); |
201 } | 203 } |
202 | 204 |
203 inline hb_unicode_general_category_t | 205 static inline hb_unicode_general_category_t |
204 _hb_glyph_info_get_general_category (const hb_glyph_info_t *info) | 206 _hb_glyph_info_get_general_category (const hb_glyph_info_t *info) |
205 { | 207 { |
206 return (hb_unicode_general_category_t) (info->unicode_props0() & MASK0_GEN_CAT
); | 208 return (hb_unicode_general_category_t) (info->unicode_props0() & MASK0_GEN_CAT
); |
207 } | 209 } |
208 | 210 |
209 inline void | 211 static inline void |
210 _hb_glyph_info_set_modified_combining_class (hb_glyph_info_t *info, | 212 _hb_glyph_info_set_modified_combining_class (hb_glyph_info_t *info, |
211 unsigned int modified_class) | 213 unsigned int modified_class) |
212 { | 214 { |
213 info->unicode_props1() = modified_class; | 215 info->unicode_props1() = modified_class; |
214 } | 216 } |
215 | 217 |
216 inline unsigned int | 218 static inline unsigned int |
217 _hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info) | 219 _hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info) |
218 { | 220 { |
219 return info->unicode_props1(); | 221 return info->unicode_props1(); |
220 } | 222 } |
221 | 223 |
222 inline hb_bool_t | 224 static inline hb_bool_t |
223 _hb_glyph_info_is_default_ignorable (const hb_glyph_info_t *info) | 225 _hb_glyph_info_is_default_ignorable (const hb_glyph_info_t *info) |
224 { | 226 { |
225 return !!(info->unicode_props0() & MASK0_IGNORABLE); | 227 return !!(info->unicode_props0() & MASK0_IGNORABLE); |
226 } | 228 } |
227 | 229 |
228 inline hb_bool_t | 230 static inline hb_bool_t |
229 _hb_glyph_info_is_zwnj (const hb_glyph_info_t *info) | 231 _hb_glyph_info_is_zwnj (const hb_glyph_info_t *info) |
230 { | 232 { |
231 return !!(info->unicode_props0() & MASK0_ZWNJ); | 233 return !!(info->unicode_props0() & MASK0_ZWNJ); |
232 } | 234 } |
233 | 235 |
234 inline hb_bool_t | 236 static inline hb_bool_t |
235 _hb_glyph_info_is_zwj (const hb_glyph_info_t *info) | 237 _hb_glyph_info_is_zwj (const hb_glyph_info_t *info) |
236 { | 238 { |
237 return !!(info->unicode_props0() & MASK0_ZWJ); | 239 return !!(info->unicode_props0() & MASK0_ZWJ); |
238 } | 240 } |
239 | 241 |
240 inline void | 242 static inline void |
241 _hb_glyph_info_flip_joiners (hb_glyph_info_t *info) | 243 _hb_glyph_info_flip_joiners (hb_glyph_info_t *info) |
242 { | 244 { |
243 info->unicode_props0() ^= MASK0_ZWNJ | MASK0_ZWJ; | 245 info->unicode_props0() ^= MASK0_ZWNJ | MASK0_ZWJ; |
244 } | 246 } |
245 | 247 |
246 /* lig_props: aka lig_id / lig_comp | 248 /* lig_props: aka lig_id / lig_comp |
247 * | 249 * |
248 * When a ligature is formed: | 250 * When a ligature is formed: |
249 * | 251 * |
250 * - The ligature glyph and any marks in between all the same newly allocated | 252 * - The ligature glyph and any marks in between all the same newly allocated |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 static inline uint8_t | 334 static inline uint8_t |
333 _hb_allocate_lig_id (hb_buffer_t *buffer) { | 335 _hb_allocate_lig_id (hb_buffer_t *buffer) { |
334 uint8_t lig_id = buffer->next_serial () & 0x07; | 336 uint8_t lig_id = buffer->next_serial () & 0x07; |
335 if (unlikely (!lig_id)) | 337 if (unlikely (!lig_id)) |
336 lig_id = _hb_allocate_lig_id (buffer); /* in case of overflow */ | 338 lig_id = _hb_allocate_lig_id (buffer); /* in case of overflow */ |
337 return lig_id; | 339 return lig_id; |
338 } | 340 } |
339 | 341 |
340 /* glyph_props: */ | 342 /* glyph_props: */ |
341 | 343 |
342 inline void | 344 static inline void |
343 _hb_glyph_info_set_glyph_props (hb_glyph_info_t *info, unsigned int props) | 345 _hb_glyph_info_set_glyph_props (hb_glyph_info_t *info, unsigned int props) |
344 { | 346 { |
345 info->glyph_props() = props; | 347 info->glyph_props() = props; |
346 } | 348 } |
347 | 349 |
348 inline unsigned int | 350 static inline unsigned int |
349 _hb_glyph_info_get_glyph_props (const hb_glyph_info_t *info) | 351 _hb_glyph_info_get_glyph_props (const hb_glyph_info_t *info) |
350 { | 352 { |
351 return info->glyph_props(); | 353 return info->glyph_props(); |
352 } | 354 } |
353 | 355 |
354 inline bool | 356 static inline bool |
355 _hb_glyph_info_is_base_glyph (const hb_glyph_info_t *info) | 357 _hb_glyph_info_is_base_glyph (const hb_glyph_info_t *info) |
356 { | 358 { |
357 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH); | 359 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH); |
358 } | 360 } |
359 | 361 |
360 inline bool | 362 static inline bool |
361 _hb_glyph_info_is_ligature (const hb_glyph_info_t *info) | 363 _hb_glyph_info_is_ligature (const hb_glyph_info_t *info) |
362 { | 364 { |
363 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE); | 365 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE); |
364 } | 366 } |
365 | 367 |
366 inline bool | 368 static inline bool |
367 _hb_glyph_info_is_mark (const hb_glyph_info_t *info) | 369 _hb_glyph_info_is_mark (const hb_glyph_info_t *info) |
368 { | 370 { |
369 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK); | 371 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK); |
370 } | 372 } |
371 | 373 |
372 static inline bool | 374 static inline bool |
373 _hb_glyph_info_substituted (const hb_glyph_info_t *info) | 375 _hb_glyph_info_substituted (const hb_glyph_info_t *info) |
374 { | 376 { |
375 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED); | 377 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED); |
376 } | 378 } |
377 | 379 |
378 static inline bool | 380 static inline bool |
379 _hb_glyph_info_ligated (const hb_glyph_info_t *info) | 381 _hb_glyph_info_ligated (const hb_glyph_info_t *info) |
380 { | 382 { |
381 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATED); | 383 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATED); |
382 } | 384 } |
383 | 385 |
| 386 static inline bool |
| 387 _hb_glyph_info_multiplied (const hb_glyph_info_t *info) |
| 388 { |
| 389 return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED); |
| 390 } |
| 391 |
| 392 static inline bool |
| 393 _hb_glyph_info_ligated_and_didnt_multiply (const hb_glyph_info_t *info) |
| 394 { |
| 395 return _hb_glyph_info_ligated (info) && !_hb_glyph_info_multiplied (info); |
| 396 } |
| 397 |
| 398 static inline void |
| 399 _hb_glyph_info_clear_ligated_and_multiplied (hb_glyph_info_t *info) |
| 400 { |
| 401 info->glyph_props() &= ~(HB_OT_LAYOUT_GLYPH_PROPS_LIGATED | |
| 402 HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED); |
| 403 } |
| 404 |
| 405 |
384 /* Allocation / deallocation. */ | 406 /* Allocation / deallocation. */ |
385 | 407 |
386 inline void | 408 static inline void |
387 _hb_buffer_allocate_unicode_vars (hb_buffer_t *buffer) | 409 _hb_buffer_allocate_unicode_vars (hb_buffer_t *buffer) |
388 { | 410 { |
389 HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props0); | 411 HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props0); |
390 HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props1); | 412 HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props1); |
391 } | 413 } |
392 | 414 |
393 inline void | 415 static inline void |
394 _hb_buffer_deallocate_unicode_vars (hb_buffer_t *buffer) | 416 _hb_buffer_deallocate_unicode_vars (hb_buffer_t *buffer) |
395 { | 417 { |
396 HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props0); | 418 HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props0); |
397 HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props1); | 419 HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props1); |
398 } | 420 } |
399 | 421 |
400 inline void | 422 static inline void |
401 _hb_buffer_allocate_gsubgpos_vars (hb_buffer_t *buffer) | 423 _hb_buffer_allocate_gsubgpos_vars (hb_buffer_t *buffer) |
402 { | 424 { |
403 HB_BUFFER_ALLOCATE_VAR (buffer, glyph_props); | 425 HB_BUFFER_ALLOCATE_VAR (buffer, glyph_props); |
404 HB_BUFFER_ALLOCATE_VAR (buffer, lig_props); | 426 HB_BUFFER_ALLOCATE_VAR (buffer, lig_props); |
405 HB_BUFFER_ALLOCATE_VAR (buffer, syllable); | 427 HB_BUFFER_ALLOCATE_VAR (buffer, syllable); |
406 } | 428 } |
407 | 429 |
408 inline void | 430 static inline void |
409 _hb_buffer_deallocate_gsubgpos_vars (hb_buffer_t *buffer) | 431 _hb_buffer_deallocate_gsubgpos_vars (hb_buffer_t *buffer) |
410 { | 432 { |
411 HB_BUFFER_DEALLOCATE_VAR (buffer, syllable); | 433 HB_BUFFER_DEALLOCATE_VAR (buffer, syllable); |
412 HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props); | 434 HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props); |
413 HB_BUFFER_DEALLOCATE_VAR (buffer, glyph_props); | 435 HB_BUFFER_DEALLOCATE_VAR (buffer, glyph_props); |
414 } | 436 } |
415 | 437 |
416 /* Make sure no one directly touches our props... */ | 438 /* Make sure no one directly touches our props... */ |
417 #undef unicode_props0 | 439 #undef unicode_props0 |
418 #undef unicode_props1 | 440 #undef unicode_props1 |
419 #undef lig_props | 441 #undef lig_props |
420 #undef glyph_props | 442 #undef glyph_props |
421 | 443 |
422 | 444 |
423 #endif /* HB_OT_LAYOUT_PRIVATE_HH */ | 445 #endif /* HB_OT_LAYOUT_PRIVATE_HH */ |
OLD | NEW |