From 9f0ce7a2722f22592b39fb4fbf9e1413658c7f09 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 30 Jan 2011 10:38:15 +0000 Subject: [PATCH] Evas textblock + font engine: add an optimized way of doing a cut-off on the text props. SVN revision: 56470 --- .../src/lib/canvas/evas_object_textblock.c | 4 +--- .../src/lib/engines/common/evas_font_ot.c | 22 +++++++++++++++++++ .../src/lib/engines/common/evas_font_ot.h | 3 +++ .../src/lib/engines/common/evas_text_utils.c | 10 +++++++++ .../src/lib/engines/common/evas_text_utils.h | 3 +++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/legacy/evas/src/lib/canvas/evas_object_textblock.c b/legacy/evas/src/lib/canvas/evas_object_textblock.c index 71a4918ff0..9b843432d4 100644 --- a/legacy/evas/src/lib/canvas/evas_object_textblock.c +++ b/legacy/evas/src/lib/canvas/evas_object_textblock.c @@ -2296,9 +2296,7 @@ _layout_item_text_cutoff(Ctxt *c __UNUSED__, Evas_Object_Textblock_Text_Item *ti ts[cut] = 0; ti->text = eina_unicode_strdup(ts); free(ts); - c->ENFN->font_shape(c->ENDT, ti->format->font.font, ti->text, - &ti->parent.text_props, ti->parent.text_node->bidi_props, - ti->parent.text_pos, cut); + evas_common_text_props_cutoff(&ti->parent.text_props, cut); } /** diff --git a/legacy/evas/src/lib/engines/common/evas_font_ot.c b/legacy/evas/src/lib/engines/common/evas_font_ot.c index fb1e7ec58d..3a77afec8d 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_ot.c +++ b/legacy/evas/src/lib/engines/common/evas_font_ot.c @@ -112,6 +112,28 @@ _evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Source *src) hb_font_destroy(hb_font); } +/* Won't work in the middle of ligatures */ +EAPI void +evas_common_font_ot_cutoff_text_props(Evas_Text_Props *props, int cutoff) +{ + Evas_Font_OT_Data_Item *tmp; + if ((cutoff <= 0) || (!props->ot_data) || + (((size_t) cutoff) >= props->ot_data->len)) + return; + + if (props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) + { + memmove(props->ot_data->items, + props->ot_data->items + (props->ot_data->len - cutoff), + cutoff * sizeof(Evas_Font_OT_Data_Item)); + } + tmp = realloc(props->ot_data->items, + cutoff * sizeof(Evas_Font_OT_Data_Item)); + props->ot_data->items = tmp; + props->ot_data->len = cutoff; + +} + EAPI Eina_Bool evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text, Evas_Text_Props *props, int len) diff --git a/legacy/evas/src/lib/engines/common/evas_font_ot.h b/legacy/evas/src/lib/engines/common/evas_font_ot.h index 5aa560ade7..5ec19ce0d2 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_ot.h +++ b/legacy/evas/src/lib/engines/common/evas_font_ot.h @@ -75,5 +75,8 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i EAPI Eina_Bool evas_common_font_ot_populate_text_props(void *fn, const Eina_Unicode *text, Evas_Text_Props *props, int len); + +EAPI void +evas_common_font_ot_cutoff_text_props(Evas_Text_Props *props, int cutoff); #endif diff --git a/legacy/evas/src/lib/engines/common/evas_text_utils.c b/legacy/evas/src/lib/engines/common/evas_text_utils.c index e5fd81c6a0..50ca45ef27 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.c +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.c @@ -57,3 +57,13 @@ evas_common_text_props_content_unref(Evas_Text_Props *props) #endif } +/* Won't work in the middle of ligatures */ +EAPI void +evas_common_text_props_cutoff(Evas_Text_Props *props, int cutoff) +{ +#ifdef OT_SUPPORT + evas_common_font_ot_cutoff_text_props(props, cutoff); +#endif +} + + diff --git a/legacy/evas/src/lib/engines/common/evas_text_utils.h b/legacy/evas/src/lib/engines/common/evas_text_utils.h index ccc4d20ceb..ecc6a93641 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.h +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.h @@ -29,4 +29,7 @@ evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst, void evas_common_text_props_content_unref(Evas_Text_Props *props); +EAPI void +evas_common_text_props_cutoff(Evas_Text_Props *props, int cutoff); + #endif