forked from enlightenment/efl
Evas font engine: Added evas_common_font_query_pen_coords.
SVN revision: 56432
This commit is contained in:
parent
3d6ca9eca9
commit
952ba44f0b
|
@ -60,6 +60,7 @@ EAPI void evas_common_font_query_size (RGBA_Font *fn, con
|
|||
EAPI int evas_common_font_query_inset (RGBA_Font *fn, const Eina_Unicode *text);
|
||||
EAPI void evas_common_font_query_advance (RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int *h_adv, int *v_adv);
|
||||
EAPI int evas_common_font_query_char_coords (RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch);
|
||||
EAPI int evas_common_font_query_pen_coords (RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch);
|
||||
EAPI int evas_common_font_query_char_at_coords (RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int x, int y, int *cx, int *cy, int *cw, int *ch);
|
||||
EAPI int evas_common_font_query_last_up_to_pos (RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int x, int y);
|
||||
|
||||
|
|
|
@ -292,6 +292,105 @@ end:
|
|||
return ret_val;
|
||||
}
|
||||
|
||||
/* x y w h for pen at char pos for null it returns the position right after
|
||||
* the last char with 0 as width and height. This is the same as char_coords
|
||||
* but it returns the pen_x and adv instead of x and w.
|
||||
* BiDi handling: We receive the shaped string + other props from intl_props,
|
||||
* We care about the actual drawing location of the string, this is why we need
|
||||
* the visual string. We need to know how it's printed. After that we need to calculate
|
||||
* the reverse kerning in case of rtl parts. "pos" passed to this function is an
|
||||
* index in bytes, that is the actual byte location of the string, we need to find
|
||||
* the index in order to find it in the visual string.
|
||||
*/
|
||||
|
||||
EAPI int
|
||||
evas_common_font_query_pen_coords(RGBA_Font *fn, const Eina_Unicode *in_text, const Evas_BiDi_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
|
||||
{
|
||||
int asc, desc;
|
||||
int position = 0;
|
||||
const Eina_Unicode *text = in_text;
|
||||
int ret_val = 0;
|
||||
int use_kerning;
|
||||
RGBA_Font_Int *fi;
|
||||
EVAS_FONT_WALK_TEXT_INIT();
|
||||
_INIT_FI_AND_KERNING();
|
||||
|
||||
#ifdef BIDI_SUPPORT
|
||||
int len = 0;
|
||||
EvasBiDiStrIndex *visual_to_logical = NULL;
|
||||
Eina_Unicode *visual_text;
|
||||
|
||||
visual_text = eina_unicode_strdup(in_text);
|
||||
if (visual_text)
|
||||
{
|
||||
evas_bidi_props_reorder_line(visual_text, intl_props->start,
|
||||
eina_unicode_strlen(visual_text), intl_props->props,
|
||||
&visual_to_logical);
|
||||
text = visual_text;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = in_text;
|
||||
}
|
||||
len = eina_unicode_strlen(text);
|
||||
#endif
|
||||
|
||||
asc = evas_common_font_max_ascent_get(fn);
|
||||
desc = evas_common_font_max_descent_get(fn);
|
||||
|
||||
#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);
|
||||
#else
|
||||
position = pos;
|
||||
#endif
|
||||
/* If it's the null, choose location according to the direction. */
|
||||
if (!text[position])
|
||||
{
|
||||
/* 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, 0))
|
||||
{
|
||||
if (cpen_x) *cpen_x = 0;
|
||||
if (ch) *ch = asc + desc;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
evas_common_font_query_advance(fn, text, intl_props, cpen_x, ch);
|
||||
}
|
||||
if (cy) *cy = 0;
|
||||
if (cadv) *cadv = 0;
|
||||
ret_val = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
EVAS_FONT_WALK_TEXT_START()
|
||||
{
|
||||
EVAS_FONT_WALK_TEXT_WORK();
|
||||
/* we need to see if the char at the visual position is the char wanted */
|
||||
if (char_index == position)
|
||||
{
|
||||
if (cpen_x) *cpen_x = pen_x;
|
||||
if (cy) *cy = -asc;
|
||||
if (cadv) *cadv = adv;
|
||||
if (ch) *ch = asc + desc;
|
||||
ret_val = 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
EVAS_FONT_WALK_TEXT_END();
|
||||
end:
|
||||
|
||||
#ifdef BIDI_SUPPORT
|
||||
if (visual_to_logical) free(visual_to_logical);
|
||||
if (visual_text) free(visual_text);
|
||||
#endif
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/* char pos of text at xy pos
|
||||
* BiDi handling: Since we are looking for the char at the specific coords,
|
||||
* we have to get the visual string (to which the coords relate to), do
|
||||
|
|
|
@ -668,6 +668,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, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch);
|
||||
};
|
||||
|
||||
struct _Evas_Image_Load_Func
|
||||
|
|
|
@ -93,6 +93,7 @@ static int eng_font_inset_get(void *data, void *font, char *text);
|
|||
static int eng_font_h_advance_get(void *data, void *font, char *text);
|
||||
static int eng_font_v_advance_get(void *data, void *font, char *text);
|
||||
static int eng_font_char_coords_get(void *data, void *font, char *text, int pos, int *cx, int *cy, int *cw, int *ch);
|
||||
static int eng_font_pen_coords_get(void *data, void *font, char *text, int pos, int *cpen_x, int *cy, int *cadv, int *ch);
|
||||
static int eng_font_char_at_coords_get(void *data, void *font, char *text, int x, int y, int *cx, int *cy, int *cw, int *ch);
|
||||
static void eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, char *text);
|
||||
static void eng_font_cache_flush(void *data);
|
||||
|
@ -211,9 +212,13 @@ static Evas_Func eng_func =
|
|||
eng_image_scale_hint_get,
|
||||
/* more font draw functions */
|
||||
eng_font_last_up_to_pos,
|
||||
NULL, // image_map4_draw
|
||||
NULL, // image_map_surface_new
|
||||
NULL // image_map_surface_free
|
||||
NULL, // ORD(image_map4_draw);
|
||||
NULL, // ORD(image_map_surface_new);
|
||||
NULL, // ORD(image_map_surface_free);
|
||||
NULL, // eng_image_content_hint_set - software doesn't use it
|
||||
NULL, // eng_image_content_hint_get - software doesn't use it
|
||||
eng_font_pen_coords_get
|
||||
/* FUTURE software generic calls go here */
|
||||
};
|
||||
|
||||
static void *
|
||||
|
@ -1272,6 +1277,16 @@ eng_font_char_coords_get(void *data, void *font, char *text, int pos, int *cx, i
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_pen_coords_get(void *data, void *font, char *text, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
/* FIXME, use cairo font subsystem */
|
||||
re = (Render_Engine *)data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_char_at_coords_get(void *data, void *font, char *text, int x, int y, int *cx, int *cy, int *cw, int *ch)
|
||||
{
|
||||
|
|
|
@ -1096,6 +1096,15 @@ eng_font_char_coords_get(void *data, void *font, const char *text, const Evas_Bi
|
|||
return 1;
|
||||
}
|
||||
|
||||
/*FIXME: this is *NOT* implemennted correctly, look at the other engines to
|
||||
* see what needed to be done */
|
||||
static int
|
||||
eng_font_pen_coords_get(void *data, void *font, const char *text, const Evas_BiDi_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
|
||||
{
|
||||
return eng_font_char_coords_get(data, font, text, intl_props, pos, cpen_x,
|
||||
cy, cadv, ch)
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_char_at_coords_get(void *data, void *font, const char *text, const Evas_BiDi_Props *intl_props, int x, int y, int *cx, int *cy, int *cw, int *ch)
|
||||
{
|
||||
|
|
|
@ -80,6 +80,7 @@ static int eng_font_inset_get(void *data, void *font, const char *text);
|
|||
static int eng_font_h_advance_get(void *data, void *font, const char *text, const Evas_BiDi_Props *intl_props);
|
||||
static int eng_font_v_advance_get(void *data, void *font, const char *text, const Evas_BiDi_Props *intl_props);
|
||||
static int eng_font_char_coords_get(void *data, void *font, const char *text, const Evas_BiDi_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch);
|
||||
static int eng_font_pen_coords_get(void *data, void *font, const char *text, const Evas_BiDi_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch);
|
||||
static int eng_font_char_at_coords_get(void *data, void *font, const char *text, const Evas_BiDi_Props *intl_props, int x, int y, int *cx, int *cy, int *cw, int *ch);
|
||||
static void eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text, const Evas_BiDi_Props *intl_props);
|
||||
static void eng_font_hinting_set(void *data, void *font, int hinting);
|
||||
|
|
|
@ -534,6 +534,12 @@ eng_font_v_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *te
|
|||
return v;
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_pen_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
|
||||
{
|
||||
return evas_common_font_query_pen_coords(font, text, intl_props, pos, cpen_x, cy, cadv, ch);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_char_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch)
|
||||
{
|
||||
|
@ -723,7 +729,8 @@ static Evas_Func func =
|
|||
NULL, // ORD(image_map_surface_new);
|
||||
NULL, // ORD(image_map_surface_free);
|
||||
NULL, // eng_image_content_hint_set - software doesn't use it
|
||||
NULL // eng_image_content_hint_get - software doesn't use it
|
||||
NULL, // eng_image_content_hint_get - software doesn't use it
|
||||
eng_font_pen_coords_get
|
||||
/* FUTURE software generic calls go here */
|
||||
};
|
||||
|
||||
|
|
|
@ -591,6 +591,13 @@ eng_font_v_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *te
|
|||
return v;
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_pen_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props,
|
||||
int pos, int *cpen, int *cy, int *cadv, int *ch)
|
||||
{
|
||||
return evas_common_font_query_pen_coords(font, text, intl_props, pos, cpen, cy, cadv, ch);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_char_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props,
|
||||
int pos, int *cx, int *cy, int *cw, int *ch)
|
||||
|
@ -768,7 +775,8 @@ static Evas_Func func = {
|
|||
NULL, // ORD(image_map_surface_new);
|
||||
NULL, // ORD(image_map_surface_free);
|
||||
NULL, // eng_image_content_hint_set - software doesn't use it
|
||||
NULL // eng_image_content_hint_get - software doesn't use it
|
||||
NULL, // eng_image_content_hint_get - software doesn't use it
|
||||
eng_font_pen_coords_get
|
||||
/* FUTURE software generic calls go here */
|
||||
};
|
||||
|
||||
|
|
|
@ -704,6 +704,12 @@ eng_font_v_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *te
|
|||
return v;
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_pen_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
|
||||
{
|
||||
return evas_common_font_query_pen_coords(font, text, intl_props, pos, cpen_x, cy, cadv, ch);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_char_coords_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch)
|
||||
{
|
||||
|
@ -890,7 +896,8 @@ static Evas_Func func =
|
|||
eng_image_map_surface_new,
|
||||
eng_image_map_surface_free,
|
||||
NULL, // eng_image_content_hint_set - software doesn't use it
|
||||
NULL // eng_image_content_hint_get - software doesn't use it
|
||||
NULL, // eng_image_content_hint_get - software doesn't use it
|
||||
eng_font_pen_coords_get
|
||||
/* FUTURE software generic calls go here */
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue