From 14049003ac3cf17631cc68ea78ba5989e248bd52 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 11 Jun 2022 03:53:47 -0600 Subject: [PATCH] [indic-like] Reduce indic-dependency of khmer/myanmar even more --- src/hb-ot-shaper-indic-machine.hh | 56 +++++++++++++++-------------- src/hb-ot-shaper-indic-machine.rl | 4 +++ src/hb-ot-shaper-indic.hh | 5 --- src/hb-ot-shaper-khmer-machine.hh | 2 +- src/hb-ot-shaper-khmer-machine.rl | 2 +- src/hb-ot-shaper-myanmar-machine.hh | 4 +-- src/hb-ot-shaper-myanmar-machine.rl | 4 +-- src/hb-ot-shaper-myanmar.cc | 2 +- 8 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/hb-ot-shaper-indic-machine.hh b/src/hb-ot-shaper-indic-machine.hh index 0408ed961..fa4f2886c 100644 --- a/src/hb-ot-shaper-indic-machine.hh +++ b/src/hb-ot-shaper-indic-machine.hh @@ -34,6 +34,10 @@ #include "hb-ot-layout.hh" #include "hb-ot-shaper-indic.hh" +/* buffer var allocations */ +#define indic_category() ot_shaper_var_u8_category() /* indic_category_t */ +#define indic_position() ot_shaper_var_u8_auxiliary() /* indic_position_t */ + using indic_category_t = ot_category_t; using indic_position_t = ot_position_t; @@ -49,7 +53,7 @@ enum indic_syllable_type_t { }; -#line 53 "hb-ot-shaper-indic-machine.hh" +#line 57 "hb-ot-shaper-indic-machine.hh" #define indic_syllable_machine_ex_A 9u #define indic_syllable_machine_ex_C 1u #define indic_syllable_machine_ex_CM 16u @@ -70,7 +74,7 @@ enum indic_syllable_type_t { #define indic_syllable_machine_ex_ZWNJ 5u -#line 74 "hb-ot-shaper-indic-machine.hh" +#line 78 "hb-ot-shaper-indic-machine.hh" static const unsigned char _indic_syllable_machine_trans_keys[] = { 8u, 8u, 4u, 8u, 5u, 7u, 5u, 8u, 4u, 8u, 6u, 6u, 15u, 15u, 4u, 8u, 4u, 12u, 4u, 8u, 8u, 8u, 5u, 7u, 5u, 8u, 4u, 8u, 6u, 6u, 15u, 15u, @@ -409,11 +413,11 @@ static const int indic_syllable_machine_error = -1; static const int indic_syllable_machine_en_main = 39; -#line 54 "hb-ot-shaper-indic-machine.rl" +#line 58 "hb-ot-shaper-indic-machine.rl" -#line 115 "hb-ot-shaper-indic-machine.rl" +#line 119 "hb-ot-shaper-indic-machine.rl" #define found_syllable(syllable_type) \ @@ -432,7 +436,7 @@ find_syllables_indic (hb_buffer_t *buffer) int cs; hb_glyph_info_t *info = buffer->info; -#line 436 "hb-ot-shaper-indic-machine.hh" +#line 440 "hb-ot-shaper-indic-machine.hh" { cs = indic_syllable_machine_start; ts = 0; @@ -440,7 +444,7 @@ find_syllables_indic (hb_buffer_t *buffer) act = 0; } -#line 135 "hb-ot-shaper-indic-machine.rl" +#line 139 "hb-ot-shaper-indic-machine.rl" p = 0; @@ -448,7 +452,7 @@ find_syllables_indic (hb_buffer_t *buffer) unsigned int syllable_serial = 1; -#line 452 "hb-ot-shaper-indic-machine.hh" +#line 456 "hb-ot-shaper-indic-machine.hh" { int _slen; int _trans; @@ -462,7 +466,7 @@ _resume: #line 1 "NONE" {ts = p;} break; -#line 466 "hb-ot-shaper-indic-machine.hh" +#line 470 "hb-ot-shaper-indic-machine.hh" } _keys = _indic_syllable_machine_trans_keys + (cs<<1); @@ -485,51 +489,51 @@ _eof_trans: {te = p+1;} break; case 11: -#line 111 "hb-ot-shaper-indic-machine.rl" +#line 115 "hb-ot-shaper-indic-machine.rl" {te = p+1;{ found_syllable (indic_non_indic_cluster); }} break; case 13: -#line 106 "hb-ot-shaper-indic-machine.rl" +#line 110 "hb-ot-shaper-indic-machine.rl" {te = p;p--;{ found_syllable (indic_consonant_syllable); }} break; case 14: -#line 107 "hb-ot-shaper-indic-machine.rl" +#line 111 "hb-ot-shaper-indic-machine.rl" {te = p;p--;{ found_syllable (indic_vowel_syllable); }} break; case 17: -#line 108 "hb-ot-shaper-indic-machine.rl" +#line 112 "hb-ot-shaper-indic-machine.rl" {te = p;p--;{ found_syllable (indic_standalone_cluster); }} break; case 19: -#line 109 "hb-ot-shaper-indic-machine.rl" +#line 113 "hb-ot-shaper-indic-machine.rl" {te = p;p--;{ found_syllable (indic_symbol_cluster); }} break; case 15: -#line 110 "hb-ot-shaper-indic-machine.rl" +#line 114 "hb-ot-shaper-indic-machine.rl" {te = p;p--;{ found_syllable (indic_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 16: -#line 111 "hb-ot-shaper-indic-machine.rl" +#line 115 "hb-ot-shaper-indic-machine.rl" {te = p;p--;{ found_syllable (indic_non_indic_cluster); }} break; case 1: -#line 106 "hb-ot-shaper-indic-machine.rl" +#line 110 "hb-ot-shaper-indic-machine.rl" {{p = ((te))-1;}{ found_syllable (indic_consonant_syllable); }} break; case 3: -#line 107 "hb-ot-shaper-indic-machine.rl" +#line 111 "hb-ot-shaper-indic-machine.rl" {{p = ((te))-1;}{ found_syllable (indic_vowel_syllable); }} break; case 7: -#line 108 "hb-ot-shaper-indic-machine.rl" +#line 112 "hb-ot-shaper-indic-machine.rl" {{p = ((te))-1;}{ found_syllable (indic_standalone_cluster); }} break; case 8: -#line 109 "hb-ot-shaper-indic-machine.rl" +#line 113 "hb-ot-shaper-indic-machine.rl" {{p = ((te))-1;}{ found_syllable (indic_symbol_cluster); }} break; case 4: -#line 110 "hb-ot-shaper-indic-machine.rl" +#line 114 "hb-ot-shaper-indic-machine.rl" {{p = ((te))-1;}{ found_syllable (indic_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 6: @@ -550,22 +554,22 @@ _eof_trans: case 18: #line 1 "NONE" {te = p+1;} -#line 106 "hb-ot-shaper-indic-machine.rl" +#line 110 "hb-ot-shaper-indic-machine.rl" {act = 1;} break; case 5: #line 1 "NONE" {te = p+1;} -#line 110 "hb-ot-shaper-indic-machine.rl" +#line 114 "hb-ot-shaper-indic-machine.rl" {act = 5;} break; case 12: #line 1 "NONE" {te = p+1;} -#line 111 "hb-ot-shaper-indic-machine.rl" +#line 115 "hb-ot-shaper-indic-machine.rl" {act = 6;} break; -#line 569 "hb-ot-shaper-indic-machine.hh" +#line 573 "hb-ot-shaper-indic-machine.hh" } _again: @@ -574,7 +578,7 @@ _again: #line 1 "NONE" {ts = 0;} break; -#line 578 "hb-ot-shaper-indic-machine.hh" +#line 582 "hb-ot-shaper-indic-machine.hh" } if ( ++p != pe ) @@ -590,7 +594,7 @@ _again: } -#line 143 "hb-ot-shaper-indic-machine.rl" +#line 147 "hb-ot-shaper-indic-machine.rl" } diff --git a/src/hb-ot-shaper-indic-machine.rl b/src/hb-ot-shaper-indic-machine.rl index c810114d9..caae5b599 100644 --- a/src/hb-ot-shaper-indic-machine.rl +++ b/src/hb-ot-shaper-indic-machine.rl @@ -32,6 +32,10 @@ #include "hb-ot-layout.hh" #include "hb-ot-shaper-indic.hh" +/* buffer var allocations */ +#define indic_category() ot_shaper_var_u8_category() /* indic_category_t */ +#define indic_position() ot_shaper_var_u8_auxiliary() /* indic_position_t */ + using indic_category_t = ot_category_t; using indic_position_t = ot_position_t; diff --git a/src/hb-ot-shaper-indic.hh b/src/hb-ot-shaper-indic.hh index 7e97dd385..c3ea3909a 100644 --- a/src/hb-ot-shaper-indic.hh +++ b/src/hb-ot-shaper-indic.hh @@ -32,11 +32,6 @@ #include "hb-ot-shaper-syllabic.hh" -/* buffer var allocations */ -#define indic_category() ot_shaper_var_u8_category() /* indic_category_t */ -#define indic_position() ot_shaper_var_u8_auxiliary() /* indic_position_t */ - - /* Cateories used in the OpenType spec: * https://docs.microsoft.com/en-us/typography/script-development/devanagari */ diff --git a/src/hb-ot-shaper-khmer-machine.hh b/src/hb-ot-shaper-khmer-machine.hh index cf136121c..5bac24fa3 100644 --- a/src/hb-ot-shaper-khmer-machine.hh +++ b/src/hb-ot-shaper-khmer-machine.hh @@ -35,7 +35,7 @@ #include "hb-ot-shaper-indic.hh" /* buffer var allocations */ -#define khmer_category() indic_category() /* khmer_category_t */ +#define khmer_category() ot_shaper_var_u8_category() /* khmer_category_t */ using khmer_category_t = ot_category_t; diff --git a/src/hb-ot-shaper-khmer-machine.rl b/src/hb-ot-shaper-khmer-machine.rl index 1ebf586f0..4258ab9f3 100644 --- a/src/hb-ot-shaper-khmer-machine.rl +++ b/src/hb-ot-shaper-khmer-machine.rl @@ -33,7 +33,7 @@ #include "hb-ot-shaper-indic.hh" /* buffer var allocations */ -#define khmer_category() indic_category() /* khmer_category_t */ +#define khmer_category() ot_shaper_var_u8_category() /* khmer_category_t */ using khmer_category_t = ot_category_t; diff --git a/src/hb-ot-shaper-myanmar-machine.hh b/src/hb-ot-shaper-myanmar-machine.hh index 628e2e7fa..f3293b8cf 100644 --- a/src/hb-ot-shaper-myanmar-machine.hh +++ b/src/hb-ot-shaper-myanmar-machine.hh @@ -35,8 +35,8 @@ #include "hb-ot-shaper-indic.hh" /* buffer var allocations */ -#define myanmar_category() indic_category() /* myanmar_category_t */ -#define myanmar_position() indic_position() /* myanmar_position_t */ +#define myanmar_category() ot_shaper_var_u8_category() /* myanmar_category_t */ +#define myanmar_position() ot_shaper_var_u8_auxiliary() /* myanmar_position_t */ using myanmar_category_t = ot_category_t; using myanmar_position_t = ot_position_t; diff --git a/src/hb-ot-shaper-myanmar-machine.rl b/src/hb-ot-shaper-myanmar-machine.rl index 234801579..a8b19e654 100644 --- a/src/hb-ot-shaper-myanmar-machine.rl +++ b/src/hb-ot-shaper-myanmar-machine.rl @@ -33,8 +33,8 @@ #include "hb-ot-shaper-indic.hh" /* buffer var allocations */ -#define myanmar_category() indic_category() /* myanmar_category_t */ -#define myanmar_position() indic_position() /* myanmar_position_t */ +#define myanmar_category() ot_shaper_var_u8_category() /* myanmar_category_t */ +#define myanmar_position() ot_shaper_var_u8_auxiliary() /* myanmar_position_t */ using myanmar_category_t = ot_category_t; using myanmar_position_t = ot_position_t; diff --git a/src/hb-ot-shaper-myanmar.cc b/src/hb-ot-shaper-myanmar.cc index 9696ced70..6bf6a2f1e 100644 --- a/src/hb-ot-shaper-myanmar.cc +++ b/src/hb-ot-shaper-myanmar.cc @@ -114,7 +114,7 @@ is_one_of_myanmar (const hb_glyph_info_t &info, unsigned int flags) { /* If it ligated, all bets are off. */ if (_hb_glyph_info_ligated (&info)) return false; - return !!(FLAG_UNSAFE (info.indic_category()) & flags); + return !!(FLAG_UNSAFE (info.myanmar_category()) & flags); } /* Note: