map->add_gsub_pause (clear_substitution_flags);
map->add_feature (HB_TAG('r','p','h','f'), 1, F_MANUAL_ZWJ);
map->add_gsub_pause (record_rphf);
- map->add_feature (HB_TAG('p','r','e','f'), 1, F_MANUAL_ZWJ);
+ map->add_feature (HB_TAG('p','r','e','f'), 1, F_GLOBAL | F_MANUAL_ZWJ);
map->add_gsub_pause (record_pref);
/* "Orthographic unit shaping group" */
ASSERT_POD ();
hb_mask_t rphf_mask;
- hb_mask_t pref_mask;
};
static void *
return NULL;
use_plan->rphf_mask = plan->map.get_1_mask (HB_TAG('r','p','h','f'));
- use_plan->pref_mask = plan->map.get_1_mask (HB_TAG('p','r','e','f'));
return use_plan;
}
{
unsigned int limit = info[start].use_category() == USE_R ? 1 : MIN (3u, end - start);
for (unsigned int i = start; i < start + limit; i++)
- info[i].mask |= use_plan->rphf_mask | use_plan->pref_mask;
- for (unsigned int i = start + limit; i < end; i++)
- info[i].mask |= use_plan->pref_mask;
+ info[i].mask |= use_plan->rphf_mask;
}
static void
/* Setup masks for 'rphf' and 'pref'. */
const use_shape_plan_t *use_plan = (const use_shape_plan_t *) plan->data;
- if (!(use_plan->rphf_mask | use_plan->pref_mask)) return;
+ if (!use_plan->rphf_mask) return;
hb_glyph_info_t *info = buffer->info;
unsigned int count = buffer->len;
unsigned int start, unsigned int end,
hb_mask_t mask)
{
- unsigned int i = start;
-
- if (info[i].use_category() != USE_R)
- for (; i < end && !_hb_glyph_info_substituted (&info[i]); i++)
- info[i].mask &= ~mask;
-
- if (i == end)
- return;
-
- /* Found the one. Don't clear its mask. */
- i++;
-
- /* Clear the mask on the rest. */
- for (; i < end; i++)
- info[i].mask &= ~mask;
+ /* Mark a substituted repha as USE_R. */
+ for (unsigned int i = start; i < end && (info[i].mask & mask); i++)
+ if (_hb_glyph_info_substituted (&info[i]))
+ {
+ /* Found the one. Mark it as Repha. */
+ info[i].use_category() = USE_R;
+ return;
+ }
}
static void
static void
record_pref_syllable (hb_glyph_info_t *info,
- unsigned int start, unsigned int end,
- hb_mask_t mask)
+ unsigned int start, unsigned int end)
{
- unsigned int i = start;
- for (; i < end && !_hb_glyph_info_substituted (&info[i]); i++)
- info[i].mask &= ~mask;
-
- if (i == end)
- return;
-
- /* Found the one. Don't clear its mask. */
- i++;
-
- /* Clear the mask on the rest. */
- for (; i < end; i++)
- info[i].mask &= ~mask;
+ /* Mark a substituted pref as VPre, as they behave the same way. */
+ for (unsigned int i = start; i < end; i++)
+ if (_hb_glyph_info_substituted (&info[i]))
+ {
+ /* Found the one. Mark it as Repha. */
+ info[i].use_category() = USE_VPre;
+ return;
+ }
}
static void
hb_buffer_t *buffer)
{
const use_shape_plan_t *use_plan = (const use_shape_plan_t *) plan->data;
- hb_mask_t mask = use_plan->pref_mask;
- if (!mask) return;
hb_glyph_info_t *info = buffer->info;
unsigned int count = buffer->len;
if (unlikely (!count)) return;
unsigned int last_syllable = info[0].syllable();
for (unsigned int i = 1; i < count; i++)
if (last_syllable != info[i].syllable()) {
- record_pref_syllable (info, last, i, mask);
+ record_pref_syllable (info, last, i);
last = i;
last_syllable = info[last].syllable();
}
- record_pref_syllable (info, last, count, mask);
+ record_pref_syllable (info, last, count);
}
static void