parent
8ba9e68968
commit
ac596511a8
|
@ -179,6 +179,30 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout);
|
||||||
#define lig_props() var1.u8[2] /* GSUB/GPOS ligature tracking */
|
#define lig_props() var1.u8[2] /* GSUB/GPOS ligature tracking */
|
||||||
#define syllable() var1.u8[3] /* GSUB/GPOS shaping boundaries */
|
#define syllable() var1.u8[3] /* GSUB/GPOS shaping boundaries */
|
||||||
|
|
||||||
|
|
||||||
|
/* loop over syllables */
|
||||||
|
|
||||||
|
#define foreach_syllable(buffer, start, end) \
|
||||||
|
for (unsigned int \
|
||||||
|
_count = buffer->len, \
|
||||||
|
start = 0, end = _count ? _next_syllable (buffer, 0) : 0; \
|
||||||
|
start < _count; \
|
||||||
|
start = end, end = _next_syllable (buffer, start))
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
_next_syllable (hb_buffer_t *buffer, unsigned int start)
|
||||||
|
{
|
||||||
|
hb_glyph_info_t *info = buffer->info;
|
||||||
|
unsigned int count = buffer->len;
|
||||||
|
|
||||||
|
unsigned int syllable = info[start].syllable();
|
||||||
|
while (++start < count && syllable == info[start].syllable())
|
||||||
|
;
|
||||||
|
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* unicode_props */
|
/* unicode_props */
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -263,16 +263,6 @@ setup_masks_use (const hb_ot_shape_plan_t *plan,
|
||||||
info[i].use_category() = hb_use_get_categories (info[i].codepoint);
|
info[i].use_category() = hb_use_get_categories (info[i].codepoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
setup_syllable (const use_shape_plan_t *use_plan,
|
|
||||||
hb_glyph_info_t *info,
|
|
||||||
unsigned int start, unsigned int end)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_syllables (const hb_ot_shape_plan_t *plan,
|
setup_syllables (const hb_ot_shape_plan_t *plan,
|
||||||
hb_font_t *font HB_UNUSED,
|
hb_font_t *font HB_UNUSED,
|
||||||
|
@ -280,22 +270,21 @@ setup_syllables (const hb_ot_shape_plan_t *plan,
|
||||||
{
|
{
|
||||||
find_syllables (buffer);
|
find_syllables (buffer);
|
||||||
|
|
||||||
/* Setup masks for 'rphf' and 'pref'. */
|
/* Setup 'rphf' mask. */
|
||||||
|
|
||||||
const use_shape_plan_t *use_plan = (const use_shape_plan_t *) plan->data;
|
const use_shape_plan_t *use_plan = (const use_shape_plan_t *) plan->data;
|
||||||
if (!use_plan->rphf_mask) return;
|
|
||||||
|
hb_mask_t mask = use_plan->rphf_mask;
|
||||||
|
if (!mask) return;
|
||||||
|
|
||||||
hb_glyph_info_t *info = buffer->info;
|
hb_glyph_info_t *info = buffer->info;
|
||||||
unsigned int count = buffer->len;
|
|
||||||
if (unlikely (!count)) return;
|
foreach_syllable (buffer, start, end)
|
||||||
unsigned int last = 0;
|
{
|
||||||
unsigned int last_syllable = info[0].syllable();
|
unsigned int limit = info[start].use_category() == USE_R ? 1 : MIN (3u, end - start);
|
||||||
for (unsigned int i = 1; i < count; i++)
|
for (unsigned int i = start; i < start + limit; i++)
|
||||||
if (last_syllable != info[i].syllable()) {
|
info[i].mask |= mask;
|
||||||
setup_syllable (use_plan, info, last, i);
|
|
||||||
last = i;
|
|
||||||
last_syllable = info[last].syllable();
|
|
||||||
}
|
}
|
||||||
setup_syllable (use_plan, info, last, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -309,55 +298,26 @@ clear_substitution_flags (const hb_ot_shape_plan_t *plan,
|
||||||
_hb_glyph_info_clear_substituted_and_ligated_and_multiplied (&info[i]);
|
_hb_glyph_info_clear_substituted_and_ligated_and_multiplied (&info[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
record_rphf_syllable (hb_glyph_info_t *info,
|
|
||||||
unsigned int start, unsigned int end,
|
|
||||||
hb_mask_t 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_rphf (const hb_ot_shape_plan_t *plan,
|
record_rphf (const hb_ot_shape_plan_t *plan,
|
||||||
hb_font_t *font,
|
hb_font_t *font,
|
||||||
hb_buffer_t *buffer)
|
hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
const use_shape_plan_t *use_plan = (const use_shape_plan_t *) plan->data;
|
const use_shape_plan_t *use_plan = (const use_shape_plan_t *) plan->data;
|
||||||
hb_mask_t mask = use_plan->rphf_mask;
|
|
||||||
|
|
||||||
|
hb_mask_t mask = use_plan->rphf_mask;
|
||||||
if (!mask) return;
|
if (!mask) return;
|
||||||
hb_glyph_info_t *info = buffer->info;
|
hb_glyph_info_t *info = buffer->info;
|
||||||
unsigned int count = buffer->len;
|
|
||||||
if (unlikely (!count)) return;
|
|
||||||
unsigned int last = 0;
|
|
||||||
unsigned int last_syllable = info[0].syllable();
|
|
||||||
for (unsigned int i = 1; i < count; i++)
|
|
||||||
if (last_syllable != info[i].syllable()) {
|
|
||||||
record_rphf_syllable (info, last, i, mask);
|
|
||||||
last = i;
|
|
||||||
last_syllable = info[last].syllable();
|
|
||||||
}
|
|
||||||
record_rphf_syllable (info, last, count, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
foreach_syllable (buffer, start, end)
|
||||||
record_pref_syllable (hb_glyph_info_t *info,
|
|
||||||
unsigned int start, unsigned int end)
|
|
||||||
{
|
{
|
||||||
/* Mark a substituted pref as VPre, as they behave the same way. */
|
/* Mark a substituted repha as USE_R. */
|
||||||
for (unsigned int i = start; i < end; i++)
|
for (unsigned int i = start; i < end && (info[i].mask & mask); i++)
|
||||||
if (_hb_glyph_info_substituted (&info[i]))
|
if (_hb_glyph_info_substituted (&info[i]))
|
||||||
{
|
{
|
||||||
/* Found the one. Mark it as Repha. */
|
info[i].use_category() = USE_R;
|
||||||
info[i].use_category() = USE_VPre;
|
break;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,24 +327,21 @@ record_pref (const hb_ot_shape_plan_t *plan,
|
||||||
hb_buffer_t *buffer)
|
hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
hb_glyph_info_t *info = buffer->info;
|
hb_glyph_info_t *info = buffer->info;
|
||||||
unsigned int count = buffer->len;
|
|
||||||
if (unlikely (!count)) return;
|
foreach_syllable (buffer, start, end)
|
||||||
unsigned int last = 0;
|
{
|
||||||
unsigned int last_syllable = info[0].syllable();
|
/* Mark a substituted pref as VPre, as they behave the same way. */
|
||||||
for (unsigned int i = 1; i < count; i++)
|
for (unsigned int i = start; i < end; i++)
|
||||||
if (last_syllable != info[i].syllable()) {
|
if (_hb_glyph_info_substituted (&info[i]))
|
||||||
record_pref_syllable (info, last, i);
|
{
|
||||||
last = i;
|
info[i].use_category() = USE_VPre;
|
||||||
last_syllable = info[last].syllable();
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
record_pref_syllable (info, last, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reorder_syllable (const hb_ot_shape_plan_t *plan,
|
reorder_syllable (hb_buffer_t *buffer, unsigned int start, unsigned int end)
|
||||||
hb_face_t *face,
|
|
||||||
hb_buffer_t *buffer,
|
|
||||||
unsigned int start, unsigned int end)
|
|
||||||
{
|
{
|
||||||
syllable_type_t syllable_type = (syllable_type_t) (buffer->info[start].syllable() & 0x0F);
|
syllable_type_t syllable_type = (syllable_type_t) (buffer->info[start].syllable() & 0x0F);
|
||||||
/* Only a few syllable types need reordering. */
|
/* Only a few syllable types need reordering. */
|
||||||
|
@ -481,6 +438,7 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
|
||||||
buffer->clear_output ();
|
buffer->clear_output ();
|
||||||
|
|
||||||
buffer->idx = 0;
|
buffer->idx = 0;
|
||||||
|
|
||||||
unsigned int last_syllable = 0;
|
unsigned int last_syllable = 0;
|
||||||
while (buffer->idx < buffer->len)
|
while (buffer->idx < buffer->len)
|
||||||
{
|
{
|
||||||
|
@ -519,19 +477,12 @@ reorder (const hb_ot_shape_plan_t *plan,
|
||||||
insert_dotted_circles (plan, font, buffer);
|
insert_dotted_circles (plan, font, buffer);
|
||||||
|
|
||||||
hb_glyph_info_t *info = buffer->info;
|
hb_glyph_info_t *info = buffer->info;
|
||||||
unsigned int count = buffer->len;
|
|
||||||
if (unlikely (!count)) return;
|
foreach_syllable (buffer, start, end)
|
||||||
unsigned int last = 0;
|
reorder_syllable (buffer, start, end);
|
||||||
unsigned int last_syllable = info[0].syllable();
|
|
||||||
for (unsigned int i = 1; i < count; i++)
|
|
||||||
if (last_syllable != info[i].syllable()) {
|
|
||||||
reorder_syllable (plan, font->face, buffer, last, i);
|
|
||||||
last = i;
|
|
||||||
last_syllable = info[last].syllable();
|
|
||||||
}
|
|
||||||
reorder_syllable (plan, font->face, buffer, last, count);
|
|
||||||
|
|
||||||
/* Zero syllables now... */
|
/* Zero syllables now... */
|
||||||
|
unsigned int count = buffer->len;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
info[i].syllable() = 0;
|
info[i].syllable() = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue