From 840e1c53d8205229b753251c00bd8a0795c28194 Mon Sep 17 00:00:00 2001 From: Youngbok Shin Date: Thu, 4 Feb 2016 10:07:08 +0000 Subject: [PATCH] Evas: Use proper language for harfbuzz shaping Summary: Evas Text, Textblock, Textgrid keeps own language information. This language information could be vary from the result of setlocale(). Especially, Evas Textblock supports tag. The language could be changed in the middle of text. All of these language has to be used for harfbuzz shaping. @fix Test Plan: N/A Reviewers: herdsman, raster, woohyun, tasn Reviewed By: tasn Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3628 Change-Id: Ief121bb023af8fd7941408d8f67781d7fbfc4f14 --- src/lib/evas/canvas/evas_object_text.c | 3 ++- src/lib/evas/canvas/evas_object_textblock.c | 9 ++++++--- src/lib/evas/canvas/evas_object_textgrid.c | 6 ++++-- src/lib/evas/common/evas_font_ot.c | 5 ++--- src/lib/evas/common/evas_font_ot.h | 2 +- src/lib/evas/common/evas_text_utils.c | 9 +++++---- src/lib/evas/common/evas_text_utils.h | 2 +- src/lib/evas/include/evas_private.h | 2 +- src/modules/evas/engines/software_generic/evas_engine.c | 4 ++-- 9 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c index 4560857..8e1cebf 100644 --- a/src/lib/evas/canvas/evas_object_text.c +++ b/src/lib/evas/canvas/evas_object_text.c @@ -542,7 +542,8 @@ _evas_object_text_item_new(Evas_Object_Protected_Data *obj, { ENFN->font_text_props_info_create(ENDT, fi, str + pos, &it->text_props, - o->bidi_par_props, it->text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE); + o->bidi_par_props, it->text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE, + o->cur.fdesc->lang); _evas_object_text_item_update_sizes(obj, o, it); } o->items = (Evas_Object_Text_Item *) diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index aa4ce47..7bc9c8a 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -4068,7 +4068,8 @@ skip: { ENFN->font_text_props_info_create(ENDT, cur_fi, str, &ti->text_props, c->par->bidi_props, - ti->parent.text_pos, run_len, EVAS_TEXT_PROPS_MODE_SHAPE); + ti->parent.text_pos, run_len, EVAS_TEXT_PROPS_MODE_SHAPE, + ti->parent.format->font.fdesc->lang); } while ((queue->start + queue->off) < (run_start + run_len)) @@ -4747,7 +4748,8 @@ _layout_ellipsis_item_new(Ctxt *c, const Evas_Object_Textblock_Item *cur_it) ENFN->font_text_props_info_create(ENDT, cur_fi, _ellip_str, &ellip_ti->text_props, - c->par->bidi_props, ellip_ti->parent.text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE); + c->par->bidi_props, ellip_ti->parent.text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE, + ellip_ti->parent.format->font.fdesc->lang); } _text_item_update_sizes(c, ellip_ti); @@ -7525,7 +7527,8 @@ _layout_hyphen_item_new(Ctxt *c, const Evas_Object_Textblock_Text_Item *cur_ti) ENFN->font_text_props_info_create(ENDT, cur_fi, _hyphen_str, &hyphen_ti->text_props, - c->par->bidi_props, hyphen_ti->parent.text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE); + c->par->bidi_props, hyphen_ti->parent.text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE, + hyphen_ti->parent.format->font.fdesc->lang); } _text_item_update_sizes(c, hyphen_ti); diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c index 7aa7216..bc2f9d9 100644 --- a/src/lib/evas/canvas/evas_object_textgrid.c +++ b/src/lib/evas/canvas/evas_object_textgrid.c @@ -189,7 +189,8 @@ evas_object_textgrid_textprop_get(Evas_Object *eo_obj, Evas_Textgrid_Data *o, Ei evas_common_text_props_script_set(&(glyph->props[idx]), script); ENFN->font_text_props_info_create(ENDT, script_fi, &codepoint, &(glyph->props[idx]), NULL, 0, 1, - EVAS_TEXT_PROPS_MODE_NONE); + EVAS_TEXT_PROPS_MODE_NONE, + o->cur.font_description->lang); (*used)++; } else @@ -1216,7 +1217,8 @@ _evas_textgrid_efl_text_properties_font_set(Eo *eo_obj, Evas_Textgrid_Data *o, c evas_common_text_props_script_set(&text_props, script); ENFN->font_text_props_info_create(ENDT, script_fi, W, &text_props, NULL, 0, 1, - EVAS_TEXT_PROPS_MODE_NONE); + EVAS_TEXT_PROPS_MODE_NONE, + o->cur.font_description->lang); advance = ENFN->font_h_advance_get(ENDT, o->font, &text_props); vadvance = ENFN->font_v_advance_get(ENDT, o->font, &text_props); o->cur.char_width = advance; diff --git a/src/lib/evas/common/evas_font_ot.c b/src/lib/evas/common/evas_font_ot.c index a5fe5b2..3c4d4db 100644 --- a/src/lib/evas/common/evas_font_ot.c +++ b/src/lib/evas/common/evas_font_ot.c @@ -268,7 +268,7 @@ _evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Int *fi, Evas_Text_Pro EAPI Eina_Bool evas_common_font_ot_populate_text_props(const Eina_Unicode *text, - Evas_Text_Props *props, int len, Evas_Text_Props_Mode mode) + Evas_Text_Props *props, int len, Evas_Text_Props_Mode mode, const char *lang) { RGBA_Font_Int *fi; hb_buffer_t *buffer; @@ -293,8 +293,7 @@ evas_common_font_ot_populate_text_props(const Eina_Unicode *text, buffer = hb_buffer_create(); hb_buffer_set_unicode_funcs(buffer, _evas_common_font_ot_unicode_funcs_get()); - hb_buffer_set_language(buffer, hb_language_from_string( - evas_common_language_from_locale_get(), -1)); + hb_buffer_set_language(buffer, hb_language_from_string(lang, -1)); hb_buffer_set_script(buffer, _evas_script_to_harfbuzz[props->script]); hb_buffer_set_direction(buffer, (props->bidi_dir == EVAS_BIDI_DIRECTION_RTL) ? diff --git a/src/lib/evas/common/evas_font_ot.h b/src/lib/evas/common/evas_font_ot.h index 6f66731..fe263db 100644 --- a/src/lib/evas/common/evas_font_ot.h +++ b/src/lib/evas/common/evas_font_ot.h @@ -34,6 +34,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_Mode mode); + Evas_Text_Props *props, int len, Evas_Text_Props_Mode mode, const char *lang); #endif diff --git a/src/lib/evas/common/evas_text_utils.c b/src/lib/evas/common/evas_text_utils.c index bef21fe..9223c6e 100644 --- a/src/lib/evas/common/evas_text_utils.c +++ b/src/lib/evas/common/evas_text_utils.c @@ -343,13 +343,13 @@ evas_common_text_props_merge(Evas_Text_Props *item1, #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) + Evas_Text_Props *text_props, int len, Evas_Text_Props_Mode mode, const char *lang) { size_t char_index; Evas_Font_Glyph_Info *gl_itr; Evas_Coord pen_x = 0, adjust_x = 0; - evas_common_font_ot_populate_text_props(text, text_props, len, mode); + evas_common_font_ot_populate_text_props(text, text_props, len, mode, lang); gl_itr = text_props->info->glyph; for (char_index = 0 ; char_index < text_props->len ; char_index++) @@ -520,7 +520,7 @@ _content_create_regular(RGBA_Font_Int *fi, const Eina_Unicode *text, 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) + size_t par_pos, int len, Evas_Text_Props_Mode mode, const char *lang) { RGBA_Font_Int *fi = (RGBA_Font_Int *) _fi; @@ -558,8 +558,9 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, #ifdef OT_SUPPORT (void) par_props; (void) par_pos; - _content_create_ot(fi, text, text_props, len, mode); + _content_create_ot(fi, text, text_props, len, mode, lang); #else + (void) lang; _content_create_regular(fi, text, text_props, par_props, par_pos, len, mode); #endif diff --git a/src/lib/evas/common/evas_text_utils.h b/src/lib/evas/common/evas_text_utils.h index 8b9dd97..96f3d2a 100644 --- a/src/lib/evas/common/evas_text_utils.h +++ b/src/lib/evas/common/evas_text_utils.h @@ -179,7 +179,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, Evas_Text_Props_Mode mode); + size_t par_pos, int len, Evas_Text_Props_Mode mode, const char *lang); void evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst, diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 2e0aba0..dc1aa40 100755 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1375,7 +1375,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, 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); + Eina_Bool (*font_text_props_info_create) (void *data, 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, const char *lang); int (*font_right_inset_get) (void *data, Evas_Font_Set *font, const Evas_Text_Props *text_props); /* EFL-GL Glue Layer */ diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 087bb02..e5c9505 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -2691,10 +2691,10 @@ eng_font_pen_coords_get(void *data EINA_UNUSED, Evas_Font_Set *font, const Evas_ } static Eina_Bool -eng_font_text_props_info_create(void *data EINA_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) +eng_font_text_props_info_create(void *data EINA_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, const char *lang) { return evas_common_text_props_content_create((RGBA_Font_Int *) fi, text, - text_props, par_props, par_pos, len, mode); + text_props, par_props, par_pos, len, mode, lang); } static int -- 2.7.4