[indic/myanmar] Move is_consonant to .cc files

This commit is contained in:
Behdad Esfahbod 2022-06-10 06:34:56 -06:00
parent 1c657460ef
commit 10a5485136
3 changed files with 50 additions and 25 deletions

View File

@ -72,6 +72,30 @@ set_indic_properties (hb_glyph_info_t &info)
info.indic_position() = (indic_position_t) (type >> 8);
}
static inline bool
is_one_of (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);
}
/* Note:
*
* We treat Vowels and placeholders as if they were consonants. This is safe because Vowels
* cannot happen in a consonant syllable. The plus side however is, we can call the
* consonant syllable logic from the vowel syllable function and get it all right!
*
* Keep in sync with consonant_categories in the generator. */
#define CONSONANT_FLAGS_INDIC (FLAG (I_Cat(C)) | FLAG (I_Cat(CS)) | FLAG (I_Cat(Ra)) | FLAG (I_Cat(CM)) | FLAG (I_Cat(V)) | FLAG (I_Cat(PLACEHOLDER)) | FLAG (I_Cat(DOTTEDCIRCLE)))
static inline bool
is_consonant (const hb_glyph_info_t &info)
{
return is_one_of (info, CONSONANT_FLAGS_INDIC);
}
#define JOINER_FLAGS (FLAG (I_Cat(ZWJ)) | FLAG (I_Cat(ZWNJ)))
static inline bool

View File

@ -92,16 +92,6 @@ enum ot_category_t {
OT_ML = 42, // Consonant medials
};
/* Note:
*
* We treat Vowels and placeholders as if they were consonants. This is safe because Vowels
* cannot happen in a consonant syllable. The plus side however is, we can call the
* consonant syllable logic from the vowel syllable function and get it all right!
*
* Keep in sync with consonant_categories in the generator. */
#define CONSONANT_FLAGS (FLAG (OT_C) | FLAG (OT_CS) | FLAG (OT_Ra) | FLAG (OT_CM) | FLAG (OT_V) | FLAG (OT_PLACEHOLDER) | FLAG (OT_DOTTEDCIRCLE))
/* Visual positions in a syllable from left to right. */
enum ot_position_t {
POS_START = 0,
@ -134,18 +124,4 @@ HB_INTERNAL uint16_t
hb_indic_get_categories (hb_codepoint_t u);
static inline bool
is_one_of (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);
}
static inline bool
is_consonant (const hb_glyph_info_t &info)
{
return is_one_of (info, CONSONANT_FLAGS);
}
#endif /* HB_OT_SHAPER_INDIC_HH */

View File

@ -108,6 +108,31 @@ set_myanmar_properties (hb_glyph_info_t &info)
info.myanmar_category() = (myanmar_category_t) (type & 0xFFu);
}
static inline bool
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);
}
/* Note:
*
* We treat Vowels and placeholders as if they were consonants. This is safe because Vowels
* cannot happen in a consonant syllable. The plus side however is, we can call the
* consonant syllable logic from the vowel syllable function and get it all right!
*
* Keep in sync with consonant_categories in the generator. */
#define CONSONANT_FLAGS_MYANMAR (FLAG (M_Cat(C)) | FLAG (M_Cat(CS)) | FLAG (M_Cat(Ra)) | /* FLAG (M_Cat(CM)) | */ FLAG (M_Cat(IV)) | FLAG (M_Cat(GB)) | FLAG (M_Cat(DOTTEDCIRCLE)))
static inline bool
is_consonant_myanmar (const hb_glyph_info_t &info)
{
return is_one_of_myanmar (info, CONSONANT_FLAGS_MYANMAR);
}
static void
setup_syllables_myanmar (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
@ -210,7 +235,7 @@ initial_reordering_consonant_syllable (hb_buffer_t *buffer,
base = limit;
for (unsigned int i = limit; i < end; i++)
if (is_consonant (info[i]))
if (is_consonant_myanmar (info[i]))
{
base = i;
break;