From 509e7bed98fe20ad00860ec1b7c39a21a7031222 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 30 Jan 2011 10:33:43 +0000 Subject: [PATCH] Evas font-engine: handle invisible chars in font query. SVN revision: 56429 --- .../src/lib/engines/common/evas_font_draw.c | 6 ---- .../lib/engines/common/evas_font_private.h | 32 +++++++++++++++---- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font_draw.c b/legacy/evas/src/lib/engines/common/evas_font_draw.c index 2b578fb96e..1e73f2b23f 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_draw.c +++ b/legacy/evas/src/lib/engines/common/evas_font_draw.c @@ -5,12 +5,6 @@ #include "evas_bidi_utils.h" /*defines BIDI_SUPPORT if possible */ #include "evas_font_private.h" /* for Frame-Queuing support */ -#define EVAS_FONT_CHARACTER_IS_INVISIBLE(x) ( \ - ((0x200C <= (x)) && ((x) <= 0x200D)) || /* ZWNJ..ZWH */ \ - ((0x200E <= (x)) && ((x) <= 0x200F)) || /* BIDI stuff */ \ - ((0x202A <= (x)) && ((x) <= 0x202E)) /* BIDI stuff */ \ - ) - #define WORD_CACHE_MAXLEN 50 /* How many to cache */ #define WORD_CACHE_NWORDS 40 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 28d566f282..9d8be42345 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_private.h +++ b/legacy/evas/src/lib/engines/common/evas_font_private.h @@ -29,6 +29,13 @@ void evas_common_font_int_use_trim(void); void evas_common_font_int_unload(RGBA_Font_Int *fi); void evas_common_font_int_reload(RGBA_Font_Int *fi); /* Macros for text walking */ + +#define EVAS_FONT_CHARACTER_IS_INVISIBLE(x) ( \ + ((0x200C <= (x)) && ((x) <= 0x200D)) || /* ZWNJ..ZWH */ \ + ((0x200E <= (x)) && ((x) <= 0x200F)) || /* BIDI stuff */ \ + ((0x202A <= (x)) && ((x) <= 0x202E)) /* BIDI stuff */ \ + ) + /** * @def EVAS_FONT_UPDATE_KERN() * @internal @@ -106,6 +113,7 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi); do \ { \ int adv; \ + int visible; \ prev_index = 0; \ last_adv = 0; \ for (char_index = 0 ; *text ; text++, char_index++) \ @@ -136,10 +144,19 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi); continue; \ } \ kern = 0; \ - bear_x = fg->glyph_out->left; \ - bear_y = fg->glyph_out->top; \ - adv = fg->glyph->advance.x >> 16; \ - width = fg->glyph_out->bitmap.width; \ + if (EVAS_FONT_CHARACTER_IS_INVISIBLE(gl)) \ + { \ + adv = width = bear_x = bear_y = 0; \ + visible = 0; \ + } \ + else \ + { \ + bear_x = fg->glyph_out->left; \ + bear_y = fg->glyph_out->top; \ + adv = fg->glyph->advance.x >> 16; \ + width = fg->glyph_out->bitmap.width; \ + visible = 1; \ + } \ /* hmmm kerning means i can't sanely do my own cached metric */ \ /* tables! grrr - this means font face sharing is kinda... not */ \ /* an option if you want performance */ \ @@ -153,8 +170,11 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi); 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 (adv > 0) \ + /* 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; \