Evas font-engine: Added text_len to text_props which fixes

a bug with cursor position and ligatures.

SVN revision: 56983
This commit is contained in:
Tom Hacohen 2011-02-13 12:57:37 +00:00
parent 8729a314ab
commit 9ed2f6cbc0
4 changed files with 12 additions and 15 deletions

View File

@ -31,10 +31,6 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i
i++)
;
right_bound = i;
if (left_bound < 0)
left_bound = 0;
if (right_bound >= (int) (props->start + props->len))
right_bound = props->start + props->len - 1;
if (right_bound == left_bound)
{
@ -44,26 +40,22 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i
{
if (left_bound < 0)
{
items = props->start + props->len -
props->info->ot[left_bound + 1].source_cluster;
items = props->text_offset + props->text_len - base_cluster;
}
else
{
items = props->info->ot[left_bound].source_cluster -
props->info->ot[left_bound + 1].source_cluster;
items = props->info->ot[left_bound].source_cluster - base_cluster;
}
}
else
{
if (right_bound == (int) (props->start + props->len))
if (right_bound > (int) (props->text_offset + props->text_len))
{
items = props->start + props->len -
props->info->ot[right_bound - 1].source_cluster;
items = props->text_offset + props->text_len - base_cluster;
}
else
{
items = props->info->ot[right_bound].source_cluster -
props->info->ot[right_bound - 1].source_cluster;
items = props->info->ot[right_bound].source_cluster - base_cluster;
}
}
return (items > 0) ? items : 1;

View File

@ -143,7 +143,7 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const Eina_Unicode *text __UNU
position = pos;
/* If it's the null, choose location according to the direction. */
if (text_props->len == position)
if (position == text_props->text_len)
{
/* if it's rtl then the location is the left of the string,
* otherwise, the right. */
@ -267,7 +267,7 @@ evas_common_font_query_pen_coords(RGBA_Font *fn, const Eina_Unicode *text __UNUS
position = pos;
/* If it's the null, choose location according to the direction. */
if (text_props->len == position)
if (position == text_props->text_len)
{
/* if it's rtl then the location is the left of the string,
* otherwise, the right. */

View File

@ -143,6 +143,8 @@ evas_common_text_props_split(Evas_Text_Props *base,
ext->text_offset = base->text_offset + base->len;
#endif
}
ext->text_len = base->text_len - (ext->text_offset - base->text_offset);
base->text_len = (ext->text_offset - base->text_offset);
}
/* Won't work in the middle of ligatures */
@ -161,6 +163,7 @@ evas_common_text_props_merge(Evas_Text_Props *item1,
}
item1->len += item2->len;
item1->text_len += item2->text_len;
}
EAPI Eina_Bool
@ -325,6 +328,7 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
}
text_props->len = len;
#endif
text_props->text_len = len;
text_props->info->refcount = 1;
return EINA_TRUE;
}

View File

@ -16,6 +16,7 @@ struct _Evas_Text_Props
size_t start;
size_t len;
size_t text_offset; /* The text offset from the start of the info */
size_t text_len; /* The length of the original text */
Evas_BiDi_Props bidi;
Evas_Script_Type script;
Evas_Text_Props_Info *info;