| 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 Google, Inc. | 3 * Copyright © 2010,2012 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 * beginning of Substitution table */ | 185 * beginning of Substitution table */ |
| 186 ArrayOf<GlyphID> | 186 ArrayOf<GlyphID> |
| 187 substitute; /* Array of substitute | 187 substitute; /* Array of substitute |
| 188 * GlyphIDs--ordered by Coverage Index *
/ | 188 * GlyphIDs--ordered by Coverage Index *
/ |
| 189 public: | 189 public: |
| 190 DEFINE_SIZE_ARRAY (6, substitute); | 190 DEFINE_SIZE_ARRAY (6, substitute); |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 struct SingleSubst | 193 struct SingleSubst |
| 194 { | 194 { |
| 195 template <typename context_t> | |
| 196 inline typename context_t::return_t process (context_t *c) const | |
| 197 { | |
| 198 TRACE_PROCESS (this); | |
| 199 switch (u.format) { | |
| 200 case 1: return TRACE_RETURN (c->process (u.format1)); | |
| 201 case 2: return TRACE_RETURN (c->process (u.format2)); | |
| 202 default:return TRACE_RETURN (c->default_return_value ()); | |
| 203 } | |
| 204 } | |
| 205 | |
| 206 inline bool serialize (hb_serialize_context_t *c, | 195 inline bool serialize (hb_serialize_context_t *c, |
| 207 Supplier<GlyphID> &glyphs, | 196 Supplier<GlyphID> &glyphs, |
| 208 Supplier<GlyphID> &substitutes, | 197 Supplier<GlyphID> &substitutes, |
| 209 unsigned int num_glyphs) | 198 unsigned int num_glyphs) |
| 210 { | 199 { |
| 211 TRACE_SERIALIZE (this); | 200 TRACE_SERIALIZE (this); |
| 212 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 201 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); |
| 213 unsigned int format = 2; | 202 unsigned int format = 2; |
| 214 int delta; | 203 int delta; |
| 215 if (num_glyphs) { | 204 if (num_glyphs) { |
| 216 format = 1; | 205 format = 1; |
| 217 /* TODO(serialize) check for wrap-around */ | 206 /* TODO(serialize) check for wrap-around */ |
| 218 delta = substitutes[0] - glyphs[0]; | 207 delta = substitutes[0] - glyphs[0]; |
| 219 for (unsigned int i = 1; i < num_glyphs; i++) | 208 for (unsigned int i = 1; i < num_glyphs; i++) |
| 220 if (delta != substitutes[i] - glyphs[i]) { | 209 if (delta != substitutes[i] - glyphs[i]) { |
| 221 format = 2; | 210 format = 2; |
| 222 break; | 211 break; |
| 223 } | 212 } |
| 224 } | 213 } |
| 225 u.format.set (format); | 214 u.format.set (format); |
| 226 switch (u.format) { | 215 switch (u.format) { |
| 227 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs, del
ta)); | 216 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, num_glyphs, del
ta)); |
| 228 case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, substitutes, nu
m_glyphs)); | 217 case 2: return TRACE_RETURN (u.format2.serialize (c, glyphs, substitutes, nu
m_glyphs)); |
| 229 default:return TRACE_RETURN (false); | 218 default:return TRACE_RETURN (false); |
| 230 } | 219 } |
| 231 } | 220 } |
| 232 | 221 |
| 222 template <typename context_t> |
| 223 inline typename context_t::return_t dispatch (context_t *c) const |
| 224 { |
| 225 TRACE_DISPATCH (this); |
| 226 switch (u.format) { |
| 227 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 228 case 2: return TRACE_RETURN (c->dispatch (u.format2)); |
| 229 default:return TRACE_RETURN (c->default_return_value ()); |
| 230 } |
| 231 } |
| 232 |
| 233 inline bool sanitize (hb_sanitize_context_t *c) { | 233 inline bool sanitize (hb_sanitize_context_t *c) { |
| 234 TRACE_SANITIZE (this); | 234 TRACE_SANITIZE (this); |
| 235 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 235 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
| 236 switch (u.format) { | 236 switch (u.format) { |
| 237 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | 237 case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
| 238 case 2: return TRACE_RETURN (u.format2.sanitize (c)); | 238 case 2: return TRACE_RETURN (u.format2.sanitize (c)); |
| 239 default:return TRACE_RETURN (true); | 239 default:return TRACE_RETURN (true); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 265 unsigned int count = substitute.len; | 265 unsigned int count = substitute.len; |
| 266 for (unsigned int i = 0; i < count; i++) | 266 for (unsigned int i = 0; i < count; i++) |
| 267 c->output->add (substitute[i]); | 267 c->output->add (substitute[i]); |
| 268 } | 268 } |
| 269 | 269 |
| 270 inline bool apply (hb_apply_context_t *c) const | 270 inline bool apply (hb_apply_context_t *c) const |
| 271 { | 271 { |
| 272 TRACE_APPLY (this); | 272 TRACE_APPLY (this); |
| 273 if (unlikely (!substitute.len)) return TRACE_RETURN (false); | 273 if (unlikely (!substitute.len)) return TRACE_RETURN (false); |
| 274 | 274 |
| 275 unsigned int klass = c->property & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT
_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0; | 275 unsigned int klass = c->buffer->cur().glyph_props() & |
| 276 » » » HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_
PROPS_BASE_GLYPH : 0; |
| 276 unsigned int count = substitute.len; | 277 unsigned int count = substitute.len; |
| 277 for (unsigned int i = 0; i < count; i++) { | 278 for (unsigned int i = 0; i < count; i++) { |
| 278 set_lig_props_for_component (c->buffer->cur(), i); | 279 set_lig_props_for_component (c->buffer->cur(), i); |
| 279 c->output_glyph (substitute.array[i], klass); | 280 c->output_glyph (substitute.array[i], klass); |
| 280 } | 281 } |
| 281 c->buffer->skip_glyph (); | 282 c->buffer->skip_glyph (); |
| 282 | 283 |
| 283 return TRACE_RETURN (true); | 284 return TRACE_RETURN (true); |
| 284 } | 285 } |
| 285 | 286 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 * beginning of Substitution table */ | 378 * beginning of Substitution table */ |
| 378 OffsetArrayOf<Sequence> | 379 OffsetArrayOf<Sequence> |
| 379 sequence; /* Array of Sequence tables | 380 sequence; /* Array of Sequence tables |
| 380 * ordered by Coverage Index */ | 381 * ordered by Coverage Index */ |
| 381 public: | 382 public: |
| 382 DEFINE_SIZE_ARRAY (6, sequence); | 383 DEFINE_SIZE_ARRAY (6, sequence); |
| 383 }; | 384 }; |
| 384 | 385 |
| 385 struct MultipleSubst | 386 struct MultipleSubst |
| 386 { | 387 { |
| 387 template <typename context_t> | |
| 388 inline typename context_t::return_t process (context_t *c) const | |
| 389 { | |
| 390 TRACE_PROCESS (this); | |
| 391 switch (u.format) { | |
| 392 case 1: return TRACE_RETURN (c->process (u.format1)); | |
| 393 default:return TRACE_RETURN (c->default_return_value ()); | |
| 394 } | |
| 395 } | |
| 396 | |
| 397 inline bool serialize (hb_serialize_context_t *c, | 388 inline bool serialize (hb_serialize_context_t *c, |
| 398 Supplier<GlyphID> &glyphs, | 389 Supplier<GlyphID> &glyphs, |
| 399 Supplier<unsigned int> &substitute_len_list, | 390 Supplier<unsigned int> &substitute_len_list, |
| 400 unsigned int num_glyphs, | 391 unsigned int num_glyphs, |
| 401 Supplier<GlyphID> &substitute_glyphs_list) | 392 Supplier<GlyphID> &substitute_glyphs_list) |
| 402 { | 393 { |
| 403 TRACE_SERIALIZE (this); | 394 TRACE_SERIALIZE (this); |
| 404 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 395 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); |
| 405 unsigned int format = 1; | 396 unsigned int format = 1; |
| 406 u.format.set (format); | 397 u.format.set (format); |
| 407 switch (u.format) { | 398 switch (u.format) { |
| 408 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, substitute_len_
list, num_glyphs, substitute_glyphs_list)); | 399 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, substitute_len_
list, num_glyphs, substitute_glyphs_list)); |
| 409 default:return TRACE_RETURN (false); | 400 default:return TRACE_RETURN (false); |
| 410 } | 401 } |
| 411 } | 402 } |
| 412 | 403 |
| 404 template <typename context_t> |
| 405 inline typename context_t::return_t dispatch (context_t *c) const |
| 406 { |
| 407 TRACE_DISPATCH (this); |
| 408 switch (u.format) { |
| 409 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 410 default:return TRACE_RETURN (c->default_return_value ()); |
| 411 } |
| 412 } |
| 413 |
| 413 inline bool sanitize (hb_sanitize_context_t *c) { | 414 inline bool sanitize (hb_sanitize_context_t *c) { |
| 414 TRACE_SANITIZE (this); | 415 TRACE_SANITIZE (this); |
| 415 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 416 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
| 416 switch (u.format) { | 417 switch (u.format) { |
| 417 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | 418 case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
| 418 default:return TRACE_RETURN (true); | 419 default:return TRACE_RETURN (true); |
| 419 } | 420 } |
| 420 } | 421 } |
| 421 | 422 |
| 422 protected: | 423 protected: |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 * beginning of Substitution table */ | 529 * beginning of Substitution table */ |
| 529 OffsetArrayOf<AlternateSet> | 530 OffsetArrayOf<AlternateSet> |
| 530 alternateSet; /* Array of AlternateSet tables | 531 alternateSet; /* Array of AlternateSet tables |
| 531 * ordered by Coverage Index */ | 532 * ordered by Coverage Index */ |
| 532 public: | 533 public: |
| 533 DEFINE_SIZE_ARRAY (6, alternateSet); | 534 DEFINE_SIZE_ARRAY (6, alternateSet); |
| 534 }; | 535 }; |
| 535 | 536 |
| 536 struct AlternateSubst | 537 struct AlternateSubst |
| 537 { | 538 { |
| 538 template <typename context_t> | |
| 539 inline typename context_t::return_t process (context_t *c) const | |
| 540 { | |
| 541 TRACE_PROCESS (this); | |
| 542 switch (u.format) { | |
| 543 case 1: return TRACE_RETURN (c->process (u.format1)); | |
| 544 default:return TRACE_RETURN (c->default_return_value ()); | |
| 545 } | |
| 546 } | |
| 547 | |
| 548 inline bool serialize (hb_serialize_context_t *c, | 539 inline bool serialize (hb_serialize_context_t *c, |
| 549 Supplier<GlyphID> &glyphs, | 540 Supplier<GlyphID> &glyphs, |
| 550 Supplier<unsigned int> &alternate_len_list, | 541 Supplier<unsigned int> &alternate_len_list, |
| 551 unsigned int num_glyphs, | 542 unsigned int num_glyphs, |
| 552 Supplier<GlyphID> &alternate_glyphs_list) | 543 Supplier<GlyphID> &alternate_glyphs_list) |
| 553 { | 544 { |
| 554 TRACE_SERIALIZE (this); | 545 TRACE_SERIALIZE (this); |
| 555 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 546 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); |
| 556 unsigned int format = 1; | 547 unsigned int format = 1; |
| 557 u.format.set (format); | 548 u.format.set (format); |
| 558 switch (u.format) { | 549 switch (u.format) { |
| 559 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, alternate_len_l
ist, num_glyphs, alternate_glyphs_list)); | 550 case 1: return TRACE_RETURN (u.format1.serialize (c, glyphs, alternate_len_l
ist, num_glyphs, alternate_glyphs_list)); |
| 560 default:return TRACE_RETURN (false); | 551 default:return TRACE_RETURN (false); |
| 561 } | 552 } |
| 562 } | 553 } |
| 563 | 554 |
| 555 template <typename context_t> |
| 556 inline typename context_t::return_t dispatch (context_t *c) const |
| 557 { |
| 558 TRACE_DISPATCH (this); |
| 559 switch (u.format) { |
| 560 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 561 default:return TRACE_RETURN (c->default_return_value ()); |
| 562 } |
| 563 } |
| 564 |
| 564 inline bool sanitize (hb_sanitize_context_t *c) { | 565 inline bool sanitize (hb_sanitize_context_t *c) { |
| 565 TRACE_SANITIZE (this); | 566 TRACE_SANITIZE (this); |
| 566 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 567 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
| 567 switch (u.format) { | 568 switch (u.format) { |
| 568 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | 569 case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
| 569 default:return TRACE_RETURN (true); | 570 default:return TRACE_RETURN (true); |
| 570 } | 571 } |
| 571 } | 572 } |
| 572 | 573 |
| 573 protected: | 574 protected: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 &is_mark_ligature, | 631 &is_mark_ligature, |
| 631 &total_component_count))) | 632 &total_component_count))) |
| 632 return TRACE_RETURN (false); | 633 return TRACE_RETURN (false); |
| 633 | 634 |
| 634 /* Deal, we are forming the ligature. */ | 635 /* Deal, we are forming the ligature. */ |
| 635 c->buffer->merge_clusters (c->buffer->idx, c->buffer->idx + end_offset); | 636 c->buffer->merge_clusters (c->buffer->idx, c->buffer->idx + end_offset); |
| 636 | 637 |
| 637 ligate_input (c, | 638 ligate_input (c, |
| 638 count, | 639 count, |
| 639 &component[1], | 640 &component[1], |
| 640 ligGlyph, | |
| 641 match_glyph, | 641 match_glyph, |
| 642 NULL, | 642 NULL, |
| 643 ligGlyph, |
| 643 is_mark_ligature, | 644 is_mark_ligature, |
| 644 total_component_count); | 645 total_component_count); |
| 645 | 646 |
| 646 return TRACE_RETURN (true); | 647 return TRACE_RETURN (true); |
| 647 } | 648 } |
| 648 | 649 |
| 649 inline bool serialize (hb_serialize_context_t *c, | 650 inline bool serialize (hb_serialize_context_t *c, |
| 650 GlyphID ligature, | 651 GlyphID ligature, |
| 651 Supplier<GlyphID> &components, /* Starting from second
*/ | 652 Supplier<GlyphID> &components, /* Starting from second
*/ |
| 652 unsigned int num_components /* Including first componen
t */) | 653 unsigned int num_components /* Including first componen
t */) |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 * beginning of Substitution table */ | 834 * beginning of Substitution table */ |
| 834 OffsetArrayOf<LigatureSet> | 835 OffsetArrayOf<LigatureSet> |
| 835 ligatureSet; /* Array LigatureSet tables | 836 ligatureSet; /* Array LigatureSet tables |
| 836 * ordered by Coverage Index */ | 837 * ordered by Coverage Index */ |
| 837 public: | 838 public: |
| 838 DEFINE_SIZE_ARRAY (6, ligatureSet); | 839 DEFINE_SIZE_ARRAY (6, ligatureSet); |
| 839 }; | 840 }; |
| 840 | 841 |
| 841 struct LigatureSubst | 842 struct LigatureSubst |
| 842 { | 843 { |
| 843 template <typename context_t> | |
| 844 inline typename context_t::return_t process (context_t *c) const | |
| 845 { | |
| 846 TRACE_PROCESS (this); | |
| 847 switch (u.format) { | |
| 848 case 1: return TRACE_RETURN (c->process (u.format1)); | |
| 849 default:return TRACE_RETURN (c->default_return_value ()); | |
| 850 } | |
| 851 } | |
| 852 | |
| 853 inline bool serialize (hb_serialize_context_t *c, | 844 inline bool serialize (hb_serialize_context_t *c, |
| 854 Supplier<GlyphID> &first_glyphs, | 845 Supplier<GlyphID> &first_glyphs, |
| 855 Supplier<unsigned int> &ligature_per_first_glyph_count_
list, | 846 Supplier<unsigned int> &ligature_per_first_glyph_count_
list, |
| 856 unsigned int num_first_glyphs, | 847 unsigned int num_first_glyphs, |
| 857 Supplier<GlyphID> &ligatures_list, | 848 Supplier<GlyphID> &ligatures_list, |
| 858 Supplier<unsigned int> &component_count_list, | 849 Supplier<unsigned int> &component_count_list, |
| 859 Supplier<GlyphID> &component_list /* Starting from seco
nd for each ligature */) | 850 Supplier<GlyphID> &component_list /* Starting from seco
nd for each ligature */) |
| 860 { | 851 { |
| 861 TRACE_SERIALIZE (this); | 852 TRACE_SERIALIZE (this); |
| 862 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); | 853 if (unlikely (!c->extend_min (u.format))) return TRACE_RETURN (false); |
| 863 unsigned int format = 1; | 854 unsigned int format = 1; |
| 864 u.format.set (format); | 855 u.format.set (format); |
| 865 switch (u.format) { | 856 switch (u.format) { |
| 866 case 1: return TRACE_RETURN (u.format1.serialize (c, first_glyphs, ligature_
per_first_glyph_count_list, num_first_glyphs, | 857 case 1: return TRACE_RETURN (u.format1.serialize (c, first_glyphs, ligature_
per_first_glyph_count_list, num_first_glyphs, |
| 867 ligatures_list, component_
count_list, component_list)); | 858 ligatures_list, component_
count_list, component_list)); |
| 868 default:return TRACE_RETURN (false); | 859 default:return TRACE_RETURN (false); |
| 869 } | 860 } |
| 870 } | 861 } |
| 871 | 862 |
| 863 template <typename context_t> |
| 864 inline typename context_t::return_t dispatch (context_t *c) const |
| 865 { |
| 866 TRACE_DISPATCH (this); |
| 867 switch (u.format) { |
| 868 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 869 default:return TRACE_RETURN (c->default_return_value ()); |
| 870 } |
| 871 } |
| 872 |
| 872 inline bool sanitize (hb_sanitize_context_t *c) { | 873 inline bool sanitize (hb_sanitize_context_t *c) { |
| 873 TRACE_SANITIZE (this); | 874 TRACE_SANITIZE (this); |
| 874 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 875 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
| 875 switch (u.format) { | 876 switch (u.format) { |
| 876 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | 877 case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
| 877 default:return TRACE_RETURN (true); | 878 default:return TRACE_RETURN (true); |
| 878 } | 879 } |
| 879 } | 880 } |
| 880 | 881 |
| 881 protected: | 882 protected: |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 ArrayOf<GlyphID> | 1016 ArrayOf<GlyphID> |
| 1016 substituteX; /* Array of substitute | 1017 substituteX; /* Array of substitute |
| 1017 * GlyphIDs--ordered by Coverage Index *
/ | 1018 * GlyphIDs--ordered by Coverage Index *
/ |
| 1018 public: | 1019 public: |
| 1019 DEFINE_SIZE_MIN (10); | 1020 DEFINE_SIZE_MIN (10); |
| 1020 }; | 1021 }; |
| 1021 | 1022 |
| 1022 struct ReverseChainSingleSubst | 1023 struct ReverseChainSingleSubst |
| 1023 { | 1024 { |
| 1024 template <typename context_t> | 1025 template <typename context_t> |
| 1025 inline typename context_t::return_t process (context_t *c) const | 1026 inline typename context_t::return_t dispatch (context_t *c) const |
| 1026 { | 1027 { |
| 1027 TRACE_PROCESS (this); | 1028 TRACE_DISPATCH (this); |
| 1028 switch (u.format) { | 1029 switch (u.format) { |
| 1029 case 1: return TRACE_RETURN (c->process (u.format1)); | 1030 case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
| 1030 default:return TRACE_RETURN (c->default_return_value ()); | 1031 default:return TRACE_RETURN (c->default_return_value ()); |
| 1031 } | 1032 } |
| 1032 } | 1033 } |
| 1033 | 1034 |
| 1034 inline bool sanitize (hb_sanitize_context_t *c) { | 1035 inline bool sanitize (hb_sanitize_context_t *c) { |
| 1035 TRACE_SANITIZE (this); | 1036 TRACE_SANITIZE (this); |
| 1036 if (!u.format.sanitize (c)) return TRACE_RETURN (false); | 1037 if (!u.format.sanitize (c)) return TRACE_RETURN (false); |
| 1037 switch (u.format) { | 1038 switch (u.format) { |
| 1038 case 1: return TRACE_RETURN (u.format1.sanitize (c)); | 1039 case 1: return TRACE_RETURN (u.format1.sanitize (c)); |
| 1039 default:return TRACE_RETURN (true); | 1040 default:return TRACE_RETURN (true); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1062 Multiple = 2, | 1063 Multiple = 2, |
| 1063 Alternate = 3, | 1064 Alternate = 3, |
| 1064 Ligature = 4, | 1065 Ligature = 4, |
| 1065 Context = 5, | 1066 Context = 5, |
| 1066 ChainContext = 6, | 1067 ChainContext = 6, |
| 1067 Extension = 7, | 1068 Extension = 7, |
| 1068 ReverseChainSingle = 8 | 1069 ReverseChainSingle = 8 |
| 1069 }; | 1070 }; |
| 1070 | 1071 |
| 1071 template <typename context_t> | 1072 template <typename context_t> |
| 1072 inline typename context_t::return_t process (context_t *c, unsigned int lookup
_type) const | 1073 inline typename context_t::return_t dispatch (context_t *c, unsigned int looku
p_type) const |
| 1073 { | 1074 { |
| 1074 TRACE_PROCESS (this); | 1075 TRACE_DISPATCH (this); |
| 1075 switch (lookup_type) { | 1076 switch (lookup_type) { |
| 1076 case Single:» » return TRACE_RETURN (u.single.process (c)); | 1077 case Single:» » return TRACE_RETURN (u.single.dispatch (c)); |
| 1077 case Multiple:» » return TRACE_RETURN (u.multiple.process (c)); | 1078 case Multiple:» » return TRACE_RETURN (u.multiple.dispatch (c)); |
| 1078 case Alternate:» » return TRACE_RETURN (u.alternate.process (c)); | 1079 case Alternate:» » return TRACE_RETURN (u.alternate.dispatch (c)); |
| 1079 case Ligature:» » return TRACE_RETURN (u.ligature.process (c)); | 1080 case Ligature:» » return TRACE_RETURN (u.ligature.dispatch (c)); |
| 1080 case Context:» » return TRACE_RETURN (u.context.process (c)); | 1081 case Context:» » return TRACE_RETURN (u.context.dispatch (c)); |
| 1081 case ChainContext:» » return TRACE_RETURN (u.chainContext.process (c))
; | 1082 case ChainContext:» » return TRACE_RETURN (u.chainContext.dispatch (c)
); |
| 1082 case Extension:» » return TRACE_RETURN (u.extension.process (c)); | 1083 case Extension:» » return TRACE_RETURN (u.extension.dispatch (c)); |
| 1083 case ReverseChainSingle:» return TRACE_RETURN (u.reverseChainContextSingle
.process (c)); | 1084 case ReverseChainSingle:» return TRACE_RETURN (u.reverseChainContextSingle
.dispatch (c)); |
| 1084 default: return TRACE_RETURN (c->default_return_value ())
; | 1085 default: return TRACE_RETURN (c->default_return_value ())
; |
| 1085 } | 1086 } |
| 1086 } | 1087 } |
| 1087 | 1088 |
| 1088 inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) { | 1089 inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) { |
| 1089 TRACE_SANITIZE (this); | 1090 TRACE_SANITIZE (this); |
| 1090 if (!u.header.sub_format.sanitize (c)) | 1091 if (!u.header.sub_format.sanitize (c)) |
| 1091 return TRACE_RETURN (false); | 1092 return TRACE_RETURN (false); |
| 1092 switch (lookup_type) { | 1093 switch (lookup_type) { |
| 1093 case Single: return TRACE_RETURN (u.single.sanitize (c)); | 1094 case Single: return TRACE_RETURN (u.single.sanitize (c)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 { return lookup_type == SubstLookupSubTable::ReverseChainSingle; } | 1131 { return lookup_type == SubstLookupSubTable::ReverseChainSingle; } |
| 1131 | 1132 |
| 1132 inline bool is_reverse (void) const | 1133 inline bool is_reverse (void) const |
| 1133 { | 1134 { |
| 1134 unsigned int type = get_type (); | 1135 unsigned int type = get_type (); |
| 1135 if (unlikely (type == SubstLookupSubTable::Extension)) | 1136 if (unlikely (type == SubstLookupSubTable::Extension)) |
| 1136 return CastR<ExtensionSubst> (get_subtable(0)).is_reverse (); | 1137 return CastR<ExtensionSubst> (get_subtable(0)).is_reverse (); |
| 1137 return lookup_type_is_reverse (type); | 1138 return lookup_type_is_reverse (type); |
| 1138 } | 1139 } |
| 1139 | 1140 |
| 1140 template <typename context_t> | |
| 1141 inline typename context_t::return_t process (context_t *c) const | |
| 1142 { | |
| 1143 TRACE_PROCESS (this); | |
| 1144 unsigned int lookup_type = get_type (); | |
| 1145 unsigned int count = get_subtable_count (); | |
| 1146 for (unsigned int i = 0; i < count; i++) { | |
| 1147 typename context_t::return_t r = get_subtable (i).process (c, lookup_type)
; | |
| 1148 if (c->stop_sublookup_iteration (r)) | |
| 1149 return TRACE_RETURN (r); | |
| 1150 } | |
| 1151 return TRACE_RETURN (c->default_return_value ()); | |
| 1152 } | |
| 1153 template <typename context_t> | |
| 1154 static inline typename context_t::return_t process_recurse_func (context_t *c,
unsigned int lookup_index); | |
| 1155 | |
| 1156 inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const | 1141 inline hb_closure_context_t::return_t closure (hb_closure_context_t *c) const |
| 1157 { | 1142 { |
| 1158 TRACE_CLOSURE (this); | 1143 TRACE_CLOSURE (this); |
| 1159 c->set_recurse_func (process_recurse_func<hb_closure_context_t>); | 1144 c->set_recurse_func (dispatch_recurse_func<hb_closure_context_t>); |
| 1160 return TRACE_RETURN (process (c)); | 1145 return TRACE_RETURN (dispatch (c)); |
| 1161 } | 1146 } |
| 1162 | 1147 |
| 1163 inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect
_glyphs_context_t *c) const | 1148 inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect
_glyphs_context_t *c) const |
| 1164 { | 1149 { |
| 1165 TRACE_COLLECT_GLYPHS (this); | 1150 TRACE_COLLECT_GLYPHS (this); |
| 1166 c->set_recurse_func (process_recurse_func<hb_collect_glyphs_context_t>); | 1151 c->set_recurse_func (dispatch_recurse_func<hb_collect_glyphs_context_t>); |
| 1167 return TRACE_RETURN (process (c)); | 1152 return TRACE_RETURN (dispatch (c)); |
| 1168 } | 1153 } |
| 1169 | 1154 |
| 1170 template <typename set_t> | 1155 template <typename set_t> |
| 1171 inline void add_coverage (set_t *glyphs) const | 1156 inline void add_coverage (set_t *glyphs) const |
| 1172 { | 1157 { |
| 1173 hb_get_coverage_context_t c; | 1158 hb_get_coverage_context_t c; |
| 1174 const Coverage *last = NULL; | 1159 const Coverage *last = NULL; |
| 1175 unsigned int count = get_subtable_count (); | 1160 unsigned int count = get_subtable_count (); |
| 1176 for (unsigned int i = 0; i < count; i++) { | 1161 for (unsigned int i = 0; i < count; i++) { |
| 1177 const Coverage *coverage = &get_subtable (i).process (&c, get_type ()); | 1162 const Coverage *coverage = &get_subtable (i).dispatch (&c, get_type ()); |
| 1178 if (coverage != last) { | 1163 if (coverage != last) { |
| 1179 coverage->add_coverage (glyphs); | 1164 coverage->add_coverage (glyphs); |
| 1180 last = coverage; | 1165 last = coverage; |
| 1181 } | 1166 } |
| 1182 } | 1167 } |
| 1183 } | 1168 } |
| 1184 | 1169 |
| 1185 inline bool would_apply (hb_would_apply_context_t *c, const hb_set_digest_t *d
igest) const | 1170 inline bool would_apply (hb_would_apply_context_t *c, const hb_set_digest_t *d
igest) const |
| 1186 { | 1171 { |
| 1187 TRACE_WOULD_APPLY (this); | 1172 TRACE_WOULD_APPLY (this); |
| 1188 if (unlikely (!c->len)) return TRACE_RETURN (false); | 1173 if (unlikely (!c->len)) return TRACE_RETURN (false); |
| 1189 if (!digest->may_have (c->glyphs[0])) return TRACE_RETURN (false); | 1174 if (!digest->may_have (c->glyphs[0])) return TRACE_RETURN (false); |
| 1190 return TRACE_RETURN (process (c)); | 1175 return TRACE_RETURN (dispatch (c)); |
| 1191 } | 1176 } |
| 1192 | 1177 |
| 1193 inline bool apply_once (hb_apply_context_t *c) const | 1178 inline bool apply_once (hb_apply_context_t *c) const |
| 1194 { | 1179 { |
| 1195 TRACE_APPLY (this); | 1180 TRACE_APPLY (this); |
| 1196 if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props, &c->proper
ty)) | 1181 if (!c->check_glyph_property (&c->buffer->cur(), c->lookup_props)) |
| 1197 return TRACE_RETURN (false); | 1182 return TRACE_RETURN (false); |
| 1198 return TRACE_RETURN (process (c)); | 1183 return TRACE_RETURN (dispatch (c)); |
| 1199 } | 1184 } |
| 1200 | 1185 |
| 1201 static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_ind
ex); | 1186 static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_ind
ex); |
| 1202 inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest
) const | 1187 inline bool apply_string (hb_apply_context_t *c, const hb_set_digest_t *digest
) const |
| 1203 { | 1188 { |
| 1204 bool ret = false; | 1189 bool ret = false; |
| 1205 | 1190 |
| 1206 if (unlikely (!c->buffer->len || !c->lookup_mask)) | 1191 if (unlikely (!c->buffer->len || !c->lookup_mask)) |
| 1207 return false; | 1192 return false; |
| 1208 | 1193 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 Supplier<GlyphID> &ligatures_list, | 1282 Supplier<GlyphID> &ligatures_list, |
| 1298 Supplier<unsigned int> &component_count_list, | 1283 Supplier<unsigned int> &component_count_list, |
| 1299 Supplier<GlyphID> &component_list /* Starting
from second for each ligature */) | 1284 Supplier<GlyphID> &component_list /* Starting
from second for each ligature */) |
| 1300 { | 1285 { |
| 1301 TRACE_SERIALIZE (this); | 1286 TRACE_SERIALIZE (this); |
| 1302 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Ligature, lookup_p
rops, 1))) return TRACE_RETURN (false); | 1287 if (unlikely (!Lookup::serialize (c, SubstLookupSubTable::Ligature, lookup_p
rops, 1))) return TRACE_RETURN (false); |
| 1303 return TRACE_RETURN (serialize_subtable (c, 0).u.ligature.serialize (c, firs
t_glyphs, ligature_per_first_glyph_count_list, num_first_glyphs, | 1288 return TRACE_RETURN (serialize_subtable (c, 0).u.ligature.serialize (c, firs
t_glyphs, ligature_per_first_glyph_count_list, num_first_glyphs, |
| 1304 ligatur
es_list, component_count_list, component_list)); | 1289 ligatur
es_list, component_count_list, component_list)); |
| 1305 } | 1290 } |
| 1306 | 1291 |
| 1292 template <typename context_t> |
| 1293 static inline typename context_t::return_t dispatch_recurse_func (context_t *c
, unsigned int lookup_index); |
| 1294 |
| 1295 template <typename context_t> |
| 1296 inline typename context_t::return_t dispatch (context_t *c) const |
| 1297 { |
| 1298 TRACE_DISPATCH (this); |
| 1299 unsigned int lookup_type = get_type (); |
| 1300 unsigned int count = get_subtable_count (); |
| 1301 for (unsigned int i = 0; i < count; i++) { |
| 1302 typename context_t::return_t r = get_subtable (i).dispatch (c, lookup_type
); |
| 1303 if (c->stop_sublookup_iteration (r)) |
| 1304 return TRACE_RETURN (r); |
| 1305 } |
| 1306 return TRACE_RETURN (c->default_return_value ()); |
| 1307 } |
| 1308 |
| 1307 inline bool sanitize (hb_sanitize_context_t *c) | 1309 inline bool sanitize (hb_sanitize_context_t *c) |
| 1308 { | 1310 { |
| 1309 TRACE_SANITIZE (this); | 1311 TRACE_SANITIZE (this); |
| 1310 if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); | 1312 if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false); |
| 1311 OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSu
bTable> > (subTable); | 1313 OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSu
bTable> > (subTable); |
| 1312 if (unlikely (!list.sanitize (c, this, get_type ()))) return TRACE_RETURN (f
alse); | 1314 if (unlikely (!list.sanitize (c, this, get_type ()))) return TRACE_RETURN (f
alse); |
| 1313 | 1315 |
| 1314 if (unlikely (get_type () == SubstLookupSubTable::Extension)) | 1316 if (unlikely (get_type () == SubstLookupSubTable::Extension)) |
| 1315 { | 1317 { |
| 1316 /* The spec says all subtables of an Extension lookup should | 1318 /* The spec says all subtables of an Extension lookup should |
| 1317 * have the same type. This is specially important if one has | 1319 * have the same type. This is specially important if one has |
| 1318 * a reverse type! | 1320 * a reverse type! */ |
| 1319 * | |
| 1320 * We just check that they are all either forward, or reverse. */ | |
| 1321 unsigned int type = get_subtable (0).u.extension.get_type (); | 1321 unsigned int type = get_subtable (0).u.extension.get_type (); |
| 1322 unsigned int count = get_subtable_count (); | 1322 unsigned int count = get_subtable_count (); |
| 1323 for (unsigned int i = 1; i < count; i++) | 1323 for (unsigned int i = 1; i < count; i++) |
| 1324 if (get_subtable (i).u.extension.get_type () != type) | 1324 if (get_subtable (i).u.extension.get_type () != type) |
| 1325 return TRACE_RETURN (false); | 1325 return TRACE_RETURN (false); |
| 1326 } | 1326 } |
| 1327 return TRACE_RETURN (true); | 1327 return TRACE_RETURN (true); |
| 1328 } | 1328 } |
| 1329 }; | 1329 }; |
| 1330 | 1330 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 | 1380 |
| 1381 inline bool ExtensionSubst::is_reverse (void) const | 1381 inline bool ExtensionSubst::is_reverse (void) const |
| 1382 { | 1382 { |
| 1383 unsigned int type = get_type (); | 1383 unsigned int type = get_type (); |
| 1384 if (unlikely (type == SubstLookupSubTable::Extension)) | 1384 if (unlikely (type == SubstLookupSubTable::Extension)) |
| 1385 return CastR<ExtensionSubst> (get_subtable<SubstLookupSubTable>()).is_revers
e (); | 1385 return CastR<ExtensionSubst> (get_subtable<SubstLookupSubTable>()).is_revers
e (); |
| 1386 return SubstLookup::lookup_type_is_reverse (type); | 1386 return SubstLookup::lookup_type_is_reverse (type); |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 template <typename context_t> | 1389 template <typename context_t> |
| 1390 inline typename context_t::return_t SubstLookup::process_recurse_func (context_t
*c, unsigned int lookup_index) | 1390 inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_
t *c, unsigned int lookup_index) |
| 1391 { | 1391 { |
| 1392 const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); | 1392 const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); |
| 1393 const SubstLookup &l = gsub.get_lookup (lookup_index); | 1393 const SubstLookup &l = gsub.get_lookup (lookup_index); |
| 1394 return l.process (c); | 1394 return l.dispatch (c); |
| 1395 } | 1395 } |
| 1396 | 1396 |
| 1397 inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int
lookup_index) | 1397 inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int
lookup_index) |
| 1398 { | 1398 { |
| 1399 const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); | 1399 const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); |
| 1400 const SubstLookup &l = gsub.get_lookup (lookup_index); | 1400 const SubstLookup &l = gsub.get_lookup (lookup_index); |
| 1401 unsigned int saved_lookup_props = c->lookup_props; | 1401 unsigned int saved_lookup_props = c->lookup_props; |
| 1402 unsigned int saved_property = c->property; | |
| 1403 c->set_lookup (l); | 1402 c->set_lookup (l); |
| 1404 bool ret = l.apply_once (c); | 1403 bool ret = l.apply_once (c); |
| 1405 c->lookup_props = saved_lookup_props; | 1404 c->lookup_props = saved_lookup_props; |
| 1406 c->property = saved_property; | |
| 1407 return ret; | 1405 return ret; |
| 1408 } | 1406 } |
| 1409 | 1407 |
| 1410 | 1408 |
| 1411 } /* namespace OT */ | 1409 } /* namespace OT */ |
| 1412 | 1410 |
| 1413 | 1411 |
| 1414 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ | 1412 #endif /* HB_OT_LAYOUT_GSUB_TABLE_HH */ |
| OLD | NEW |