Evas font-engine: Added right_inset_get.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 29 Mar 2011 13:52:22 +0000 (13:52 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 29 Mar 2011 13:52:22 +0000 (13:52 +0000)
This lets us get the difference between the width and the advance
of a string pretty fast, which means we only need to calculate either
advance or width, because we can now calculate one from the other.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@58181 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/engines/common/evas_font.h
src/lib/engines/common/evas_font_query.c
src/lib/include/evas_private.h
src/modules/engines/cairo_x11/evas_engine.c
src/modules/engines/quartz/evas_quartz_private.h
src/modules/engines/software_16/evas_engine.c
src/modules/engines/software_8/evas_engine.c
src/modules/engines/software_generic/evas_engine.c

index 3db4366..13e5dc5 100644 (file)
@@ -58,6 +58,7 @@ EAPI void              evas_common_font_all_clear            (void);
 EAPI int               evas_common_font_query_kerning        (RGBA_Font_Int* fi, FT_UInt left, FT_UInt right, int* kerning);
 EAPI void              evas_common_font_query_size           (RGBA_Font *fn, const Eina_Unicode *text, const Evas_Text_Props *intl_props, int *w, int *h);
 EAPI int               evas_common_font_query_inset          (RGBA_Font *fn __UNUSED__, const Evas_Text_Props *text_props);
+EAPI int               evas_common_font_query_right_inset    (RGBA_Font *fn __UNUSED__, const Evas_Text_Props *text_props);
 EAPI void              evas_common_font_query_advance        (RGBA_Font *fn, const Eina_Unicode *text, const Evas_Text_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_Text_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_Text_Props *intl_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch);
index ae73e60..026afce 100644 (file)
@@ -66,6 +66,22 @@ evas_common_font_query_inset(RGBA_Font *fn __UNUSED__, const Evas_Text_Props *te
    return text_props->info->glyph[text_props->start].x_bear;
 }
 
+/* text right x inset */
+EAPI int
+evas_common_font_query_right_inset(RGBA_Font *fn __UNUSED__, const Evas_Text_Props *text_props)
+{
+   const Evas_Font_Glyph_Info *gli;
+   if (!text_props->len) return 0;
+   gli = text_props->info->glyph + text_props->start + text_props->len - 1;
+
+   return EVAS_FONT_ROUND_26_6_TO_INT(gli->advance) -
+      (gli->width + gli->x_bear
+#ifdef OT_SUPPORT
+       + text_props->info->ot[text_props->start + text_props->len - 1].x_offset
+#endif
+      );
+}
+
 /* size of the string (width and height) in pixels
  * BiDi handling: We receive the shaped string + other props from text_props,
  * We only care about the size, and the size does not depend on the visual order.
index a8dbf4b..4251d7d 100644 (file)
@@ -683,6 +683,7 @@ struct _Evas_Func
    int  (*image_content_hint_get)          (void *data, void *surface);
    int  (*font_pen_coords_get)            (void *data, void *font, const Eina_Unicode *text, 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__, void *font, Eina_Unicode *text, Evas_Text_Props *intl_props, const Evas_BiDi_Paragraph_Props *par_props, size_t pos, size_t len);
+   int  (*font_right_inset_get)                  (void *data, void *font, const Evas_Text_Props *text_props);
 };
 
 struct _Evas_Image_Load_Func
index 0f9ea14..5a9881e 100644 (file)
@@ -90,6 +90,7 @@ static int eng_font_max_ascent_get(void *data, void *font);
 static int eng_font_max_descent_get(void *data, void *font);
 static void eng_font_string_size_get(void *data, void *font, char *text, int *w, int *h);
 static int eng_font_inset_get(void *data, void *font, const Evas_Text_Props *intl_props);
+static int eng_font_right_inset_get(void *data, void *font, const Evas_Text_Props *intl_props);
 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);
@@ -219,7 +220,8 @@ static Evas_Func eng_func =
      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,
-     eng_font_text_props_info_create
+     eng_font_text_props_info_create,
+     eng_font_right_inset_get
      /* FUTURE software generic calls go here */
 };
 
index c1a1123..024d274 100644 (file)
@@ -77,6 +77,7 @@ static int eng_font_max_ascent_get(void *data, void *font);
 static int eng_font_max_descent_get(void *data, void *font);
 static void eng_font_string_size_get(void *data, void *font, const char *text, const Evas_Text_Props *intl_props, int *w, int *h);
 static int eng_font_inset_get(void *data, void *font, const Evas_Text_Props *intl_props);
+static int eng_font_right_inset_get(void *data, void *font, const Evas_Text_Props *intl_props);
 static int eng_font_h_advance_get(void *data, void *font, const char *text, const Evas_Text_Props *intl_props);
 static int eng_font_v_advance_get(void *data, void *font, const char *text, const Evas_Text_Props *intl_props);
 static int eng_font_char_coords_get(void *data, void *font, const char *text, const Evas_Text_Props *intl_props, int pos, int *cx, int *cy, int *cw, int *ch);
index fd657d9..eaec10e 100644 (file)
@@ -517,6 +517,12 @@ eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *tex
 }
 
 static int
+eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
+{
+   return evas_common_font_query_right_inset(font, text_props);
+}
+
+static int
 eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props)
 {
    int h, v;
@@ -746,7 +752,8 @@ static Evas_Func func =
      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,
-     eng_font_text_props_info_create
+     eng_font_text_props_info_create,
+     eng_font_right_inset_get
      /* FUTURE software generic calls go here */
 };
 
index bc8b933..e060cdb 100644 (file)
@@ -574,6 +574,12 @@ eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *tex
 }
 
 static int
+eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
+{
+   return evas_common_font_query_right_inset(font, text_props);
+}
+
+static int
 eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props)
 {
    int h, v;
@@ -792,7 +798,8 @@ static Evas_Func func = {
    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,
-   eng_font_text_props_info_create
+   eng_font_text_props_info_create,
+   eng_font_right_inset_get
    /* FUTURE software generic calls go here */
 };
 
index be96fe1..d40e09b 100644 (file)
@@ -695,6 +695,12 @@ eng_font_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *tex
 }
 
 static int
+eng_font_right_inset_get(void *data __UNUSED__, void *font, const Evas_Text_Props *text_props)
+{
+   return evas_common_font_query_right_inset(font, text_props);
+}
+
+static int
 eng_font_h_advance_get(void *data __UNUSED__, void *font, const Eina_Unicode *text, const Evas_Text_Props *text_props)
 {
    int h, v;
@@ -926,7 +932,8 @@ static Evas_Func func =
      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,
-     eng_font_text_props_info_create
+     eng_font_text_props_info_create,
+     eng_font_right_inset_get
      /* FUTURE software generic calls go here */
 };