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
This commit is contained in:
Tom Hacohen 2012-06-12 14:14:52 +00:00
parent edfa1dfe61
commit a9709c792e
8 changed files with 86 additions and 51 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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,

View File

@ -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

View File

@ -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;

View File

@ -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,

View File

@ -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

View File

@ -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