Evas text utils: Fixed walking compound clusters.

In some scripts, like Devanagari, clusters can be split across more
than just one glyph. This is now fixed.

Thanks to YoungBok Shin for reporting.
This commit is contained in:
Tom Hacohen 2014-02-19 12:01:08 +00:00
parent e0428e9cb0
commit 27b1bebea5
1 changed files with 20 additions and 4 deletions

View File

@ -117,8 +117,16 @@ _evas_common_text_props_cluster_move(const Evas_Text_Props *props, int pos,
if (!right && (prop_pos > 0))
{
#ifdef OT_SUPPORT
return props->info->ot[props->start + prop_pos - 1].source_cluster -
props->text_offset;
int base_cluster = props->info->ot[props->start + prop_pos].source_cluster;
prop_pos--;
for ( ; prop_pos >= 0 ; prop_pos--)
{
int cur_cluster = props->info->ot[props->start + prop_pos].source_cluster;
if (cur_cluster != base_cluster)
{
return cur_cluster - props->text_offset;
}
}
#else
return props->start + prop_pos - 1 - props->text_offset;
#endif
@ -126,8 +134,16 @@ _evas_common_text_props_cluster_move(const Evas_Text_Props *props, int pos,
else if (right && (prop_pos < (int) (props->len - 1)))
{
#ifdef OT_SUPPORT
return props->info->ot[props->start + prop_pos + 1].source_cluster -
props->text_offset;
int base_cluster = props->info->ot[props->start + prop_pos].source_cluster;
prop_pos++;
for ( ; prop_pos < (int) props->len ; prop_pos++)
{
int cur_cluster = props->info->ot[props->start + prop_pos].source_cluster;
if (cur_cluster != base_cluster)
{
return cur_cluster - props->text_offset;
}
}
#else
return props->start + prop_pos + 1 - props->text_offset;
#endif