} outline, shadow, glow, glow2;
unsigned char style;
- Evas_BiDi_Props intl_props;
+ Evas_BiDi_Paragraph_Props *bidi_par_props;
+ Evas_BiDi_Props bidi_props;
} cur, prev;
float ascent, descent;
o->ascent = ENFN->font_ascent_get(ENDT, o->engine_data);
ENFN->font_string_size_get(ENDT,
o->engine_data,
- o->cur.text, &o->cur.intl_props,
+ o->cur.text, &o->cur.bidi_props,
&w, &h);
o->ascent = ENFN->font_ascent_get(ENDT, o->engine_data);
o->descent = ENFN->font_descent_get(ENDT, o->engine_data);
obj->layer->evas->pointer.x,
obj->layer->evas->pointer.y, 1, 1);
/* DO II */
- /*Update intl_props*/
+ /*Update bidi_props*/
#ifdef BIDI_SUPPORT
- evas_bidi_paragraph_props_unref(o->cur.intl_props.props);
- o->cur.intl_props.props = evas_bidi_paragraph_props_get(text);
- evas_bidi_shape_string(text, o->cur.intl_props.props, 0, len);
+ evas_bidi_paragraph_props_unref(o->cur.bidi_par_props);
+ o->cur.bidi_par_props = evas_bidi_paragraph_props_get(text);
+ evas_bidi_shape_string(text, o->cur.bidi_par_props, 0, len);
#endif
if (o->cur.text) eina_ustringshare_del(o->cur.text);
if (o->cur.utf8_text) eina_stringshare_del(o->cur.utf8_text);
ENFN->font_string_size_get(ENDT,
o->engine_data,
- o->cur.text, &o->cur.intl_props,
+ o->cur.text, &o->cur.bidi_props,
&w, &h);
evas_text_style_pad_get(o->cur.style, &l, &r, &t, &b);
obj->cur.geometry.w = w + l + r;
MAGIC_CHECK_END();
if (!o->engine_data) return 0;
if (!o->cur.text) return 0;
- return ENFN->font_h_advance_get(ENDT, o->engine_data, o->cur.text, &o->cur.intl_props);
+ return ENFN->font_h_advance_get(ENDT, o->engine_data, o->cur.text,
+ &o->cur.bidi_props);
}
/**
MAGIC_CHECK_END();
if (!o->engine_data) return 0;
if (!o->cur.text) return o->ascent + o->descent;
- return ENFN->font_v_advance_get(ENDT, o->engine_data, o->cur.text, &o->cur.intl_props);
+ return ENFN->font_v_advance_get(ENDT, o->engine_data, o->cur.text,
+ &o->cur.bidi_props);
}
/**
MAGIC_CHECK_END();
if (!o->engine_data) return EINA_FALSE;
if (!o->cur.text) return EINA_FALSE;
- ret = ENFN->font_char_coords_get(ENDT, o->engine_data, o->cur.text, &o->cur.intl_props,
+ ret = ENFN->font_char_coords_get(ENDT, o->engine_data, o->cur.text,
+ &o->cur.bidi_props,
pos, &x, &y, &w, &h);
evas_text_style_pad_get(o->cur.style, &l, &r, &t, &b);
y += o->max_ascent - t;
if (!o->cur.text) return -1;
return ENFN->font_last_up_to_pos(ENDT,
o->engine_data,
- o->cur.text, &o->cur.intl_props,
+ o->cur.text, &o->cur.bidi_props,
x,
- y - o->max_ascent);
+ y - o->max_ascent);
}
/**
if (!o->cur.text) return -1;
ret = ENFN->font_char_at_coords_get(ENDT,
o->engine_data,
- o->cur.text, &o->cur.intl_props,
+ o->cur.text, &o->cur.bidi_props,
x,
y - o->max_ascent,
&rx, &ry,
o->magic = MAGIC_OBJ_TEXT;
o->prev = o->cur;
#ifdef BIDI_SUPPORT
- o->cur.intl_props.props = evas_bidi_paragraph_props_new();
+ o->cur.bidi_par_props = evas_bidi_paragraph_props_new();
#endif
return o;
}
if (o->cur.source) eina_stringshare_del(o->cur.source);
if (o->engine_data) evas_font_free(obj->layer->evas, o->engine_data);
#ifdef BIDI_SUPPORT
- evas_bidi_props_clean(&o->cur.intl_props);
+ evas_bidi_paragraph_props_unref(o->cur.bidi_par_props);
+ evas_bidi_props_clean(&o->cur.bidi_props);
#endif
o->magic = 0;
EVAS_MEMPOOL_FREE(_mp_obj, o);
obj->cur.geometry.h, \
obj->cur.geometry.w, \
obj->cur.geometry.h, \
- o->cur.text, &o->cur.intl_props);
+ o->cur.text, &o->cur.bidi_props);
#if 0
#define DRAW_TEXT(ox, oy) \
if ((o->engine_data) && (o->cur.text)) \
obj->cur.cache.geometry.h, \
obj->cur.geometry.w, \
obj->cur.geometry.h, \
- o->cur.text, &o->cur.intl_props);
+ o->cur.text, &o->cur.bidi_props);
#endif
/* shadows */
if (o->cur.style == EVAS_TEXT_STYLE_SHADOW)
ENFN->font_string_size_get(ENDT,
o->engine_data,
- o->cur.text, &o->cur.intl_props,
+ o->cur.text, &o->cur.bidi_props,
&w, &h);
evas_text_style_pad_get(o->cur.style, &l, &r, &t, &b);
obj->cur.geometry.w = w + l + r;
size_t visual_pos;
#endif
Evas_Coord adv, x, w, h;
- Evas_BiDi_Props bidi_props;
+ Evas_BiDi_Props bidi_props;
};
struct _Evas_Object_Textblock_Text_Item
{
new_ti->parent.text_node = ti->parent.text_node;
new_ti->parent.text_pos = ti->parent.text_pos + cutoff;
- new_ti->parent.bidi_props.start = new_ti->parent.text_pos;
- new_ti->parent.bidi_props.props = new_ti->parent.text_node->bidi_props;
+ new_ti->parent.bidi_props.dir = (evas_bidi_is_rtl_char(
+ new_ti->parent.text_node->bidi_props,
+ new_ti->parent.text_pos,
+ 0)) ? EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
ti = new_ti;
len -= cutoff;
}
ti->parent.text_pos = start + str - tbase;
if (ti->parent.text_node)
{
- ti->parent.bidi_props.start = ti->parent.text_pos;
- ti->parent.bidi_props.props = ti->parent.text_node->bidi_props;
+ ti->parent.bidi_props.dir = (evas_bidi_is_rtl_char(
+ ti->parent.text_node->bidi_props,
+ ti->parent.text_pos,
+ 0)) ? EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
}
tw = th = 0;
if (fmt->font.font)
fi->parent.text_node = n->text_node;
/* FIXME: make it more efficient */
fi->parent.text_pos = _evas_textblock_node_format_pos_get(n);
- fi->parent.bidi_props.props = n->text_node->bidi_props;
- fi->parent.bidi_props.start = fi->parent.text_pos;
+ fi->parent.bidi_props.dir = (evas_bidi_is_rtl_char(
+ fi->parent.text_node->bidi_props,
+ fi->parent.text_pos,
+ 0)) ? EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
}
return fi;
}
void
evas_bidi_props_copy_and_ref(const Evas_BiDi_Props *src, Evas_BiDi_Props *dst)
{
- dst->start = src->start;
- dst->props = evas_bidi_paragraph_props_ref(src->props);
+ dst->dir = src->dir;
}
/**
return EINA_TRUE;
}
+/**
+ * @internal
+ * Reverses the string according to the props
+ *
+ * @param str the string to reverse.
+ */
+void
+evas_bidi_reverse_string(Eina_Unicode *str)
+{
+ eina_unicode_reverse(str);
+}
+
/**
* @internal
/**
* @internal
+ * Returns the reversed pos of the index.
+ *
+ * @param dir the direction of the string
+ * @param len the length of the map.
+ * @param position the position to convert.
+ * @return on success the visual position, on failure the same position.
+ */
+EvasBiDiStrIndex
+evas_bidi_position_reverse(const Evas_BiDi_Props *props, int len, EvasBiDiStrIndex position)
+{
+ if (!props || position >= len)
+ return position;
+
+ return (props->dir == EVAS_BIDI_DIRECTION_RTL) ? (len - 1) - position : position;
+}
+
+/**
+ * @internal
* Checks if the char is rtl oriented. I.e even a neutral char can become rtl
* if surrounded by rtl chars.
*
evas_bidi_props_clean(Evas_BiDi_Props *bidi_props)
{
if (!bidi_props) return;
- evas_bidi_paragraph_props_unref(bidi_props->props);
- bidi_props->props = NULL;
+ bidi_props->dir = EVAS_BIDI_DIRECTION_NATURAL;
}
/**
* @}
};
struct _Evas_BiDi_Props {
- Evas_BiDi_Paragraph_Props *props;
- size_t start;
+ Evas_BiDi_Direction dir;
};
EvasBiDiStrIndex
evas_bidi_position_logical_to_visual(EvasBiDiStrIndex *v_to_l, int len, EvasBiDiStrIndex position);
+EvasBiDiStrIndex
+evas_bidi_position_reverse(const Evas_BiDi_Props *props, int len, EvasBiDiStrIndex position);
+
Eina_Bool
evas_bidi_is_rtl_str(const Eina_Unicode *str);
Eina_Bool
evas_bidi_props_reorder_line(Eina_Unicode *eina_ustr, size_t start, size_t len, const Evas_BiDi_Paragraph_Props *props, EvasBiDiStrIndex **_v_to_l);
+void
+evas_bidi_reverse_string(Eina_Unicode *str) EINA_ARG_NONNULL(1);
+
Evas_BiDi_Paragraph_Props *
evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
#endif
#ifdef BIDI_SUPPORT
- Eina_Unicode *visual_text;
+ Eina_Unicode *visual_text = NULL;
- visual_text = eina_unicode_strdup(in_text);
-
- if (visual_text)
+ if (intl_props && (intl_props->dir == EVAS_BIDI_DIRECTION_RTL))
{
- evas_bidi_props_reorder_line(visual_text, intl_props->start,
- eina_unicode_strlen(visual_text), intl_props->props, NULL);
- text = visual_text;
+ visual_text = eina_unicode_strdup(in_text);
+
+ if (visual_text)
+ {
+ evas_bidi_reverse_string(visual_text);
+ text = visual_text;
+ }
}
- else
+ if (!visual_text)
{
text = in_text;
}
-#else
- intl_props = NULL;
#endif
if (fi->src->current_size != fi->size)
{
/* i.e prev index is now the index and the other way */ \
/* around. There is a slight exception when there are */ \
/* compositing chars involved.*/ \
- if (intl_props && \
- evas_bidi_is_rtl_char(intl_props->props, intl_props->start, char_index) && \
+ if (intl_props && (intl_props->dir == EVAS_BIDI_DIRECTION_RTL) && \
adv > 0) \
{ \
if (evas_common_font_query_kerning(fi, index, prev_index, &kern)) \
_INIT_FI_AND_KERNING();
#ifdef BIDI_SUPPORT
- int len = 0;
- EvasBiDiStrIndex *visual_to_logical = NULL;
- Eina_Unicode *visual_text;
+ Eina_Unicode *visual_text = NULL;
+ int len;
- visual_text = eina_unicode_strdup(in_text);
- if (visual_text)
+ if (intl_props && (intl_props->dir == EVAS_BIDI_DIRECTION_RTL))
{
- evas_bidi_props_reorder_line(visual_text, intl_props->start,
- eina_unicode_strlen(visual_text), intl_props->props,
- &visual_to_logical);
- text = visual_text;
+ visual_text = eina_unicode_strdup(in_text);
+
+ if (visual_text)
+ {
+ evas_bidi_reverse_string(visual_text);
+ text = visual_text;
+ }
}
- else
+ if (!visual_text)
{
text = in_text;
}
#ifdef BIDI_SUPPORT
/* Get the position in the visual string because those are the coords we care about */
- position = evas_bidi_position_logical_to_visual(visual_to_logical, len, pos);
+ position = evas_bidi_position_reverse(intl_props, len, pos);
#else
position = pos;
#endif
/* if it's rtl then the location is the left of the string,
* otherwise, the right. */
#ifdef BIDI_SUPPORT
- if (evas_bidi_is_rtl_char(intl_props->props, intl_props->start, 0))
+ if (intl_props->dir == EVAS_BIDI_DIRECTION_RTL)
{
if (cx) *cx = 0;
if (ch) *ch = asc + desc;
end:
#ifdef BIDI_SUPPORT
- if (visual_to_logical) free(visual_to_logical);
if (visual_text) free(visual_text);
#endif
_INIT_FI_AND_KERNING();
#ifdef BIDI_SUPPORT
- int len = 0;
- EvasBiDiStrIndex *visual_to_logical = NULL;
- Eina_Unicode *visual_text;
+ Eina_Unicode *visual_text = NULL;
+ int len;
- visual_text = eina_unicode_strdup(in_text);
- if (visual_text)
+ if (intl_props && (intl_props->dir == EVAS_BIDI_DIRECTION_RTL))
{
- evas_bidi_props_reorder_line(visual_text, intl_props->start,
- eina_unicode_strlen(visual_text), intl_props->props,
- &visual_to_logical);
- text = visual_text;
+ visual_text = eina_unicode_strdup(in_text);
+
+ if (visual_text)
+ {
+ evas_bidi_reverse_string(visual_text);
+ text = visual_text;
+ }
}
- else
+ if (!visual_text)
{
text = in_text;
}
#ifdef BIDI_SUPPORT
/* Get the position in the visual string because those are the coords we care about */
- position = evas_bidi_position_logical_to_visual(visual_to_logical, len, pos);
+ position = evas_bidi_position_reverse(intl_props, len, pos);
#else
position = pos;
#endif
/* if it's rtl then the location is the left of the string,
* otherwise, the right. */
#ifdef BIDI_SUPPORT
- if (evas_bidi_is_rtl_char(intl_props->props, 0, 0))
+ if (intl_props->dir == EVAS_BIDI_DIRECTION_RTL)
{
if (cpen_x) *cpen_x = 0;
if (ch) *ch = asc + desc;
end:
#ifdef BIDI_SUPPORT
- if (visual_to_logical) free(visual_to_logical);
if (visual_text) free(visual_text);
#endif
#endif
#ifdef BIDI_SUPPORT
- int len = 0;
- EvasBiDiStrIndex *visual_to_logical = NULL;
- Eina_Unicode *visual_text;
-
- visual_text = eina_unicode_strdup(in_text);
+ Eina_Unicode *visual_text = NULL;
+ int len;
- if (visual_text)
+ if (intl_props && (intl_props->dir == EVAS_BIDI_DIRECTION_RTL))
{
- evas_bidi_props_reorder_line(visual_text, intl_props->start,
- eina_unicode_strlen(visual_text), intl_props->props,
- &visual_to_logical);
- text = visual_text;
+ visual_text = eina_unicode_strdup(in_text);
+
+ if (visual_text)
+ {
+ evas_bidi_reverse_string(visual_text);
+ text = visual_text;
+ }
}
- else
+ if (!visual_text)
{
text = in_text;
}
/* we found the char position of the wanted char in the
* visual string, we now need to translate it to the
* position in the logical string */
- position = evas_bidi_position_visual_to_logical(visual_to_logical,
- position);
+ position = evas_bidi_position_reverse(intl_props, len, position);
#endif
ret_val = position;
goto end;
end:
#ifdef BIDI_SUPPORT
- if (visual_to_logical) free(visual_to_logical);
if (visual_text) free(visual_text);
#endif