[amalgam] Finish fixing Indic-like shapers

Part of https://github.com/harfbuzz/harfbuzz/issues/1809
This commit is contained in:
Behdad Esfahbod 2019-07-02 15:23:00 -07:00
parent eb37bc9d93
commit 3724f13ba0
7 changed files with 61 additions and 55 deletions

View File

@ -392,9 +392,9 @@ compare_indic_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
static void
update_consonant_positions (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
update_consonant_positions_indic (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) plan->data;
@ -917,10 +917,10 @@ initial_reordering_standalone_cluster (const hb_ot_shape_plan_t *plan,
}
static void
initial_reordering_syllable (const hb_ot_shape_plan_t *plan,
hb_face_t *face,
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
initial_reordering_syllable_indic (const hb_ot_shape_plan_t *plan,
hb_face_t *face,
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
{
indic_syllable_type_t syllable_type = (indic_syllable_type_t) (buffer->info[start].syllable() & 0x0F);
switch (syllable_type)
@ -942,9 +942,9 @@ initial_reordering_syllable (const hb_ot_shape_plan_t *plan,
}
static inline void
insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
insert_dotted_circles_indic (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
{
if (unlikely (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE))
return;
@ -1009,17 +1009,17 @@ initial_reordering_indic (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
update_consonant_positions (plan, font, buffer);
insert_dotted_circles (plan, font, buffer);
update_consonant_positions_indic (plan, font, buffer);
insert_dotted_circles_indic (plan, font, buffer);
foreach_syllable (buffer, start, end)
initial_reordering_syllable (plan, font->face, buffer, start, end);
initial_reordering_syllable_indic (plan, font->face, buffer, start, end);
}
static void
final_reordering_syllable (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
final_reordering_syllable_indic (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
{
const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) plan->data;
hb_glyph_info_t *info = buffer->info;
@ -1488,7 +1488,7 @@ final_reordering_indic (const hb_ot_shape_plan_t *plan,
if (unlikely (!count)) return;
foreach_syllable (buffer, start, end)
final_reordering_syllable (plan, buffer, start, end);
final_reordering_syllable_indic (plan, buffer, start, end);
HB_BUFFER_DEALLOCATE_VAR (buffer, indic_category);
HB_BUFFER_DEALLOCATE_VAR (buffer, indic_position);

View File

@ -64,7 +64,14 @@ enum indic_category_t {
OT_Ra = 16,
OT_CM = 17, /* Consonant-Medial. */
OT_Symbol = 18, /* Avagraha, etc that take marks (SM,A,VD). */
OT_CS = 19
OT_CS = 19,
/* The following are used by Khmer & Myanmar shapers. Defined
* here for them to share. */
OT_VAbv = 26,
OT_VBlw = 27,
OT_VPre = 28,
OT_VPst = 29,
};
#define MEDIAL_FLAGS (FLAG (OT_CM))

View File

@ -318,10 +318,10 @@ reorder_consonant_syllable (const hb_ot_shape_plan_t *plan,
}
static void
initial_reordering_syllable (const hb_ot_shape_plan_t *plan,
hb_face_t *face,
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
reorder_syllable_khmer (const hb_ot_shape_plan_t *plan,
hb_face_t *face,
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
{
khmer_syllable_type_t syllable_type = (khmer_syllable_type_t) (buffer->info[start].syllable() & 0x0F);
switch (syllable_type)
@ -337,9 +337,9 @@ initial_reordering_syllable (const hb_ot_shape_plan_t *plan,
}
static inline void
insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
insert_dotted_circles_khmer (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
{
if (unlikely (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE))
return;
@ -404,10 +404,10 @@ reorder_khmer (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
insert_dotted_circles (plan, font, buffer);
insert_dotted_circles_khmer (plan, font, buffer);
foreach_syllable (buffer, start, end)
initial_reordering_syllable (plan, font->face, buffer, start, end);
reorder_syllable_khmer (plan, font->face, buffer, start, end);
HB_BUFFER_DEALLOCATE_VAR (buffer, khmer_category);
}

View File

@ -43,11 +43,10 @@ enum khmer_category_t
OT_Robatic = 20,
OT_Xgroup = 21,
OT_Ygroup = 22,
OT_VAbv = 26,
OT_VBlw = 27,
OT_VPre = 28,
OT_VPst = 29,
//OT_VAbv = 26,
//OT_VBlw = 27,
//OT_VPre = 28,
//OT_VPst = 29,
};
static inline void
@ -100,10 +99,10 @@ set_khmer_properties (hb_glyph_info_t &info)
if (cat == (khmer_category_t) OT_M)
switch ((int) pos)
{
case POS_PRE_C: cat = OT_VPre; break;
case POS_BELOW_C: cat = OT_VBlw; break;
case POS_ABOVE_C: cat = OT_VAbv; break;
case POS_POST_C: cat = OT_VPst; break;
case POS_PRE_C: cat = (khmer_category_t) OT_VPre; break;
case POS_BELOW_C: cat = (khmer_category_t) OT_VBlw; break;
case POS_ABOVE_C: cat = (khmer_category_t) OT_VAbv; break;
case POS_POST_C: cat = (khmer_category_t) OT_VPst; break;
default: assert (0);
}

View File

@ -294,9 +294,9 @@ reorder_syllable_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED,
}
static inline void
insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
insert_dotted_circles_myanmar (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
{
if (unlikely (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE))
return;
@ -355,7 +355,7 @@ reorder_myanmar (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
insert_dotted_circles (plan, font, buffer);
insert_dotted_circles_myanmar (plan, font, buffer);
foreach_syllable (buffer, start, end)
reorder_syllable_myanmar (plan, font->face, buffer, start, end);

View File

@ -49,10 +49,10 @@ enum myanmar_category_t {
OT_MW = 23, /* Various consonant medial types */
OT_MY = 24, /* Various consonant medial types */
OT_PT = 25, /* Pwo and other tones */
OT_VAbv = 26,
OT_VBlw = 27,
OT_VPre = 28,
OT_VPst = 29,
//OT_VAbv = 26,
//OT_VBlw = 27,
//OT_VPre = 28,
//OT_VPst = 29,
OT_VS = 30, /* Variation selectors */
OT_P = 31, /* Punctuation */
OT_D = 32, /* Digits except zero */
@ -155,11 +155,11 @@ set_myanmar_properties (hb_glyph_info_t &info)
{
switch ((int) pos)
{
case POS_PRE_C: cat = OT_VPre;
case POS_PRE_C: cat = (myanmar_category_t) OT_VPre;
pos = POS_PRE_M; break;
case POS_ABOVE_C: cat = OT_VAbv; break;
case POS_BELOW_C: cat = OT_VBlw; break;
case POS_POST_C: cat = OT_VPst; break;
case POS_ABOVE_C: cat = (myanmar_category_t) OT_VAbv; break;
case POS_BELOW_C: cat = (myanmar_category_t) OT_VBlw; break;
case POS_POST_C: cat = (myanmar_category_t) OT_VPst; break;
}
}

View File

@ -412,7 +412,7 @@ record_pref_use (const hb_ot_shape_plan_t *plan HB_UNUSED,
}
static inline bool
is_halant (const hb_glyph_info_t &info)
is_halant_use (const hb_glyph_info_t &info)
{
return (info.use_category() == USE_H || info.use_category() == USE_HVM) &&
!_hb_glyph_info_ligated (&info);
@ -458,7 +458,7 @@ reorder_syllable_use (hb_buffer_t *buffer, unsigned int start, unsigned int end)
for (unsigned int i = start + 1; i < end; i++)
{
bool is_post_base_glyph = (FLAG64_UNSAFE (info[i].use_category()) & POST_BASE_FLAGS64) ||
is_halant (info[i]);
is_halant_use (info[i]);
if (is_post_base_glyph || i == end - 1)
{
/* If we hit a post-base glyph, move before it; otherwise move to the
@ -482,7 +482,7 @@ reorder_syllable_use (hb_buffer_t *buffer, unsigned int start, unsigned int end)
for (unsigned int i = start; i < end; i++)
{
uint32_t flag = FLAG_UNSAFE (info[i].use_category());
if (is_halant (info[i]))
if (is_halant_use (info[i]))
{
/* If we hit a halant, move after it; otherwise move to the beginning, and
* shift things in between forward. */
@ -502,9 +502,9 @@ reorder_syllable_use (hb_buffer_t *buffer, unsigned int start, unsigned int end)
}
static inline void
insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
insert_dotted_circles_use (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font,
hb_buffer_t *buffer)
{
if (unlikely (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE))
return;
@ -564,7 +564,7 @@ reorder_use (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
insert_dotted_circles (plan, font, buffer);
insert_dotted_circles_use (plan, font, buffer);
foreach_syllable (buffer, start, end)
reorder_syllable_use (buffer, start, end);