From 1dac813ace3d2108f4b56f1f2ceb71499aa81c05 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 13 Apr 2011 08:37:01 +0000 Subject: [PATCH] Evas font-engine: Fix the fallback fribidi shaper. Just keep the shaped string in the string object if fribidi is used without harfbuzz. SVN revision: 58620 --- .../src/lib/engines/common/evas_font_draw.c | 6 ++++++ .../src/lib/engines/common/evas_text_utils.c | 19 ++++++++++++++++++- .../src/lib/engines/common/evas_text_utils.h | 6 +++++- .../engines/software_generic/evas_engine.c | 18 +++--------------- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font_draw.c b/legacy/evas/src/lib/engines/common/evas_font_draw.c index cc38ad9a75..e5594cc7fa 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_draw.c +++ b/legacy/evas/src/lib/engines/common/evas_font_draw.c @@ -414,7 +414,13 @@ evas_common_font_draw_internal(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font const Evas_Text_Props *text_props, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, RGBA_Font_Int *fi, int im_w, int im_h __UNUSED__) { +#if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT) + (void) in_text; + const Eina_Unicode *text = text_props->info->shaped_text + + text_props->text_offset; +#else const Eina_Unicode *text = in_text; +#endif DATA32 *im; FT_Face pface = NULL; EVAS_FONT_WALK_TEXT_INIT(); 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 261024bde5..67c3fb294c 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.c +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.c @@ -63,6 +63,10 @@ evas_common_text_props_content_unref(Evas_Text_Props *props) #ifdef OT_SUPPORT if (props->info->ot) free(props->info->ot); +#endif +#if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT) + if (props->info->shaped_text) + free(props->info->shaped_text); #endif free(props->info); props->info = NULL; @@ -171,7 +175,8 @@ evas_common_text_props_merge(Evas_Text_Props *item1, EAPI Eina_Bool evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text, - Evas_Text_Props *text_props, int len) + Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, + size_t par_pos, int len) { RGBA_Font *fn = (RGBA_Font *) _fn; RGBA_Font_Int *fi; @@ -202,6 +207,9 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text, size_t char_index; Evas_Font_Glyph_Info *gl_itr; const Eina_Unicode *base_char; + (void) par_props; + (void) par_pos; + evas_common_font_ot_populate_text_props(fn, text, text_props, len); /* Load the glyph according to the first letter of the script, preety @@ -266,6 +274,15 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text, FT_UInt prev_index; FT_Face pface = NULL; int adv_d, i; +#if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT) + text = text_props->info->shaped_text = eina_unicode_strndup(text, len); + evas_bidi_shape_string(text_props->info->shaped_text, par_props, par_pos, + len); +#else + (void) par_props; + (void) par_pos; +#endif + FTLOCK(); use_kerning = FT_HAS_KERNING(fi->src->ft.face); FTUNLOCK(); 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 1cddb95dfc..6144ce4bb7 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.h +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.h @@ -27,6 +27,9 @@ struct _Evas_Text_Props_Info unsigned int refcount; Evas_Font_Glyph_Info *glyph; Evas_Font_OT_Info *ot; +#if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT) + Eina_Unicode *shaped_text; +#endif }; /* Sorted in visual order when created */ @@ -55,7 +58,8 @@ evas_common_text_props_script_set(Evas_Text_Props *props, EAPI Eina_Bool evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text, - Evas_Text_Props *text_props, int len); + Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, + size_t par_pos, int len); void evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst, 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 f3b2835523..2b47815505 100644 --- a/legacy/evas/src/modules/engines/software_generic/evas_engine.c +++ b/legacy/evas/src/modules/engines/software_generic/evas_engine.c @@ -772,22 +772,10 @@ eng_font_pen_coords_get(void *data __UNUSED__, void *font, const Evas_Text_Props } static Eina_Bool -eng_font_text_props_info_create(void *data __UNUSED__, void *font, const Eina_Unicode *text, Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, size_t pos, size_t len) +eng_font_text_props_info_create(void *data __UNUSED__, void *font, const Eina_Unicode *text, Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, size_t par_pos, size_t len) { - Eina_Bool ret; - (void) par_props; - (void) pos; -#if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT) - Eina_Unicode *tmp = eina_unicode_strndup(text, len); - text = tmp; - evas_bidi_shape_string(text, par_props, pos, len); -#endif - ret = evas_common_text_props_content_create(font, text, text_props, len); - -#if !defined(OT_SUPPORT) && defined(BIDI_SUPPORT) - free(tmp); -#endif - return ret; + return evas_common_text_props_content_create(font, text, text_props, + par_props, par_pos, len); } static int