From ad37a5e7bfe1870952fd16f7aa423239411ef244 Mon Sep 17 00:00:00 2001 From: Rafael Antognolli Date: Tue, 15 May 2012 21:15:20 +0000 Subject: [PATCH] evas/cserve2: Use width and horizontal bearing from glyph metrics. Instead of having to render the glyph to get the width and horizontal bearing of it, it's possible to get this information from the glyph metrics (which are available on the glyph slot). This change now allows Evas to only render the glyph at the rendering phase, instead of having to render it during layout phase. SVN revision: 71132 --- .../evas/src/lib/engines/common/evas_font_main.c | 4 ++++ .../evas/src/lib/engines/common/evas_text_utils.c | 15 ++++----------- legacy/evas/src/lib/include/evas_common.h | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font_main.c b/legacy/evas/src/lib/engines/common/evas_font_main.c index 1aed305f97..9356038e42 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_main.c +++ b/legacy/evas/src/lib/engines/common/evas_font_main.c @@ -388,6 +388,10 @@ evas_common_font_int_cache_glyph_get(RGBA_Font_Int *fi, FT_UInt idx) if (fi->fash) _fash_gl_add(fi->fash, idx, (void *)(-1)); return NULL; } + fg->width = EVAS_FONT_ROUND_26_6_TO_INT( + fi->src->ft.face->glyph->metrics.width); + fg->x_bear = EVAS_FONT_ROUND_26_6_TO_INT( + fi->src->ft.face->glyph->metrics.horiBearingX); fg->index = idx; fg->fi = fi; diff --git a/legacy/evas/src/lib/engines/common/evas_text_utils.c b/legacy/evas/src/lib/engines/common/evas_text_utils.c index 741adfab71..cea592a38f 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.c +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.c @@ -337,15 +337,10 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, LKU(fi->ft_mutex); continue; } - if ((!fg->glyph_out) && (!evas_common_font_int_cache_glyph_render(fg))) - { - LKU(fi->ft_mutex); - continue; - } LKU(fi->ft_mutex); - gl_itr->x_bear = fg->glyph_out->left; - gl_itr->width = fg->glyph_out->bitmap.width; + gl_itr->x_bear = fg->x_bear; + gl_itr->width = fg->width; /* text_props->info->glyph[char_index].advance = * text_props->info->glyph[char_index].index = * already done by the ot function */ @@ -435,8 +430,6 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, fg = evas_common_font_int_cache_glyph_get(fi, idx); if (!fg) continue; - if ((!fg->glyph_out) && (!evas_common_font_int_cache_glyph_render(fg))) - continue; kern = 0; if ((use_kerning) && (prev_index) && (idx) && @@ -453,9 +446,9 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, pface = fi->src->ft.face; gl_itr->index = idx; - gl_itr->x_bear = fg->glyph_out->left; + gl_itr->x_bear = fg->x_bear; adv = fg->glyph->advance.x >> 10; - gl_itr->width = fg->glyph_out->bitmap.width; + gl_itr->width = fg->width; if (EVAS_FONT_CHARACTER_IS_INVISIBLE(_gl)) { diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h index 65b9ba8e95..a1c034003e 100644 --- a/legacy/evas/src/lib/include/evas_common.h +++ b/legacy/evas/src/lib/include/evas_common.h @@ -965,6 +965,8 @@ struct _RGBA_Font_Source struct _RGBA_Font_Glyph { FT_UInt index; + Evas_Coord width; + Evas_Coord x_bear; FT_Glyph glyph; FT_BitmapGlyph glyph_out; /* this is a problem - only 1 engine at a time can extend such a font... grrr */