From a9709c792ec59fddcd5d146bf2e2d48a1362eb93 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 12 Jun 2012 14:14:52 +0000 Subject: [PATCH] Evas font: Support no bidi no shaping mode in font rendering. For no bidi: just don't set the bidi stuff. I.e paragraph props and the other stuff (including text_props_direction_set). If you disable BiDi you most likely want to disable shaping as well. For no shaping: Disable bidi (i.e don't set direction) and pass EVAS_TEXT_PROPS_MODE_NONE to info create. This will prove especially useful for textgrid, but not only. SVN revision: 72032 --- legacy/evas/src/lib/canvas/evas_object_text.c | 2 +- .../src/lib/canvas/evas_object_textblock.c | 4 +- .../src/lib/engines/common/evas_font_ot.c | 16 ++- .../src/lib/engines/common/evas_font_ot.h | 2 +- .../src/lib/engines/common/evas_text_utils.c | 99 +++++++++++-------- .../src/lib/engines/common/evas_text_utils.h | 8 +- legacy/evas/src/lib/include/evas_private.h | 2 +- .../engines/software_generic/evas_engine.c | 4 +- 8 files changed, 86 insertions(+), 51 deletions(-) diff --git a/legacy/evas/src/lib/canvas/evas_object_text.c b/legacy/evas/src/lib/canvas/evas_object_text.c index 2795f8cb28..03cfc9ae33 100644 --- a/legacy/evas/src/lib/canvas/evas_object_text.c +++ b/legacy/evas/src/lib/canvas/evas_object_text.c @@ -450,7 +450,7 @@ _evas_object_text_item_new(Evas_Object *obj, Evas_Object_Text *o, { ENFN->font_text_props_info_create(ENDT, fi, str + pos, &it->text_props, - o->bidi_par_props, it->text_pos, len); + o->bidi_par_props, it->text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE); ENFN->font_string_size_get(ENDT, o->font, diff --git a/legacy/evas/src/lib/canvas/evas_object_textblock.c b/legacy/evas/src/lib/canvas/evas_object_textblock.c index 8dc37a3fc4..82723441c1 100644 --- a/legacy/evas/src/lib/canvas/evas_object_textblock.c +++ b/legacy/evas/src/lib/canvas/evas_object_textblock.c @@ -3004,7 +3004,7 @@ skip: { c->ENFN->font_text_props_info_create(c->ENDT, cur_fi, str, &ti->text_props, c->par->bidi_props, - ti->parent.text_pos, run_len); + ti->parent.text_pos, run_len, EVAS_TEXT_PROPS_MODE_SHAPE); } str += run_len; script_len -= run_len; @@ -3508,7 +3508,7 @@ _layout_ellipsis_item_new(Ctxt *c, const Evas_Object_Textblock_Item *cur_it) c->ENFN->font_text_props_info_create(c->ENDT, cur_fi, _ellip_str, &ellip_ti->text_props, - c->par->bidi_props, ellip_ti->parent.text_pos, len); + c->par->bidi_props, ellip_ti->parent.text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE); } _text_item_update_sizes(c, ellip_ti); 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 2912d556dd..9ed92c75f0 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_ot.c +++ b/legacy/evas/src/lib/engines/common/evas_font_ot.c @@ -243,7 +243,7 @@ _evas_common_font_ot_unicode_funcs_get(void) } static void -_evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Int *fi) +_evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Int *fi, Evas_Text_Props_Mode mode) { /* Create hb_font if not previously created */ if (!fi->ft.hb_font) @@ -258,12 +258,20 @@ _evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Int *fi) _evas_common_font_ot_font_funcs_get(), fi, NULL); } - hb_shape(fi->ft.hb_font, buffer, NULL, 0); + if (mode == EVAS_TEXT_PROPS_MODE_SHAPE) + { + hb_shape(fi->ft.hb_font, buffer, NULL, 0); + } + else + { + const char *shaper_list[] = { "fallback", NULL }; + hb_shape_full(fi->ft.hb_font, buffer, NULL, 0, shaper_list); + } } EAPI Eina_Bool evas_common_font_ot_populate_text_props(const Eina_Unicode *text, - Evas_Text_Props *props, int len) + Evas_Text_Props *props, int len, Evas_Text_Props_Mode mode) { RGBA_Font_Int *fi; hb_buffer_t *buffer; @@ -297,7 +305,7 @@ evas_common_font_ot_populate_text_props(const Eina_Unicode *text, /* FIXME: add run-time conversions if needed, which is very unlikely */ hb_buffer_add_utf32(buffer, (const uint32_t *) text, slen, 0, slen); - _evas_common_font_ot_shape(buffer, fi); + _evas_common_font_ot_shape(buffer, fi, mode); props->len = hb_buffer_get_length(buffer); props->info->ot = calloc(props->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 bc5ab02b86..6398c92bea 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_ot.h +++ b/legacy/evas/src/lib/engines/common/evas_font_ot.h @@ -40,6 +40,6 @@ 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(const Eina_Unicode *text, - Evas_Text_Props *props, int len); + Evas_Text_Props *props, int len, Evas_Text_Props_Mode mode); #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 427bb84360..1cdcacd00f 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.c +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.c @@ -283,46 +283,16 @@ evas_common_text_props_merge(Evas_Text_Props *item1, PROPS_CHANGE(item1); } -EAPI Eina_Bool -evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, - Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, - size_t par_pos, int len) -{ - RGBA_Font_Int *fi = (RGBA_Font_Int *) _fi; - - if (text_props->info) - { - evas_common_text_props_content_unref(text_props); - } - if (len == 0) - { - text_props->info = NULL; - text_props->start = text_props->len = text_props->text_offset = 0; - } - text_props->info = calloc(1, sizeof(Evas_Text_Props_Info)); - - text_props->font_instance = fi; - - evas_common_font_int_reload(fi); - if (fi->src->current_size != fi->size) - { - evas_common_font_source_reload(fi->src); - FTLOCK(); - FT_Activate_Size(fi->ft.size); - FTUNLOCK(); - fi->src->current_size = fi->size; - } - - text_props->changed = EINA_TRUE; - #ifdef OT_SUPPORT +static inline void +_content_create_ot(RGBA_Font_Int *fi, const Eina_Unicode *text, + Evas_Text_Props *text_props, int len, Evas_Text_Props_Mode mode) +{ size_t char_index; Evas_Font_Glyph_Info *gl_itr; Evas_Coord pen_x = 0, adjust_x = 0; - (void) par_props; - (void) par_pos; - evas_common_font_ot_populate_text_props(text, text_props, len); + evas_common_font_ot_populate_text_props(text, text_props, len, mode); gl_itr = text_props->info->glyph; for (char_index = 0 ; char_index < text_props->len ; char_index++) @@ -380,7 +350,14 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, fi = text_props->font_instance; gl_itr++; } -#else +} +#endif + +static inline void +_content_create_regular(RGBA_Font_Int *fi, const Eina_Unicode *text, + Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, + size_t par_pos, int len, Evas_Text_Props_Mode mode) +{ /* We are walking the string in visual ordering */ Evas_Font_Glyph_Info *gl_itr; Eina_Bool use_kerning; @@ -390,12 +367,16 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, int adv_d, i; #if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT) Eina_Unicode *base_str = NULL; - if (text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) + if (mode == EVAS_TEXT_PROPS_MODE_SHAPE) { - text = base_str = eina_unicode_strndup(text, len); - evas_bidi_shape_string(base_str, par_props, par_pos, len); + if (text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) + { + text = base_str = eina_unicode_strndup(text, len); + evas_bidi_shape_string(base_str, par_props, par_pos, len); + } } #else + (void) mode; (void) par_props; (void) par_pos; #endif @@ -475,6 +456,46 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, if (base_str) free(base_str); # endif +} + +EAPI Eina_Bool +evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, + Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, + size_t par_pos, int len, Evas_Text_Props_Mode mode) +{ + RGBA_Font_Int *fi = (RGBA_Font_Int *) _fi; + + if (text_props->info) + { + evas_common_text_props_content_unref(text_props); + } + if (len == 0) + { + text_props->info = NULL; + text_props->start = text_props->len = text_props->text_offset = 0; + } + text_props->info = calloc(1, sizeof(Evas_Text_Props_Info)); + + text_props->font_instance = fi; + + evas_common_font_int_reload(fi); + if (fi->src->current_size != fi->size) + { + evas_common_font_source_reload(fi->src); + FTLOCK(); + FT_Activate_Size(fi->ft.size); + FTUNLOCK(); + fi->src->current_size = fi->size; + } + + text_props->changed = EINA_TRUE; + +#ifdef OT_SUPPORT + (void) par_props; + (void) par_pos; + _content_create_ot(fi, text, text_props, len, mode); +#else + _content_create_regular(fi, text, text_props, par_props, par_pos, len, mode); #endif text_props->text_len = len; 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 6a77cdbef8..ba5ef3736d 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.h +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.h @@ -53,6 +53,12 @@ struct _Evas_Font_Glyph_Info Evas_Coord pen_after; }; +typedef enum +{ + EVAS_TEXT_PROPS_MODE_NONE = 0, + EVAS_TEXT_PROPS_MODE_SHAPE +} Evas_Text_Props_Mode; + void evas_common_text_props_bidi_set(Evas_Text_Props *props, @@ -64,7 +70,7 @@ evas_common_text_props_script_set(Evas_Text_Props *props, Evas_Script_Type scr); EAPI Eina_Bool evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, - size_t par_pos, int len); + size_t par_pos, int len, Evas_Text_Props_Mode mode); void evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst, diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h index 30e4274229..c45ea86738 100644 --- a/legacy/evas/src/lib/include/evas_private.h +++ b/legacy/evas/src/lib/include/evas_private.h @@ -836,7 +836,7 @@ struct _Evas_Func void (*image_content_hint_set) (void *data, void *surface, int hint); int (*image_content_hint_get) (void *data, void *surface); int (*font_pen_coords_get) (void *data, Evas_Font_Set *font, const Evas_Text_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch); - Eina_Bool (*font_text_props_info_create) (void *data __UNUSED__, Evas_Font_Instance *fi, const Eina_Unicode *text, Evas_Text_Props *intl_props, const Evas_BiDi_Paragraph_Props *par_props, size_t pos, size_t len); + Eina_Bool (*font_text_props_info_create) (void *data __UNUSED__, Evas_Font_Instance *fi, const Eina_Unicode *text, Evas_Text_Props *intl_props, const Evas_BiDi_Paragraph_Props *par_props, size_t pos, size_t len, Evas_Text_Props_Mode mode); int (*font_right_inset_get) (void *data, Evas_Font_Set *font, const Evas_Text_Props *text_props); #if 0 // filtering disabled diff --git a/legacy/evas/src/modules/engines/software_generic/evas_engine.c b/legacy/evas/src/modules/engines/software_generic/evas_engine.c index 70a94e9f56..0126ef003f 100644 --- a/legacy/evas/src/modules/engines/software_generic/evas_engine.c +++ b/legacy/evas/src/modules/engines/software_generic/evas_engine.c @@ -1241,10 +1241,10 @@ eng_font_pen_coords_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_T } static Eina_Bool -eng_font_text_props_info_create(void *data __UNUSED__, Evas_Font_Instance *fi, const Eina_Unicode *text, Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, size_t par_pos, size_t len) +eng_font_text_props_info_create(void *data __UNUSED__, Evas_Font_Instance *fi, const Eina_Unicode *text, Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, size_t par_pos, size_t len, Evas_Text_Props_Mode mode) { return evas_common_text_props_content_create((RGBA_Font_Int *) fi, text, - text_props, par_props, par_pos, len); + text_props, par_props, par_pos, len, mode); } static int