summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2014-11-04 15:23:40 +0200
committerDaniel Hirt <daniel.hirt@samsung.com>2014-11-09 17:41:18 +0200
commit9f43ff9a9d582890891848b2d2ed79bd5eeb6851 (patch)
treedb330a1b7a49a1a90efc5b5624c606f718d6d354
parentb3bb81e12366472e23a643f549ce7efd3de84f2c (diff)
downloadefl-9f43ff9a9d582890891848b2d2ed79bd5eeb6851.tar.gz
fix: revised hard split of text props
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c88
-rw-r--r--src/lib/evas/common/evas_font_ot.c1
-rw-r--r--src/lib/evas/common/evas_text_utils.c40
3 files changed, 112 insertions, 17 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index f70cc1b325..3c1993c945 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -5439,21 +5439,18 @@ Evas_Object_Textblock_Text_Item *right_ti, size_t text_len)
if (right_ti)
{
props_right = &right_ti->text_props;
+ right_ti->parent.merge = EINA_FALSE;
}
evas_common_text_props_hard_split(props_left, props_mid, props_right, text_len, 0);
- //fix start of props_left
if (props_right)
{
- Eina_List *i;
+ Eina_List *i, *start;
Evas_Object_Textblock_Item *it;
- it = eina_list_data_get(right);
- it->merge = EINA_FALSE;
-
- right = eina_list_next(right);
- EINA_LIST_FOREACH(right, i, it)
+ start = eina_list_next(right);
+ EINA_LIST_FOREACH(start, i, it)
{
if (!it->merge) break;
@@ -5462,6 +5459,49 @@ Evas_Object_Textblock_Text_Item *right_ti, size_t text_len)
evas_common_text_props_content_ref(props_right);
}
}
+
+ /* fix start positions and clusters */
+ if (left_ti && left_ti->parent.merge && (mid_ti->text_props.bidi_dir == EVAS_BIDI_DIRECTION_RTL))
+ {
+ Eina_List *i;
+ Evas_Object_Textblock_Item *it;
+ Evas_Object_Textblock_Text_Item *prev_ti = left_ti;
+ Eina_List *l = eina_list_prev(left);
+
+ i = l;
+ do
+ {
+ /* first prev exists since we checked left_ti->parent.merge */
+ it = eina_list_data_get(i);
+ _ITEM_TEXT(it)->text_props.start = prev_ti->text_props.start + prev_ti->text_props.len;
+ if (!it->merge) break;
+
+ prev_ti = _ITEM_TEXT(it);
+ i = eina_list_prev(i);
+ } while(it->merge);
+
+ }
+
+ /* fix start positions and clusters */
+ if (right_ti)
+ {
+ Eina_List *i;
+ Evas_Object_Textblock_Item *it;
+ Evas_Object_Textblock_Text_Item *prev_ti = right_ti;
+ Eina_List *l = eina_list_next(right);
+
+ EINA_LIST_FOREACH(l, i, it)
+ {
+ if (!it->merge) break;
+ if (mid_ti->text_props.bidi_dir != EVAS_BIDI_DIRECTION_RTL)
+ {
+ _ITEM_TEXT(it)->text_props.start = prev_ti->text_props.start + prev_ti->text_props.len;
+ }
+ _ITEM_TEXT(it)->text_props.text_offset = prev_ti->text_props.text_offset + prev_ti->text_props.text_len;
+
+ prev_ti = _ITEM_TEXT(it);
+ }
+ }
}
@@ -12628,6 +12668,33 @@ ptextblock(Evas_Textblock_Data *o)
}
EAPI void
+ptextpropsinfo(Evas_Text_Props *props)
+{
+ size_t i;
+ Evas_Text_Props_Info *info = props->info;
+ printf(" Info:\n");
+ int cur = 0;
+ for (i = 0; i < props->info->len; i++)
+ {
+ if (!cur && (i >= props->start))
+ {
+ cur = 1;
+ printf("****** CURRENT ITEM **************************\n");
+ }
+ else if ((cur == 1) && (i >= props->start + props->len))
+ {
+ cur = 2;
+ printf("***************************************\n");
+ }
+ printf(" [idx=%lu]\n", i);
+ printf(" info->cluster=%lu\n", info->ot[i].source_cluster);
+ printf(" info->glyph->index=%d\n", info->glyph[i].index);
+ printf(" info->glyph->pen_after=%d\n", info->glyph[i].pen_after);
+ printf(" info->glyph->width=%d\n", info->glyph[i].width);
+ }
+}
+
+EAPI void
ptextprops(Evas_Text_Props *props)
{
printf("[Props]\n");
@@ -12648,13 +12715,14 @@ ptextprops(Evas_Text_Props *props)
}
EAPI void
-ptextprops_items(Evas_Object_Textblock_Paragraph *par)
+ptextprops_items(Eina_List *start, Eina_List *skip)
{
Eina_List *i;
Evas_Object_Textblock_Item *it;
- EINA_LIST_FOREACH(par->logical_items, i, it)
+ EINA_LIST_FOREACH(start, i, it)
{
- printf("[Item] (text_pos=%d)", it->text_pos);
+ if (i == skip) continue;
+ printf("[Item] (text_pos=%lu)", it->text_pos);
if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
{
ptextprops(&_ITEM_TEXT(it)->text_props);
diff --git a/src/lib/evas/common/evas_font_ot.c b/src/lib/evas/common/evas_font_ot.c
index d5b89379b2..b20c955568 100644
--- a/src/lib/evas/common/evas_font_ot.c
+++ b/src/lib/evas/common/evas_font_ot.c
@@ -597,7 +597,6 @@ evas_common_font_ot_hard_split_text_props_rtl(Evas_Text_Props *props_left, Evas_
left_info->ot = malloc(left_len * sizeof(Evas_Font_OT_Info));
memcpy(left_info->glyph, old_glyph + props_mid->start + props_mid->len, left_len * sizeof(Evas_Font_Glyph_Info));
memcpy(left_info->ot, old_ot + props_mid->start + props_mid->len, left_len * sizeof(Evas_Font_OT_Info));
- //no need to change left's start
props_left->start = 0;
props_left->info->len = left_len;
}
diff --git a/src/lib/evas/common/evas_text_utils.c b/src/lib/evas/common/evas_text_utils.c
index a471537c30..5cb06999f4 100644
--- a/src/lib/evas/common/evas_text_utils.c
+++ b/src/lib/evas/common/evas_text_utils.c
@@ -326,6 +326,21 @@ evas_common_text_props_cut(Evas_Text_Props *props1,
return EINA_TRUE;
}
+static inline void
+_rectify_cluster_indices(Evas_Text_Props *props, int clust_idx_old)
+{
+ int clust_idx_new = props->text_offset; //now it's 0, because of hard split
+ int clust_diff = clust_idx_new - clust_idx_old;
+ size_t pos;
+
+ for (pos = 0; pos < props->info->len; pos++)
+ {
+ /* rectify cluster indices */
+ props->info->ot[pos].source_cluster += clust_diff;
+ }
+
+}
+
/**
* @internal
* Description here
@@ -350,14 +365,27 @@ evas_common_text_props_hard_split(Evas_Text_Props *props_left, Evas_Text_Props *
evas_common_font_ot_hard_split_text_props(props_left, props_mid, props_right, mode);
/* Fields associated with glyph/ot info were updated in the above call */
if (props_right)
- {
- props_mid->info->refcount--; /* deattaching right_props */
- props_right->text_offset = 0;
- props_right->changed = EINA_TRUE;
- }
+ {
+ props_mid->info->refcount--; /* deattaching right_props */
+ props_right->changed = EINA_TRUE;
+ if (props_mid->bidi_dir == EVAS_BIDI_DIRECTION_RTL)
+ {
+ props_right->text_offset = 0;
+ int clust_idx_old = props_right->info->ot[props_right->info->len - 1].source_cluster;
+ _rectify_cluster_indices(props_right, clust_idx_old);
+ }
+ }
if (props_left)
- props_left->changed = EINA_TRUE;
+ {
+ if (props_mid->bidi_dir != EVAS_BIDI_DIRECTION_RTL)
+ {
+ props_left->text_offset = 0;
+ int clust_idx_old = props_right->info->ot[0].source_cluster;
+ _rectify_cluster_indices(props_right, clust_idx_old);
+ }
+ props_left->changed = EINA_TRUE;
+ }
return EINA_TRUE;
}