| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009,2010 Red Hat, Inc. |
| 3 * Copyright © 2010,2012,2013 Google, Inc. | 3 * Copyright © 2010,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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 unsigned int num_glyphs, | 90 unsigned int num_glyphs, |
| 91 int delta) | 91 int delta) |
| 92 { | 92 { |
| 93 TRACE_SERIALIZE (this); | 93 TRACE_SERIALIZE (this); |
| 94 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 94 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); |
| 95 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); | 95 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); |
| 96 deltaGlyphID.set (delta); /* TODO(serilaize) overflow? */ | 96 deltaGlyphID.set (delta); /* TODO(serilaize) overflow? */ |
| 97 return TRACE_RETURN (true); | 97 return TRACE_RETURN (true); |
| 98 } | 98 } |
| 99 | 99 |
| 100 inline bool sanitize (hb_sanitize_context_t *c) { | 100 inline bool sanitize (hb_sanitize_context_t *c) const |
| 101 { |
| 101 TRACE_SANITIZE (this); | 102 TRACE_SANITIZE (this); |
| 102 return TRACE_RETURN (coverage.sanitize (c, this) && deltaGlyphID.sanitize (c
)); | 103 return TRACE_RETURN (coverage.sanitize (c, this) && deltaGlyphID.sanitize (c
)); |
| 103 } | 104 } |
| 104 | 105 |
| 105 protected: | 106 protected: |
| 106 USHORT format; /* Format identifier--format = 1 */ | 107 USHORT format; /* Format identifier--format = 1 */ |
| 107 OffsetTo<Coverage> | 108 OffsetTo<Coverage> |
| 108 coverage; /* Offset to Coverage table--from | 109 coverage; /* Offset to Coverage table--from |
| 109 * beginning of Substitution table */ | 110 * beginning of Substitution table */ |
| 110 SHORT deltaGlyphID; /* Add to original GlyphID to get | 111 SHORT deltaGlyphID; /* Add to original GlyphID to get |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 Supplier<GlyphID> &substitutes, | 167 Supplier<GlyphID> &substitutes, |
| 167 unsigned int num_glyphs) | 168 unsigned int num_glyphs) |
| 168 { | 169 { |
| 169 TRACE_SERIALIZE (this); | 170 TRACE_SERIALIZE (this); |
| 170 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 171 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); |
| 171 if (unlikely (!substitute.serialize (c, substitutes, num_glyphs))) return TR
ACE_RETURN (false); | 172 if (unlikely (!substitute.serialize (c, substitutes, num_glyphs))) return TR
ACE_RETURN (false); |
| 172 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); | 173 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); |
| 173 return TRACE_RETURN (true); | 174 return TRACE_RETURN (true); |
| 174 } | 175 } |
| 175 | 176 |
| 176 inline bool sanitize (hb_sanitize_context_t *c) { | 177 inline bool sanitize (hb_sanitize_context_t *c) const |
| 178 { |
| 177 TRACE_SANITIZE (this); | 179 TRACE_SANITIZE (this); |
| 178 return TRACE_RETURN (coverage.sanitize (c, this) && substitute.sanitize (c))
; | 180 return TRACE_RETURN (coverage.sanitize (c, this) && substitute.sanitize (c))
; |
| 179 } | 181 } |
| 180 | 182 |
| 181 protected: | 183 protected: |
| 182 USHORT format; /* Format identifier--format = 2 */ | 184 USHORT format; /* Format identifier--format = 2 */ |
| 183 OffsetTo<Coverage> | 185 OffsetTo<Coverage> |
| 184 coverage; /* Offset to Coverage table--from | 186 coverage; /* Offset to Coverage table--from |
| 185 * beginning of Substitution table */ | 187 * beginning of Substitution table */ |
| 186 ArrayOf<GlyphID> | 188 ArrayOf<GlyphID> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 216 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs, del
ta)); | 218 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs, del
ta)); |
| 217 case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, substitutes, nu
m_glyphs)); | 219 case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, substitutes, nu
m_glyphs)); |
| 218 default:return TRACE_RETURN (false); | 220 default:return TRACE_RETURN (false); |
| 219 } | 221 } |
| 220 } | 222 } |
| 221 | 223 |
| 222 template <typename context_t> | 224 template <typename context_t> |
| 223 inline typename context_t::return_t dispatch (context_t *c) const | 225 inline typename context_t::return_t dispatch (context_t *c) const |
| 224 { | 226 { |
| 225 TRACE_DISPATCH (this, u.format); | 227 TRACE_DISPATCH (this, u.format); |
| 228 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); |
| 226 switch (u.format) { | 229 switch (u.format) { |
| 227 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 230 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 228 case 2: return TRACE_RETURN (c->dispatch (u.format2)); | 231 case 2: return TRACE_RETURN (c->dispatch (u.format2)); |
| 229 default:return TRACE_RETURN (c->default_return_value ()); | 232 default:return TRACE_RETURN (c->default_return_value ()); |
| 230 } | 233 } |
| 231 } | 234 } |
| 232 | 235 |
| 233 inline bool sanitize (hb_sanitize_context_t *c) { | |
| 234 TRACE_SANITIZE (this); | |
| 235 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | |
| 236 switch (u.format) { | |
| 237 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | |
| 238 case 2: return TRACE_RETURN (u.format2.sanitize (c)); | |
| 239 default:return TRACE_RETURN (true); | |
| 240 } | |
| 241 } | |
| 242 | |
| 243 protected: | 236 protected: |
| 244 union { | 237 union { |
| 245 USHORT format; /* Format identifier */ | 238 USHORT format; /* Format identifier */ |
| 246 SingleSubstFormat1 format1; | 239 SingleSubstFormat1 format1; |
| 247 SingleSubstFormat2 format2; | 240 SingleSubstFormat2 format2; |
| 248 } u; | 241 } u; |
| 249 }; | 242 }; |
| 250 | 243 |
| 251 | 244 |
| 252 struct Sequence | 245 struct Sequence |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 inline bool serialize (hb_serialize_context_t *c, | 298 inline bool serialize (hb_serialize_context_t *c, |
| 306 Supplier<GlyphID> &glyphs, | 299 Supplier<GlyphID> &glyphs, |
| 307 unsigned int num_glyphs) | 300 unsigned int num_glyphs) |
| 308 { | 301 { |
| 309 TRACE_SERIALIZE (this); | 302 TRACE_SERIALIZE (this); |
| 310 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 303 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); |
| 311 if (unlikely (!substitute.serialize (c, glyphs, num_glyphs))) return TRACE_R
ETURN (false); | 304 if (unlikely (!substitute.serialize (c, glyphs, num_glyphs))) return TRACE_R
ETURN (false); |
| 312 return TRACE_RETURN (true); | 305 return TRACE_RETURN (true); |
| 313 } | 306 } |
| 314 | 307 |
| 315 inline bool sanitize (hb_sanitize_context_t *c) { | 308 inline bool sanitize (hb_sanitize_context_t *c) const |
| 309 { |
| 316 TRACE_SANITIZE (this); | 310 TRACE_SANITIZE (this); |
| 317 return TRACE_RETURN (substitute.sanitize (c)); | 311 return TRACE_RETURN (substitute.sanitize (c)); |
| 318 } | 312 } |
| 319 | 313 |
| 320 protected: | 314 protected: |
| 321 ArrayOf<GlyphID> | 315 ArrayOf<GlyphID> |
| 322 substitute; /* String of GlyphIDs to substitute */ | 316 substitute; /* String of GlyphIDs to substitute */ |
| 323 public: | 317 public: |
| 324 DEFINE_SIZE_ARRAY (2, substitute); | 318 DEFINE_SIZE_ARRAY (2, substitute); |
| 325 }; | 319 }; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 if (unlikely (!sequence.serialize (c, num_glyphs))) return TRACE_RETURN (fal
se); | 371 if (unlikely (!sequence.serialize (c, num_glyphs))) return TRACE_RETURN (fal
se); |
| 378 for (unsigned int i = 0; i < num_glyphs; i++) | 372 for (unsigned int i = 0; i < num_glyphs; i++) |
| 379 if (unlikely (!sequence[i].serialize (c, this).serialize (c, | 373 if (unlikely (!sequence[i].serialize (c, this).serialize (c, |
| 380 substitute_glyph
s_list, | 374 substitute_glyph
s_list, |
| 381 substitute_len_l
ist[i]))) return TRACE_RETURN (false); | 375 substitute_len_l
ist[i]))) return TRACE_RETURN (false); |
| 382 substitute_len_list.advance (num_glyphs); | 376 substitute_len_list.advance (num_glyphs); |
| 383 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); | 377 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); |
| 384 return TRACE_RETURN (true); | 378 return TRACE_RETURN (true); |
| 385 } | 379 } |
| 386 | 380 |
| 387 inline bool sanitize (hb_sanitize_context_t *c) { | 381 inline bool sanitize (hb_sanitize_context_t *c) const |
| 382 { |
| 388 TRACE_SANITIZE (this); | 383 TRACE_SANITIZE (this); |
| 389 return TRACE_RETURN (coverage.sanitize (c, this) && sequence.sanitize (c, th
is)); | 384 return TRACE_RETURN (coverage.sanitize (c, this) && sequence.sanitize (c, th
is)); |
| 390 } | 385 } |
| 391 | 386 |
| 392 protected: | 387 protected: |
| 393 USHORT format; /* Format identifier--format = 1 */ | 388 USHORT format; /* Format identifier--format = 1 */ |
| 394 OffsetTo<Coverage> | 389 OffsetTo<Coverage> |
| 395 coverage; /* Offset to Coverage table--from | 390 coverage; /* Offset to Coverage table--from |
| 396 * beginning of Substitution table */ | 391 * beginning of Substitution table */ |
| 397 OffsetArrayOf<Sequence> | 392 OffsetArrayOf<Sequence> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 416 switch (u.format) { | 411 switch (u.format) { |
| 417 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, substitute_len_
list, num_glyphs, substitute_glyphs_list)); | 412 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, substitute_len_
list, num_glyphs, substitute_glyphs_list)); |
| 418 default:return TRACE_RETURN (false); | 413 default:return TRACE_RETURN (false); |
| 419 } | 414 } |
| 420 } | 415 } |
| 421 | 416 |
| 422 template <typename context_t> | 417 template <typename context_t> |
| 423 inline typename context_t::return_t dispatch (context_t *c) const | 418 inline typename context_t::return_t dispatch (context_t *c) const |
| 424 { | 419 { |
| 425 TRACE_DISPATCH (this, u.format); | 420 TRACE_DISPATCH (this, u.format); |
| 421 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); |
| 426 switch (u.format) { | 422 switch (u.format) { |
| 427 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 423 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 428 default:return TRACE_RETURN (c->default_return_value ()); | 424 default:return TRACE_RETURN (c->default_return_value ()); |
| 429 } | 425 } |
| 430 } | 426 } |
| 431 | 427 |
| 432 inline bool sanitize (hb_sanitize_context_t *c) { | |
| 433 TRACE_SANITIZE (this); | |
| 434 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | |
| 435 switch (u.format) { | |
| 436 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | |
| 437 default:return TRACE_RETURN (true); | |
| 438 } | |
| 439 } | |
| 440 | |
| 441 protected: | 428 protected: |
| 442 union { | 429 union { |
| 443 USHORT format; /* Format identifier */ | 430 USHORT format; /* Format identifier */ |
| 444 MultipleSubstFormat1 format1; | 431 MultipleSubstFormat1 format1; |
| 445 } u; | 432 } u; |
| 446 }; | 433 }; |
| 447 | 434 |
| 448 | 435 |
| 449 typedef ArrayOf<GlyphID> AlternateSet; /* Array of alternate GlyphIDs--in | 436 typedef ArrayOf<GlyphID> AlternateSet; /* Array of alternate GlyphIDs--in |
| 450 * arbitrary order */ | 437 * arbitrary order */ |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 if (unlikely (!alternateSet.serialize (c, num_glyphs))) return TRACE_RETURN
(false); | 515 if (unlikely (!alternateSet.serialize (c, num_glyphs))) return TRACE_RETURN
(false); |
| 529 for (unsigned int i = 0; i < num_glyphs; i++) | 516 for (unsigned int i = 0; i < num_glyphs; i++) |
| 530 if (unlikely (!alternateSet[i].serialize (c, this).serialize (c, | 517 if (unlikely (!alternateSet[i].serialize (c, this).serialize (c, |
| 531 alternate_gl
yphs_list, | 518 alternate_gl
yphs_list, |
| 532 alternate_le
n_list[i]))) return TRACE_RETURN (false); | 519 alternate_le
n_list[i]))) return TRACE_RETURN (false); |
| 533 alternate_len_list.advance (num_glyphs); | 520 alternate_len_list.advance (num_glyphs); |
| 534 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); | 521 if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs
))) return TRACE_RETURN (false); |
| 535 return TRACE_RETURN (true); | 522 return TRACE_RETURN (true); |
| 536 } | 523 } |
| 537 | 524 |
| 538 inline bool sanitize (hb_sanitize_context_t *c) { | 525 inline bool sanitize (hb_sanitize_context_t *c) const |
| 526 { |
| 539 TRACE_SANITIZE (this); | 527 TRACE_SANITIZE (this); |
| 540 return TRACE_RETURN (coverage.sanitize (c, this) && alternateSet.sanitize (c
, this)); | 528 return TRACE_RETURN (coverage.sanitize (c, this) && alternateSet.sanitize (c
, this)); |
| 541 } | 529 } |
| 542 | 530 |
| 543 protected: | 531 protected: |
| 544 USHORT format; /* Format identifier--format = 1 */ | 532 USHORT format; /* Format identifier--format = 1 */ |
| 545 OffsetTo<Coverage> | 533 OffsetTo<Coverage> |
| 546 coverage; /* Offset to Coverage table--from | 534 coverage; /* Offset to Coverage table--from |
| 547 * beginning of Substitution table */ | 535 * beginning of Substitution table */ |
| 548 OffsetArrayOf<AlternateSet> | 536 OffsetArrayOf<AlternateSet> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 567 switch (u.format) { | 555 switch (u.format) { |
| 568 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, alternate_len_l
ist, num_glyphs, alternate_glyphs_list)); | 556 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, alternate_len_l
ist, num_glyphs, alternate_glyphs_list)); |
| 569 default:return TRACE_RETURN (false); | 557 default:return TRACE_RETURN (false); |
| 570 } | 558 } |
| 571 } | 559 } |
| 572 | 560 |
| 573 template <typename context_t> | 561 template <typename context_t> |
| 574 inline typename context_t::return_t dispatch (context_t *c) const | 562 inline typename context_t::return_t dispatch (context_t *c) const |
| 575 { | 563 { |
| 576 TRACE_DISPATCH (this, u.format); | 564 TRACE_DISPATCH (this, u.format); |
| 565 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); |
| 577 switch (u.format) { | 566 switch (u.format) { |
| 578 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 567 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 579 default:return TRACE_RETURN (c->default_return_value ()); | 568 default:return TRACE_RETURN (c->default_return_value ()); |
| 580 } | 569 } |
| 581 } | 570 } |
| 582 | 571 |
| 583 inline bool sanitize (hb_sanitize_context_t *c) { | |
| 584 TRACE_SANITIZE (this); | |
| 585 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | |
| 586 switch (u.format) { | |
| 587 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | |
| 588 default:return TRACE_RETURN (true); | |
| 589 } | |
| 590 } | |
| 591 | |
| 592 protected: | 572 protected: |
| 593 union { | 573 union { |
| 594 USHORT format; /* Format identifier */ | 574 USHORT format; /* Format identifier */ |
| 595 AlternateSubstFormat1 format1; | 575 AlternateSubstFormat1 format1; |
| 596 } u; | 576 } u; |
| 597 }; | 577 }; |
| 598 | 578 |
| 599 | 579 |
| 600 struct Ligature | 580 struct Ligature |
| 601 { | 581 { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 unsigned int num_components /* Including first componen
t */) | 659 unsigned int num_components /* Including first componen
t */) |
| 680 { | 660 { |
| 681 TRACE_SERIALIZE (this); | 661 TRACE_SERIALIZE (this); |
| 682 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); | 662 if (unlikely (!c->extend_min (*this))) return TRACE_RETURN (false); |
| 683 ligGlyph = ligature; | 663 ligGlyph = ligature; |
| 684 if (unlikely (!component.serialize (c, components, num_components))) return
TRACE_RETURN (false); | 664 if (unlikely (!component.serialize (c, components, num_components))) return
TRACE_RETURN (false); |
| 685 return TRACE_RETURN (true); | 665 return TRACE_RETURN (true); |
| 686 } | 666 } |
| 687 | 667 |
| 688 public: | 668 public: |
| 689 inline bool sanitize (hb_sanitize_context_t *c) { | 669 inline bool sanitize (hb_sanitize_context_t *c) const |
| 670 { |
| 690 TRACE_SANITIZE (this); | 671 TRACE_SANITIZE (this); |
| 691 return TRACE_RETURN (ligGlyph.sanitize (c) && component.sanitize (c)); | 672 return TRACE_RETURN (ligGlyph.sanitize (c) && component.sanitize (c)); |
| 692 } | 673 } |
| 693 | 674 |
| 694 protected: | 675 protected: |
| 695 GlyphID ligGlyph; /* GlyphID of ligature to substitute */ | 676 GlyphID ligGlyph; /* GlyphID of ligature to substitute */ |
| 696 HeadlessArrayOf<GlyphID> | 677 HeadlessArrayOf<GlyphID> |
| 697 component; /* Array of component GlyphIDs--start | 678 component; /* Array of component GlyphIDs--start |
| 698 * with the second component--ordered | 679 * with the second component--ordered |
| 699 * in writing direction */ | 680 * in writing direction */ |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 for (unsigned int i = 0; i < num_ligatures; i++) | 738 for (unsigned int i = 0; i < num_ligatures; i++) |
| 758 if (unlikely (!ligature[i].serialize (c, this).serialize (c, | 739 if (unlikely (!ligature[i].serialize (c, this).serialize (c, |
| 759 ligatures[i], | 740 ligatures[i], |
| 760 component_list, | 741 component_list, |
| 761 component_count_
list[i]))) return TRACE_RETURN (false); | 742 component_count_
list[i]))) return TRACE_RETURN (false); |
| 762 ligatures.advance (num_ligatures); | 743 ligatures.advance (num_ligatures); |
| 763 component_count_list.advance (num_ligatures); | 744 component_count_list.advance (num_ligatures); |
| 764 return TRACE_RETURN (true); | 745 return TRACE_RETURN (true); |
| 765 } | 746 } |
| 766 | 747 |
| 767 inline bool sanitize (hb_sanitize_context_t *c) { | 748 inline bool sanitize (hb_sanitize_context_t *c) const |
| 749 { |
| 768 TRACE_SANITIZE (this); | 750 TRACE_SANITIZE (this); |
| 769 return TRACE_RETURN (ligature.sanitize (c, this)); | 751 return TRACE_RETURN (ligature.sanitize (c, this)); |
| 770 } | 752 } |
| 771 | 753 |
| 772 protected: | 754 protected: |
| 773 OffsetArrayOf<Ligature> | 755 OffsetArrayOf<Ligature> |
| 774 ligature; /* Array LigatureSet tables | 756 ligature; /* Array LigatureSet tables |
| 775 * ordered by preference */ | 757 * ordered by preference */ |
| 776 public: | 758 public: |
| 777 DEFINE_SIZE_ARRAY (2, ligature); | 759 DEFINE_SIZE_ARRAY (2, ligature); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 if (unlikely (!ligatureSet[i].serialize (c, this).serialize (c, | 823 if (unlikely (!ligatureSet[i].serialize (c, this).serialize (c, |
| 842 ligatures_lis
t, | 824 ligatures_lis
t, |
| 843 component_cou
nt_list, | 825 component_cou
nt_list, |
| 844 ligature_per_
first_glyph_count_list[i], | 826 ligature_per_
first_glyph_count_list[i], |
| 845 component_lis
t))) return TRACE_RETURN (false); | 827 component_lis
t))) return TRACE_RETURN (false); |
| 846 ligature_per_first_glyph_count_list.advance (num_first_glyphs); | 828 ligature_per_first_glyph_count_list.advance (num_first_glyphs); |
| 847 if (unlikely (!coverage.serialize (c, this).serialize (c, first_glyphs, num_
first_glyphs))) return TRACE_RETURN (false); | 829 if (unlikely (!coverage.serialize (c, this).serialize (c, first_glyphs, num_
first_glyphs))) return TRACE_RETURN (false); |
| 848 return TRACE_RETURN (true); | 830 return TRACE_RETURN (true); |
| 849 } | 831 } |
| 850 | 832 |
| 851 inline bool sanitize (hb_sanitize_context_t *c) { | 833 inline bool sanitize (hb_sanitize_context_t *c) const |
| 834 { |
| 852 TRACE_SANITIZE (this); | 835 TRACE_SANITIZE (this); |
| 853 return TRACE_RETURN (coverage.sanitize (c, this) && ligatureSet.sanitize (c,
this)); | 836 return TRACE_RETURN (coverage.sanitize (c, this) && ligatureSet.sanitize (c,
this)); |
| 854 } | 837 } |
| 855 | 838 |
| 856 protected: | 839 protected: |
| 857 USHORT format; /* Format identifier--format = 1 */ | 840 USHORT format; /* Format identifier--format = 1 */ |
| 858 OffsetTo<Coverage> | 841 OffsetTo<Coverage> |
| 859 coverage; /* Offset to Coverage table--from | 842 coverage; /* Offset to Coverage table--from |
| 860 * beginning of Substitution table */ | 843 * beginning of Substitution table */ |
| 861 OffsetArrayOf<LigatureSet> | 844 OffsetArrayOf<LigatureSet> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 883 case 1: return TRACE_RETURN (u.format1.serialize (c, first_glyphs, ligature_
per_first_glyph_count_list, num_first_glyphs, | 866 case 1: return TRACE_RETURN (u.format1.serialize (c, first_glyphs, ligature_
per_first_glyph_count_list, num_first_glyphs, |
| 884 ligatures_list, component_
count_list, component_list)); | 867 ligatures_list, component_
count_list, component_list)); |
| 885 default:return TRACE_RETURN (false); | 868 default:return TRACE_RETURN (false); |
| 886 } | 869 } |
| 887 } | 870 } |
| 888 | 871 |
| 889 template <typename context_t> | 872 template <typename context_t> |
| 890 inline typename context_t::return_t dispatch (context_t *c) const | 873 inline typename context_t::return_t dispatch (context_t *c) const |
| 891 { | 874 { |
| 892 TRACE_DISPATCH (this, u.format); | 875 TRACE_DISPATCH (this, u.format); |
| 876 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); |
| 893 switch (u.format) { | 877 switch (u.format) { |
| 894 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 878 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 895 default:return TRACE_RETURN (c->default_return_value ()); | 879 default:return TRACE_RETURN (c->default_return_value ()); |
| 896 } | 880 } |
| 897 } | 881 } |
| 898 | 882 |
| 899 inline bool sanitize (hb_sanitize_context_t *c) { | |
| 900 TRACE_SANITIZE (this); | |
| 901 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | |
| 902 switch (u.format) { | |
| 903 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | |
| 904 default:return TRACE_RETURN (true); | |
| 905 } | |
| 906 } | |
| 907 | |
| 908 protected: | 883 protected: |
| 909 union { | 884 union { |
| 910 USHORT format; /* Format identifier */ | 885 USHORT format; /* Format identifier */ |
| 911 LigatureSubstFormat1 format1; | 886 LigatureSubstFormat1 format1; |
| 912 } u; | 887 } u; |
| 913 }; | 888 }; |
| 914 | 889 |
| 915 | 890 |
| 916 struct ContextSubst : Context {}; | 891 struct ContextSubst : Context {}; |
| 917 | 892 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 c->replace_glyph_inplace (substitute[index]); | 985 c->replace_glyph_inplace (substitute[index]); |
| 1011 /* Note: We DON'T decrease buffer->idx. The main loop does it | 986 /* Note: We DON'T decrease buffer->idx. The main loop does it |
| 1012 * for us. This is useful for preventing surprises if someone | 987 * for us. This is useful for preventing surprises if someone |
| 1013 * calls us through a Context lookup. */ | 988 * calls us through a Context lookup. */ |
| 1014 return TRACE_RETURN (true); | 989 return TRACE_RETURN (true); |
| 1015 } | 990 } |
| 1016 | 991 |
| 1017 return TRACE_RETURN (false); | 992 return TRACE_RETURN (false); |
| 1018 } | 993 } |
| 1019 | 994 |
| 1020 inline bool sanitize (hb_sanitize_context_t *c) { | 995 inline bool sanitize (hb_sanitize_context_t *c) const |
| 996 { |
| 1021 TRACE_SANITIZE (this); | 997 TRACE_SANITIZE (this); |
| 1022 if (!(coverage.sanitize (c, this) && backtrack.sanitize (c, this))) | 998 if (!(coverage.sanitize (c, this) && backtrack.sanitize (c, this))) |
| 1023 return TRACE_RETURN (false); | 999 return TRACE_RETURN (false); |
| 1024 OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (
backtrack); | 1000 const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverag
e> > (backtrack); |
| 1025 if (!lookahead.sanitize (c, this)) | 1001 if (!lookahead.sanitize (c, this)) |
| 1026 return TRACE_RETURN (false); | 1002 return TRACE_RETURN (false); |
| 1027 ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead); | 1003 const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahe
ad); |
| 1028 return TRACE_RETURN (substitute.sanitize (c)); | 1004 return TRACE_RETURN (substitute.sanitize (c)); |
| 1029 } | 1005 } |
| 1030 | 1006 |
| 1031 protected: | 1007 protected: |
| 1032 USHORT format; /* Format identifier--format = 1 */ | 1008 USHORT format; /* Format identifier--format = 1 */ |
| 1033 OffsetTo<Coverage> | 1009 OffsetTo<Coverage> |
| 1034 coverage; /* Offset to Coverage table--from | 1010 coverage; /* Offset to Coverage table--from |
| 1035 * beginning of table */ | 1011 * beginning of table */ |
| 1036 OffsetArrayOf<Coverage> | 1012 OffsetArrayOf<Coverage> |
| 1037 backtrack; /* Array of coverage tables | 1013 backtrack; /* Array of coverage tables |
| 1038 * in backtracking sequence, in glyph | 1014 * in backtracking sequence, in glyph |
| 1039 * sequence order */ | 1015 * sequence order */ |
| 1040 OffsetArrayOf<Coverage> | 1016 OffsetArrayOf<Coverage> |
| 1041 lookaheadX; /* Array of coverage tables | 1017 lookaheadX; /* Array of coverage tables |
| 1042 * in lookahead sequence, in glyph | 1018 * in lookahead sequence, in glyph |
| 1043 * sequence order */ | 1019 * sequence order */ |
| 1044 ArrayOf<GlyphID> | 1020 ArrayOf<GlyphID> |
| 1045 substituteX; /* Array of substitute | 1021 substituteX; /* Array of substitute |
| 1046 * GlyphIDs--ordered by Coverage Index *
/ | 1022 * GlyphIDs--ordered by Coverage Index *
/ |
| 1047 public: | 1023 public: |
| 1048 DEFINE_SIZE_MIN (10); | 1024 DEFINE_SIZE_MIN (10); |
| 1049 }; | 1025 }; |
| 1050 | 1026 |
| 1051 struct ReverseChainSingleSubst | 1027 struct ReverseChainSingleSubst |
| 1052 { | 1028 { |
| 1053 template <typename context_t> | 1029 template <typename context_t> |
| 1054 inline typename context_t::return_t dispatch (context_t *c) const | 1030 inline typename context_t::return_t dispatch (context_t *c) const |
| 1055 { | 1031 { |
| 1056 TRACE_DISPATCH (this, u.format); | 1032 TRACE_DISPATCH (this, u.format); |
| 1033 if (unlikely (!c->may_dispatch (this, &u.format))) TRACE_RETURN (c->default_
return_value ()); |
| 1057 switch (u.format) { | 1034 switch (u.format) { |
| 1058 case 1: return TRACE_RETURN (c->dispatch (u.format1)); | 1035 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 1059 default:return TRACE_RETURN (c->default_return_value ()); | 1036 default:return TRACE_RETURN (c->default_return_value ()); |
| 1060 } | 1037 } |
| 1061 } | 1038 } |
| 1062 | 1039 |
| 1063 inline bool sanitize (hb_sanitize_context_t *c) { | |
| 1064 TRACE_SANITIZE (this); | |
| 1065 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | |
| 1066 switch (u.format) { | |
| 1067 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | |
| 1068 default:return TRACE_RETURN (true); | |
| 1069 } | |
| 1070 } | |
| 1071 | |
| 1072 protected: | 1040 protected: |
| 1073 union { | 1041 union { |
| 1074 USHORT format; /* Format identifier */ | 1042 USHORT format; /* Format identifier */ |
| 1075 ReverseChainSingleSubstFormat1 format1; | 1043 ReverseChainSingleSubstFormat1 format1; |
| 1076 } u; | 1044 } u; |
| 1077 }; | 1045 }; |
| 1078 | 1046 |
| 1079 | 1047 |
| 1080 | 1048 |
| 1081 /* | 1049 /* |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1094 Context = 5, | 1062 Context = 5, |
| 1095 ChainContext = 6, | 1063 ChainContext = 6, |
| 1096 Extension = 7, | 1064 Extension = 7, |
| 1097 ReverseChainSingle = 8 | 1065 ReverseChainSingle = 8 |
| 1098 }; | 1066 }; |
| 1099 | 1067 |
| 1100 template <typename context_t> | 1068 template <typename context_t> |
| 1101 inline typename context_t::return_t dispatch (context_t *c, unsigned int looku
p_type) const | 1069 inline typename context_t::return_t dispatch (context_t *c, unsigned int looku
p_type) const |
| 1102 { | 1070 { |
| 1103 TRACE_DISPATCH (this, lookup_type); | 1071 TRACE_DISPATCH (this, lookup_type); |
| 1072 /* The sub_format passed to may_dispatch is unnecessary but harmless. */ |
| 1073 if (unlikely (!c->may_dispatch (this, &u.sub_format))) TRACE_RETURN (c->defa
ult_return_value ()); |
| 1104 switch (lookup_type) { | 1074 switch (lookup_type) { |
| 1105 case Single: return TRACE_RETURN (u.single.dispatch (c)); | 1075 case Single: return TRACE_RETURN (u.single.dispatch (c)); |
| 1106 case Multiple: return TRACE_RETURN (u.multiple.dispatch (c)); | 1076 case Multiple: return TRACE_RETURN (u.multiple.dispatch (c)); |
| 1107 case Alternate: return TRACE_RETURN (u.alternate.dispatch (c)); | 1077 case Alternate: return TRACE_RETURN (u.alternate.dispatch (c)); |
| 1108 case Ligature: return TRACE_RETURN (u.ligature.dispatch (c)); | 1078 case Ligature: return TRACE_RETURN (u.ligature.dispatch (c)); |
| 1109 case Context: return TRACE_RETURN (u.context.dispatch (c)); | 1079 case Context: return TRACE_RETURN (u.context.dispatch (c)); |
| 1110 case ChainContext: return TRACE_RETURN (u.chainContext.dispatch (c)
); | 1080 case ChainContext: return TRACE_RETURN (u.chainContext.dispatch (c)
); |
| 1111 case Extension: return TRACE_RETURN (u.extension.dispatch (c)); | 1081 case Extension: return TRACE_RETURN (u.extension.dispatch (c)); |
| 1112 case ReverseChainSingle: return TRACE_RETURN (u.reverseChainContextSingle
.dispatch (c)); | 1082 case ReverseChainSingle: return TRACE_RETURN (u.reverseChainContextSingle
.dispatch (c)); |
| 1113 default: return TRACE_RETURN (c->default_return_value ())
; | 1083 default: return TRACE_RETURN (c->default_return_value ())
; |
| 1114 } | 1084 } |
| 1115 } | 1085 } |
| 1116 | 1086 |
| 1117 inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) { | |
| 1118 TRACE_SANITIZE (this); | |
| 1119 if (!u.header.sub_format.sanitize (c)) | |
| 1120 return TRACE_RETURN (false); | |
| 1121 switch (lookup_type) { | |
| 1122 case Single: return TRACE_RETURN (u.single.sanitize (c)); | |
| 1123 case Multiple: return TRACE_RETURN (u.multiple.sanitize (c)); | |
| 1124 case Alternate: return TRACE_RETURN (u.alternate.sanitize (c)); | |
| 1125 case Ligature: return TRACE_RETURN (u.ligature.sanitize (c)); | |
| 1126 case Context: return TRACE_RETURN (u.context.sanitize (c)); | |
| 1127 case ChainContext: return TRACE_RETURN (u.chainContext.sanitize (c)
); | |
| 1128 case Extension: return TRACE_RETURN (u.extension.sanitize (c)); | |
| 1129 case ReverseChainSingle: return TRACE_RETURN (u.reverseChainContextSingle
.sanitize (c)); | |
| 1130 default: return TRACE_RETURN (true); | |
| 1131 } | |
| 1132 } | |
| 1133 | |
| 1134 protected: | 1087 protected: |
| 1135 union { | 1088 union { |
| 1136 struct { | 1089 USHORT» » » sub_format; |
| 1137 USHORT» » » sub_format; | |
| 1138 } header; | |
| 1139 SingleSubst single; | 1090 SingleSubst single; |
| 1140 MultipleSubst multiple; | 1091 MultipleSubst multiple; |
| 1141 AlternateSubst alternate; | 1092 AlternateSubst alternate; |
| 1142 LigatureSubst ligature; | 1093 LigatureSubst ligature; |
| 1143 ContextSubst context; | 1094 ContextSubst context; |
| 1144 ChainContextSubst chainContext; | 1095 ChainContextSubst chainContext; |
| 1145 ExtensionSubst extension; | 1096 ExtensionSubst extension; |
| 1146 ReverseChainSingleSubst reverseChainContextSingle; | 1097 ReverseChainSingleSubst reverseChainContextSingle; |
| 1147 } u; | 1098 } u; |
| 1148 public: | 1099 public: |
| 1149 DEFINE_SIZE_UNION (2, header.sub_format); | 1100 DEFINE_SIZE_UNION (2, sub_format); |
| 1150 }; | 1101 }; |
| 1151 | 1102 |
| 1152 | 1103 |
| 1153 struct SubstLookup : Lookup | 1104 struct SubstLookup : Lookup |
| 1154 { | 1105 { |
| 1155 inline const SubstLookupSubTable& get_subtable (unsigned int i) const | 1106 inline const SubstLookupSubTable& get_subtable (unsigned int i) const |
| 1156 { return this+CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable)[i]; } | 1107 { return Lookup::get_subtable<SubstLookupSubTable> (i); } |
| 1157 | 1108 |
| 1158 inline static bool lookup_type_is_reverse (unsigned int lookup_type) | 1109 inline static bool lookup_type_is_reverse (unsigned int lookup_type) |
| 1159 { return lookup_type == SubstLookupSubTable::ReverseChainSingle; } | 1110 { return lookup_type == SubstLookupSubTable::ReverseChainSingle; } |
| 1160 | 1111 |
| 1161 inline bool is_reverse (void) const | 1112 inline bool is_reverse (void) const |
| 1162 { | 1113 { |
| 1163 unsigned int type = get_type (); | 1114 unsigned int type = get_type (); |
| 1164 if (unlikely (type == SubstLookupSubTable::Extension)) | 1115 if (unlikely (type == SubstLookupSubTable::Extension)) |
| 1165 return CastR<ExtensionSubst> (get_subtable(0)).is_reverse (); | 1116 return CastR<ExtensionSubst> (get_subtable(0)).is_reverse (); |
| 1166 return lookup_type_is_reverse (type); | 1117 return lookup_type_is_reverse (type); |
| 1167 } | 1118 } |
| 1168 | 1119 |
| 1120 inline bool apply (hb_apply_context_t *c) const |
| 1121 { |
| 1122 TRACE_APPLY (this); |
| 1123 return TRACE_RETURN (dispatch (c)); |
| 1124 } |
| 1125 |
| 1169 inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const | 1126 inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const |
| 1170 { | 1127 { |
| 1171 TRACE_CLOSURE (this); | 1128 TRACE_CLOSURE (this); |
| 1172 c->set_recurse_func (dispatch_recurse_func<hb_closure_context_t>); | 1129 c->set_recurse_func (dispatch_recurse_func<hb_closure_context_t>); |
| 1173 return TRACE_RETURN (dispatch (c)); | 1130 return TRACE_RETURN (dispatch (c)); |
| 1174 } | 1131 } |
| 1175 | 1132 |
| 1176 inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs
_context_t *c) const | 1133 inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs
_context_t *c) const |
| 1177 { | 1134 { |
| 1178 TRACE_COLLECT_GLYPHS (this); | 1135 TRACE_COLLECT_GLYPHS (this); |
| 1179 c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>); | 1136 c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>); |
| 1180 return TRACE_RETURN (dispatch (c)); | 1137 return TRACE_RETURN (dispatch (c)); |
| 1181 } | 1138 } |
| 1182 | 1139 |
| 1183 template <typename set_t> | 1140 template <typename set_t> |
| 1184 inline void add_coverage (set_t *glyphs) const | 1141 inline void add_coverage (set_t *glyphs) const |
| 1185 { | 1142 { |
| 1186 hb_get_coverage_context_t c; | 1143 hb_add_coverage_context_t<set_t> c (glyphs); |
| 1187 const Coverage *last = NULL; | 1144 dispatch (&c); |
| 1188 unsigned int count = get_subtable_count (); | |
| 1189 for (unsigned int i = 0; i < count; i++) { | |
| 1190 const Coverage *coverage = &get_subtable (i).dispatch (&c, get_type ()); | |
| 1191 if (coverage != last) { | |
| 1192 coverage->add_coverage (glyphs); | |
| 1193 last = coverage; | |
| 1194 } | |
| 1195 } | |
| 1196 } | 1145 } |
| 1197 | 1146 |
| 1198 inline bool would_apply (hb_would_apply_context_t *c, const hb_set_digest_t *d
igest) const | 1147 inline bool would_apply (hb_would_apply_context_t *c, |
| 1148 » » » const hb_ot_layout_lookup_accelerator_t *accel) const |
| 1199 { | 1149 { |
| 1200 TRACE_WOULD_APPLY (this); | 1150 TRACE_WOULD_APPLY (this); |
| 1201 if (unlikely (!c->len)) return TRACE_RETURN (false); | 1151 if (unlikely (!c->len)) return TRACE_RETURN (false); |
| 1202 if (!digest->may_have (c->glyphs[0])) return TRACE_RETURN (false); | 1152 if (!accel->may_have (c->glyphs[0])) return TRACE_RETURN (false); |
| 1203 return TRACE_RETURN (dispatch (c)); | 1153 return TRACE_RETURN (dispatch (c)); |
| 1204 } | 1154 } |
| 1205 | 1155 |
| 1206 inline bool apply_once (hb_apply_context_t *c) const | |
| 1207 { | |
| 1208 TRACE_APPLY (this); | |
| 1209 if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props)) | |
| 1210 return TRACE_RETURN (false); | |
| 1211 return TRACE_RETURN (dispatch (c)); | |
| 1212 } | |
| 1213 | |
| 1214 static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_ind
ex); | 1156 static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_ind
ex); |
| 1215 | 1157 |
| 1216 inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c, | 1158 inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c, |
| 1217 unsigned int i) | 1159 unsigned int i) |
| 1218 { return CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable)[i].serialize (c
, this); } | 1160 { return get_subtables<SubstLookupSubTable> ()[i].serialize (c, this); } |
| 1219 | 1161 |
| 1220 inline bool serialize_single (hb_serialize_context_t *c, | 1162 inline bool serialize_single (hb_serialize_context_t *c, |
| 1221 uint32_t lookup_props, | 1163 uint32_t lookup_props, |
| 1222 Supplier<GlyphID> &glyphs, | 1164 Supplier<GlyphID> &glyphs, |
| 1223 Supplier<GlyphID> &substitutes, | 1165 Supplier<GlyphID> &substitutes, |
| 1224 unsigned int num_glyphs) | 1166 unsigned int num_glyphs) |
| 1225 { | 1167 { |
| 1226 TRACE_SERIALIZE (this); | 1168 TRACE_SERIALIZE (this); |
| 1227 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Single, lookup_pro
ps, 1))) return TRACE_RETURN (false); | 1169 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Single, lookup_pro
ps, 1))) return TRACE_RETURN (false); |
| 1228 return TRACE_RETURN (serialize_subtable (c, 0).u.single.serialize (c, glyphs
, substitutes, num_glyphs)); | 1170 return TRACE_RETURN (serialize_subtable (c, 0).u.single.serialize (c, glyphs
, substitutes, num_glyphs)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Ligature, lookup_p
rops, 1))) return TRACE_RETURN (false); | 1209 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Ligature, lookup_p
rops, 1))) return TRACE_RETURN (false); |
| 1268 return TRACE_RETURN (serialize_subtable (c, 0).u.ligature.serialize (c, firs
t_glyphs, ligature_per_first_glyph_count_list, num_first_glyphs, | 1210 return TRACE_RETURN (serialize_subtable (c, 0).u.ligature.serialize (c, firs
t_glyphs, ligature_per_first_glyph_count_list, num_first_glyphs, |
| 1269 ligatur
es_list, component_count_list, component_list)); | 1211 ligatur
es_list, component_count_list, component_list)); |
| 1270 } | 1212 } |
| 1271 | 1213 |
| 1272 template <typename context_t> | 1214 template <typename context_t> |
| 1273 static inline typename context_t::return_t dispatch_recurse_func (context_t *c
, unsigned int lookup_index); | 1215 static inline typename context_t::return_t dispatch_recurse_func (context_t *c
, unsigned int lookup_index); |
| 1274 | 1216 |
| 1275 template <typename context_t> | 1217 template <typename context_t> |
| 1276 inline typename context_t::return_t dispatch (context_t *c) const | 1218 inline typename context_t::return_t dispatch (context_t *c) const |
| 1277 { | 1219 { return Lookup::dispatch<SubstLookupSubTable> (c); } |
| 1278 unsigned int lookup_type = get_type (); | |
| 1279 TRACE_DISPATCH (this, lookup_type); | |
| 1280 unsigned int count = get_subtable_count (); | |
| 1281 for (unsigned int i = 0; i < count; i++) { | |
| 1282 typename context_t::return_t r = get_subtable (i).dispatch (c, lookup_type
); | |
| 1283 if (c->stop_sublookup_iteration (r)) | |
| 1284 return TRACE_RETURN (r); | |
| 1285 } | |
| 1286 return TRACE_RETURN (c->default_return_value ()); | |
| 1287 } | |
| 1288 | 1220 |
| 1289 inline bool sanitize (hb_sanitize_context_t *c) | 1221 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1290 { | 1222 { |
| 1291 TRACE_SANITIZE (this); | 1223 TRACE_SANITIZE (this); |
| 1292 if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); | 1224 if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); |
| 1293 OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSu
bTable> > (subTable); | 1225 const OffsetArrayOf<SubstLookupSubTable> &list = get_subtables<SubstLookupSu
bTable> (); |
| 1294 if (unlikely (!list.sanitize (c, this, get_type ()))) return TRACE_RETURN (f
alse); | 1226 if (unlikely (!dispatch (c))) return TRACE_RETURN (false); |
| 1295 | 1227 |
| 1296 if (unlikely (get_type () == SubstLookupSubTable::Extension)) | 1228 if (unlikely (get_type () == SubstLookupSubTable::Extension)) |
| 1297 { | 1229 { |
| 1298 /* The spec says all subtables of an Extension lookup should | 1230 /* The spec says all subtables of an Extension lookup should |
| 1299 * have the same type. This is specially important if one has | 1231 * have the same type. This is specially important if one has |
| 1300 * a reverse type! */ | 1232 * a reverse type! */ |
| 1301 unsigned int type = get_subtable (0).u.extension.get_type (); | 1233 unsigned int type = get_subtable (0).u.extension.get_type (); |
| 1302 unsigned int count = get_subtable_count (); | 1234 unsigned int count = get_subtable_count (); |
| 1303 for (unsigned int i = 1; i < count; i++) | 1235 for (unsigned int i = 1; i < count; i++) |
| 1304 if (get_subtable (i).u.extension.get_type () != type) | 1236 if (get_subtable (i).u.extension.get_type () != type) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1317 struct GSUB : GSUBGPOS | 1249 struct GSUB : GSUBGPOS |
| 1318 { | 1250 { |
| 1319 static const hb_tag_t tableTag = HB_OT_TAG_GSUB; | 1251 static const hb_tag_t tableTag = HB_OT_TAG_GSUB; |
| 1320 | 1252 |
| 1321 inline const SubstLookup& get_lookup (unsigned int i) const | 1253 inline const SubstLookup& get_lookup (unsigned int i) const |
| 1322 { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); } | 1254 { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); } |
| 1323 | 1255 |
| 1324 static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer); | 1256 static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer); |
| 1325 static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer); | 1257 static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer); |
| 1326 | 1258 |
| 1327 inline bool sanitize (hb_sanitize_context_t *c) { | 1259 inline bool sanitize (hb_sanitize_context_t *c) const |
| 1260 { |
| 1328 TRACE_SANITIZE (this); | 1261 TRACE_SANITIZE (this); |
| 1329 if (unlikely (!GSUBGPOS::sanitize (c))) return TRACE_RETURN (false); | 1262 if (unlikely (!GSUBGPOS::sanitize (c))) return TRACE_RETURN (false); |
| 1330 OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupL
ist); | 1263 const OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (l
ookupList); |
| 1331 return TRACE_RETURN (list.sanitize (c, this)); | 1264 return TRACE_RETURN (list.sanitize (c, this)); |
| 1332 } | 1265 } |
| 1333 public: | 1266 public: |
| 1334 DEFINE_SIZE_STATIC (10); | 1267 DEFINE_SIZE_STATIC (10); |
| 1335 }; | 1268 }; |
| 1336 | 1269 |
| 1337 | 1270 |
| 1338 void | 1271 void |
| 1339 GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) | 1272 GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) |
| 1340 { | 1273 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1355 { | 1288 { |
| 1356 } | 1289 } |
| 1357 | 1290 |
| 1358 | 1291 |
| 1359 /* Out-of-class implementation for methods recursing */ | 1292 /* Out-of-class implementation for methods recursing */ |
| 1360 | 1293 |
| 1361 /*static*/ inline bool ExtensionSubst::is_reverse (void) const | 1294 /*static*/ inline bool ExtensionSubst::is_reverse (void) const |
| 1362 { | 1295 { |
| 1363 unsigned int type = get_type (); | 1296 unsigned int type = get_type (); |
| 1364 if (unlikely (type == SubstLookupSubTable::Extension)) | 1297 if (unlikely (type == SubstLookupSubTable::Extension)) |
| 1365 return CastR<ExtensionSubst> (get_subtable<SubstLookupSubTable>()).is_revers
e (); | 1298 return CastR<ExtensionSubst> (get_subtable<LookupSubTable>()).is_reverse (); |
| 1366 return SubstLookup::lookup_type_is_reverse (type); | 1299 return SubstLookup::lookup_type_is_reverse (type); |
| 1367 } | 1300 } |
| 1368 | 1301 |
| 1369 template <typename context_t> | 1302 template <typename context_t> |
| 1370 /*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_fun
c (context_t *c, unsigned int lookup_index) | 1303 /*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_fun
c (context_t *c, unsigned int lookup_index) |
| 1371 { | 1304 { |
| 1372 const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); | 1305 const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); |
| 1373 const SubstLookup &l = gsub.get_lookup (lookup_index); | 1306 const SubstLookup &l = gsub.get_lookup (lookup_index); |
| 1374 return l.dispatch (c); | 1307 return l.dispatch (c); |
| 1375 } | 1308 } |
| 1376 | 1309 |
| 1377 /*static*/ inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, u
nsigned int lookup_index) | 1310 /*static*/ inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, u
nsigned int lookup_index) |
| 1378 { | 1311 { |
| 1379 const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); | 1312 const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); |
| 1380 const SubstLookup &l = gsub.get_lookup (lookup_index); | 1313 const SubstLookup &l = gsub.get_lookup (lookup_index); |
| 1381 unsigned int saved_lookup_props = c->lookup_props; | 1314 unsigned int saved_lookup_props = c->lookup_props; |
| 1382 c->set_lookup (l); | 1315 c->set_lookup (l); |
| 1383 bool ret = l.apply_once (c); | 1316 bool ret = l.dispatch (c); |
| 1384 c->lookup_props = saved_lookup_props; | 1317 c->set_lookup_props (saved_lookup_props); |
| 1385 return ret; | 1318 return ret; |
| 1386 } | 1319 } |
| 1387 | 1320 |
| 1388 | 1321 |
| 1389 } /* namespace OT */ | 1322 } /* namespace OT */ |
| 1390 | 1323 |
| 1391 | 1324 |
| 1392 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ | 1325 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ |
| OLD | NEW |