From 6dba792f46580c662dac9d0e8984e57104867eae Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 30 Jan 2011 10:34:36 +0000 Subject: [PATCH] Evas font-engine: Change EVAS_FONT_WALK_TEXT_* functions to advance pen_x at the end of the loop (so a break won't advance it, but a clean finish will) and removed the checking if a diacritic using and advancement hack (that only worked only with specific fonts anyway) so we'll be able to start working with Harfbuzz. SVN revision: 56437 --- .../src/lib/engines/common/evas_font_private.h | 17 ++++------------- .../src/lib/engines/common/evas_font_query.c | 11 +++++------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font_private.h b/legacy/evas/src/lib/engines/common/evas_font_private.h index 9d8be42345..1b782f5a86 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_private.h +++ b/legacy/evas/src/lib/engines/common/evas_font_private.h @@ -87,7 +87,6 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi); #define EVAS_FONT_WALK_TEXT_INIT() \ int pen_x = 0, pen_y = 0; \ int char_index; \ - int last_adv; \ FT_UInt prev_index; \ FT_Face pface = NULL; \ (void) pen_y; /* Sometimes it won't be used */ @@ -115,7 +114,6 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi); int adv; \ int visible; \ prev_index = 0; \ - last_adv = 0; \ for (char_index = 0 ; *text ; text++, char_index++) \ { \ FT_UInt index; \ @@ -168,17 +166,6 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi); \ pface = fi->src->ft.face; \ LKU(fi->ft_mutex); \ - /* If the current one is not a compositing char, do the */ \ - /* previous advance and set the current advance as the next */ \ - /* advance to do. If it's an invisible char (i.e one that shouldn't - * be printed anyhow, we want to advance everything as if it's - * a visible char. FIXME: use a proper way to detect diacritic - * instead. */ \ - if ((adv > 0) || !visible) \ - { \ - pen_x += last_adv; \ - last_adv = adv; \ - } \ /** * @def EVAS_FONT_WALK_TEXT_END @@ -189,6 +176,10 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi); * @see EVAS_FONT_WALK_TEXT_WORK */ #define EVAS_FONT_WALK_TEXT_END() \ + if (visible) \ + { \ + pen_x += adv; \ + } \ prev_index = index; \ } \ } \ diff --git a/legacy/evas/src/lib/engines/common/evas_font_query.c b/legacy/evas/src/lib/engines/common/evas_font_query.c index aed34782ed..a092edb0b5 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_query.c +++ b/legacy/evas/src/lib/engines/common/evas_font_query.c @@ -140,6 +140,7 @@ EAPI void evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props __UNUSED__, int *w, int *h) { int keep_width = 0; + int prev_pen_x = 0; int use_kerning; RGBA_Font_Int *fi; EVAS_FONT_WALK_TEXT_INIT(); @@ -150,9 +151,11 @@ evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_ EVAS_FONT_WALK_TEXT_WORK(); /* Keep the width because we'll need it for the last char */ keep_width = width + bear_x; + /* Keep the previous pen_x, before it's advanced in TEXT_END */ + prev_pen_x = pen_x; } EVAS_FONT_WALK_TEXT_END(); - if (w) *w = pen_x + keep_width; + if (w) *w = prev_pen_x + keep_width; if (h) *h = evas_common_font_max_ascent_get(fn) + evas_common_font_max_descent_get(fn); evas_common_font_int_use_trim(); } @@ -167,7 +170,6 @@ evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_ 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) { - int keep_adv = 0; int use_kerning; RGBA_Font_Int *fi; EVAS_FONT_WALK_TEXT_INIT(); @@ -176,14 +178,11 @@ evas_common_font_query_advance(RGBA_Font *fn, const Eina_Unicode *text, const Ev EVAS_FONT_WALK_TEXT_START() { EVAS_FONT_WALK_TEXT_WORK(); - /* Keep the advancement because we want to also do the last - * advancement */ - keep_adv = adv; } EVAS_FONT_WALK_TEXT_END(); if (v_adv) *v_adv = evas_common_font_get_line_advance(fn); - if (h_adv) *h_adv = pen_x + keep_adv; + if (h_adv) *h_adv = pen_x; evas_common_font_int_use_trim(); }