2011-01-30 05:55:04 -08:00
|
|
|
#include "evas_common.h"
|
2011-01-30 02:36:39 -08:00
|
|
|
#include "evas_text_utils.h"
|
|
|
|
#include "language/evas_bidi_utils.h"
|
|
|
|
#include "language/evas_language_utils.h"
|
|
|
|
#include "evas_font_ot.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_text_props_bidi_set(Evas_Text_Props *props,
|
|
|
|
Evas_BiDi_Paragraph_Props *bidi_par_props, size_t start)
|
|
|
|
{
|
|
|
|
#ifdef BIDI_SUPPORT
|
|
|
|
props->bidi.dir = (evas_bidi_is_rtl_char(
|
|
|
|
bidi_par_props,
|
|
|
|
0,
|
|
|
|
start)) ? EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
|
|
|
|
#else
|
|
|
|
(void) start;
|
|
|
|
(void) bidi_par_props;
|
|
|
|
props->bidi.dir = EVAS_BIDI_DIRECTION_LTR;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_text_props_script_set(Evas_Text_Props *props,
|
|
|
|
const Eina_Unicode *str)
|
|
|
|
{
|
|
|
|
props->script = evas_common_language_script_type_get(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_text_props_content_copy_and_ref(Evas_Text_Props *dst,
|
|
|
|
const Evas_Text_Props *src)
|
|
|
|
{
|
|
|
|
memcpy(dst, src, sizeof(Evas_Text_Props));
|
2011-01-30 02:43:34 -08:00
|
|
|
evas_common_text_props_content_ref(dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_text_props_content_ref(Evas_Text_Props *props)
|
|
|
|
{
|
2011-01-30 05:55:04 -08:00
|
|
|
props->info->refcount++;
|
2011-01-30 02:36:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_text_props_content_unref(Evas_Text_Props *props)
|
|
|
|
{
|
2011-01-30 05:55:04 -08:00
|
|
|
/* We allow this, because sometimes we want to have props without info,
|
|
|
|
* and we don't want to diverge the code paths too much. */
|
|
|
|
if (!props->info)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (props->info->refcount == 0)
|
2011-01-30 02:36:39 -08:00
|
|
|
{
|
2011-01-30 05:55:04 -08:00
|
|
|
ERR("Trying to unref props with refount == 0");
|
|
|
|
return;
|
2011-01-30 02:36:39 -08:00
|
|
|
}
|
|
|
|
|
2011-01-30 05:55:04 -08:00
|
|
|
if (--(props->info->refcount) == 0)
|
|
|
|
{
|
|
|
|
if (props->info->glyph)
|
|
|
|
free(props->info->glyph);
|
2011-01-30 02:38:15 -08:00
|
|
|
#ifdef OT_SUPPORT
|
2011-01-30 05:55:04 -08:00
|
|
|
if (props->info->ot)
|
|
|
|
free(props->info->ot);
|
2011-01-30 02:38:15 -08:00
|
|
|
#endif
|
2011-01-30 05:55:04 -08:00
|
|
|
free(props->info);
|
|
|
|
props->info = NULL;
|
|
|
|
}
|
2011-01-30 02:38:15 -08:00
|
|
|
}
|
|
|
|
|
2011-01-30 02:40:30 -08:00
|
|
|
/* Won't work in the middle of ligatures */
|
|
|
|
EAPI void
|
|
|
|
evas_common_text_props_split(Evas_Text_Props *base,
|
|
|
|
Evas_Text_Props *ext, int cutoff)
|
|
|
|
{
|
2011-01-30 05:55:04 -08:00
|
|
|
evas_common_text_props_content_copy_and_ref(ext, base);
|
|
|
|
if (base->bidi.dir == EVAS_BIDI_DIRECTION_RTL)
|
|
|
|
{
|
|
|
|
ext->start = base->start;
|
|
|
|
base->start = cutoff;
|
|
|
|
ext->len = cutoff;
|
|
|
|
base->len = base->len - cutoff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ext->start = cutoff;
|
|
|
|
ext->len = base->len - cutoff;
|
|
|
|
base->len = cutoff;
|
|
|
|
}
|
2011-01-30 02:40:30 -08:00
|
|
|
}
|
|
|
|
|
2011-01-30 02:41:42 -08:00
|
|
|
/* Won't work in the middle of ligatures */
|
|
|
|
EAPI void
|
|
|
|
evas_common_text_props_merge(Evas_Text_Props *item1,
|
|
|
|
const Evas_Text_Props *item2)
|
|
|
|
{
|
2011-01-30 05:55:04 -08:00
|
|
|
if (item1->info != item2->info)
|
|
|
|
{
|
|
|
|
ERR("tried merge back items that weren't together in the first place.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (item1->bidi.dir == EVAS_BIDI_DIRECTION_RTL)
|
|
|
|
{
|
|
|
|
item1->start = item2->start;
|
|
|
|
}
|
2011-01-30 02:41:42 -08:00
|
|
|
|
2011-01-30 05:55:04 -08:00
|
|
|
item1->len += item2->len;
|
|
|
|
}
|
2011-01-30 02:38:15 -08:00
|
|
|
|